Compare commits

...
Author SHA1 Message Date
Rbanh 931f561e7f Document FBX dependency acceptance
CI / Format, lint, test, build (push) Has been cancelled
2026-07-13 14:08:25 -04:00
Rbanh 3e30c61c71 Resolve FBX external texture dependencies 2026-07-13 13:41:23 -04:00
Rbanh 7e99243a78 Record deterministic asset acceptance
CI / Format, lint, test, build (push) Waiting to run
2026-07-13 12:09:19 -04:00
Rbanh cbd380a941 Stabilize asset registry publication order 2026-07-13 11:46:51 -04:00
Rbanh e1b2f86a49 Make imported asset fingerprints deterministic 2026-07-13 11:23:06 -04:00
Rbanh a048233fce Record guarded shutdown and scoped UI acceptance
CI / Format, lint, test, build (push) Waiting to run
2026-07-13 10:23:56 -04:00
Rbanh 9e23ae731f Fix scoped editor UI action state 2026-07-13 06:39:30 -04:00
Rbanh 4b33f32357 Guard editor shutdown and track clean savepoints 2026-07-13 05:12:43 -04:00
Rbanh 62b538999d Record sample pack native acceptance
CI / Format, lint, test, build (push) Waiting to run
2026-07-13 04:18:56 -04:00
Rbanh d52cc2e3b7 Fix sample hydration rendering regressions 2026-07-13 03:07:31 -04:00
Rbanh 06010c5922 Add editor sample regression pack 2026-07-13 01:52:58 -04:00
Rbanh c55f34780f Fix live operator UI regressions
CI / Format, lint, test, build (push) Waiting to run
2026-07-13 00:43:10 -04:00
Rbanh 1ab3886028 Complete editor operator invariants
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 23:53:46 -04:00
Rbanh 9a67a25a15 Clarify renderer foundation follow-ups
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 23:01:02 -04:00
Rbanh 0ce43fc399 Add collider authoring diagnostics
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 22:48:00 -04:00
Rbanh 0e7aed40f1 Add transactional physics placement
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 22:07:17 -04:00
Rbanh d1a56f77cc Add terrain material layer painting
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 21:00:13 -04:00
Rbanh 293811aecd Add terrain sculpt stroke tools
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 19:50:47 -04:00
Rbanh ed21bcc52d Add chunked terrain authoring foundation
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 18:43:42 -04:00
Rbanh 577d8dcb27 Refresh production readiness matrix
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 18:10:03 -04:00
Rbanh ba59f57a5a Finish non-blocking native dialog workflows
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 18:06:57 -04:00
Rbanh d038cf3670 Add non-blocking native dialog broker 2026-07-12 17:48:51 -04:00
Rbanh 61be2440bd Document collaborative file safety acceptance
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 17:43:07 -04:00
Rbanh 3794faa4aa Document material workflow acceptance
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 13:18:40 -04:00
Rbanh 02247f029a Add material library and targeted surface drops 2026-07-12 13:14:47 -04:00
Rbanh 3931de1f0a Fix hot reload feature matrix
CI / Format, lint, test, build (push) Waiting to run
2026-07-12 11:35:57 -04:00
Rbanh f2ad88fd03 Define production readiness acceptance gate 2026-07-12 11:29:17 -04:00
Rbanh 5a82a9ee29 Add collaborative authored-file safety 2026-07-12 11:27:57 -04:00
Rbanh b4aa61e394 Ship production navigation authoring workflow 2026-07-12 02:53:43 -04:00
Rbanh 0798aa5d57 Build renderer and material component foundations
Add dedicated skinned rendering, pose restoration, shared Material and Material Instance slots, registry-driven components, Surface/Solari integration, transactional schema upgrades, navigation authoring, documentation, and evaluation evidence.
2026-07-12 00:24:06 -04:00
300 changed files with 53521 additions and 4965 deletions

No files matched your search

+3
View File
@@ -7,4 +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 --"
@@ -21,9 +21,23 @@ performance, soak, regression, and first-hour workflows must pass against a repr
`#43`; M6 implementation is complete.
4. Completed: authoritative content validation `#45` and the validation-gated packaging/Build
workflow `#44`.
5. Completed: audio source/listener/bus authoring and spatial preview passed production acceptance
in `#47`. Next: animation `#46`, navigation `#48`, source-control safety `#49`, then readiness
gate `#50`.
5. Completed: audio `#47`, animation `#46`, and navigation `#48` passed production acceptance.
Source-control safety `#49` has complete implementation and source/headless acceptance; live
visual acceptance remains before the readiness gate `#50`.
## Implemented Slice - Collaborative Authored-File Safety
- Exact BLAKE3 baselines for scene tabs, staged Material/Material Instance documents, and Project
Settings.
- One guarded atomic publication path for scene save/export, prefab source Apply/history, and
editable materials, including missing-file and immediate pre-rename race protection.
- Non-destructive background Git porcelain scanning with optional off-thread ownership providers;
Git/provider absence is quiet.
- Compact active-scene and selected-asset state plus Reload, metadata comparison, Save As, and
Cancel conflict recovery. No force-overwrite action exists.
- Focused race, read-only, provider-lock, parser, non-repository, modal-render, scene, and material
tests pass. Live debug-editor visual acceptance remains pending for a desktop-capable QA session;
packaged acceptance remains owner-deferred.
## M6 - Reliability, Recovery, And Project Workflow
@@ -0,0 +1,31 @@
# Collider Authoring Diagnostics - 2026-07-12
Issue: Gitea #26 (`BS-JD-305`)
## Outcome
Collider authoring exposes one consistent health result to the inspector, Collider viewport,
Diagnostics panel, and physics placement preflight. Shape changes preserve useful dimensions and
remain one typed undo operation.
## Contract
- Authored box, sphere, and capsule overlays include actor world scale.
- Static mesh colliders show cooked runtime bounds when available.
- Green is ready, cyan is a trigger, gray is disabled, amber is warning/stale, and red is invalid
or missing.
- Invalid dimensions and mesh references block dependent workflows. Missing hydration and
colliders over 1,000 meters in world extent are warnings.
- Physics placement consumes the same collider-health checks instead of maintaining a separate
prerequisite definition.
## Work
- [x] Add shared authored/runtime collider diagnostics and focused fixtures.
- [x] Add shape/status-aware viewport overlays and selected-collider HUD state.
- [x] Add inspector health/repair feedback and dimension-preserving undoable shape switching.
- [x] Add scene-wide selectable collider findings to Diagnostics.
- [x] Reuse diagnostics in physics placement prerequisites.
- [x] Add a committed non-blocking showcase scene and update documentation.
- [x] Run source gates and live Wayland acceptance; packaged tests remain skipped by request.
- [x] Commit, push, attach native Gitea evidence, close #26, and close M3 when empty.
@@ -0,0 +1,38 @@
# Deterministic Imported-Asset Fingerprints
**Status:** Complete at `cbd380a9413411667a83f74b66c5a2feda5e1af7`; see
[`docs/editor/evaluations/deterministic-asset-fingerprints/`](../../docs/editor/evaluations/deterministic-asset-fingerprints/).
## Scope
Implement Gitea #56 so imported-source identity is content-addressed and editor/validator runs do
not rewrite project artifacts because checkout timestamps or serialization whitespace changed.
## Contract
- Persist one shared fingerprint for imported model, texture, and audio sources: byte length plus a
BLAKE3 digest of the exact source bytes.
- Do not persist or compare source mtimes as semantic identity. Legacy timestamp fields remain
readable but are ignored.
- Static-mesh and animation manifests use the same content identity as the asset registry.
- Preserve stable registry UUIDs across metadata-only drift and uniquely identifiable source moves.
- Before writing a registry or generated manifest, compare the parsed semantic document; preserve
the existing bytes when the result is equivalent.
- Project validators stay read-only and validate both length and digest, including same-size edits.
## Implementation
1. Add the shared fingerprint type and migrate animation/static-mesh contracts.
2. Persist fingerprints for model, texture, and audio registry records and generalize move recovery.
3. Make registry and manifest publication semantic and byte-preserving.
4. Extend static-mesh and registry validation plus focused migration/read-only tests.
5. Update ADRs, asset-pipeline docs, CI clean-worktree assertion, and committed generated artifacts.
## Verification
- Focused editor and scene tests for mtime-only drift, same-size changes, legacy manifests,
byte-preserving equivalent refresh, imported source kinds, and read-only validation.
- Formatting, diff check, clippy, and workspace all-target tests.
- Native editor startup and asset refresh with before/after Git status and source timestamp drift.
- `cargo validate-levels --project .` and `cargo validate-samples --project .`, followed by a clean
worktree assertion. Packaged-runtime tests remain deferred by owner direction.
@@ -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,44 @@
# FBX External Texture Dependencies
**Issue:** Gitea #58 (`BS-JD-210`)
## Goal
Make FBX external texture discovery deterministic from import through runtime loading. Missing or
unsafe references must be reported before the Asset Browser queues Bevy loads, while an explicit
Authoring Override remains a supported untextured workflow.
## Scope
1. Add one path-safe FBX texture-reference resolver shared by the local `bevy_ufbx` loader and the
editor asset pipeline. Normalize separators, deduplicate references, retain relative `textures/`
and `.fbm/` layouts, and reject absolute or parent-traversing references.
2. Decode external images through the FBX `LoadContext`, reuse one handle per normalized path, and
consolidate unavailable dependency logging so duplicate ufbx texture records cannot create
repeated asset-server failures.
3. Generate static-mesh dependencies from parsed FBX texture references. Treat them as required for
Source Materials and as declared-but-optional for Authoring Override during read-only project
validation.
4. Replace the FBX-only file copy with a staged bundle transaction that preflights every referenced
file, preserves relative sidecar layout, backs up overwritten destinations, and rolls back a
partial commit.
5. Preflight source-material thumbnails, retain neutral direct FBX mesh/model previews, and expose a
stable failure reason plus missing dependency status in the Asset Browser.
6. Deliberately normalize the committed painted-chair fixture to Authoring Override rather than add
large absent 2K textures.
## Verification
- Unit tests for sibling `textures/`, `.fbm/`, duplicate references, missing files, path traversal,
destination symlink containment, transactional preservation, consolidated project findings, and
read-only validation.
- `cargo fmt`, focused crate tests, workspace Clippy, workspace tests, `validate-levels`, and
`validate-samples`. Packaged tests remain deferred by project-owner direction.
- Native editor QA for the painted chair and an intentionally broken Source Materials variant,
including log inspection and screenshots published as ordinary Gitea attachments.
## Documentation
- Record the cross-crate dependency/override contract in ADR 0044.
- Update editor architecture, Asset Browser workflow, root controls/checklist, documentation maps,
and an issue-specific evaluation record.
@@ -0,0 +1,62 @@
# Guarded Shutdown And History Savepoints
Date: 2026-07-13
Issue: BS-PR-709 / Gitea #55
Milestone: M7 - Production Readiness
## Goal
Route every editor-exit surface through one non-blocking dirty-document decision and make scene
dirtiness follow the authored undo timeline. Closing the native window, choosing File > Quit, and
requesting an editor exit programmatically must never silently discard dirty scene tabs.
## Decisions
- The editor disables Bevy's automatic close-and-exit systems and owns primary-window close
requests. A guarded-shutdown resource is the single authority that may emit `AppExit`.
- The final dirty-state recheck and `AppExit` authorization run in a dedicated schedule after
Bevy's `Last`; session clean-marker persistence runs after that finalizer.
- Native window close, File > Quit, and internal editor quit requests enqueue the same shutdown
intent. Repeated requests while confirmation or Save As is pending are coalesced.
- Clean sessions exit immediately. Dirty sessions use the shared `NativeDialogBroker` and a single
Save All / Discard / Cancel decision. Cancel preserves all tabs and live editor state; Discard
exits without rewriting authored files; Save All exits only after every dirty tab is saved.
- Untitled tabs and other asynchronous Save As work keep shutdown pending until their dialog result
is applied on the main thread. Cancellation or any failed write returns the editor to an idle,
dirty, recoverable state and does not emit `AppExit`.
- Each scene tab retains a canonical authored-content checkpoint established only by a successful
load or save. The checkpoint is keyed by stable actor identity, canonical component order, stable
parent identity, and scene composition rather than transient Bevy entity numbers.
- Push marks the active document dirty. Undo and redo serialize the authoritative authored
projection and compare it with that tab's checkpoint, so saving at nonzero history depth,
returning to that point, branching, tab switches, and direct non-history mutations remain exact.
## Implementation
1. Add per-tab canonical clean checkpoints to scene I/O and reconcile `SceneIo::dirty` after push,
undo, redo, save, load, and document switches without persisting Entity-ID-based history stacks.
2. Add focused history tests for undo-to-clean, redo-away-from-clean, save at nonzero depth,
branching before/after the clean point, and tab isolation.
3. Add a guarded-shutdown plugin/resource that intercepts `WindowCloseRequested`, accepts menu and
programmatic requests, coordinates non-blocking confirmation/save completion, and emits the only
final `AppExit` for the full editor.
4. Make Save All report complete, pending, cancelled, or failed explicitly. Resume pending shutdown
after untitled Save As completion and preserve the originating tab plus dirty state on failure.
5. Add File > Quit and route Switch Project's exit half through the same guard without spawning a
replacement process until the dirty-document decision succeeds.
6. Update ADR 0023, native-dialog/session-recovery documentation, editor architecture guidance,
root README controls/checklist, and production-readiness evidence.
7. Run formatting, strict Clippy, workspace tests, and focused headless state-machine tests. Keep
packaged tests deferred by project-owner direction.
8. Launch the exact editor commit under Hyprland. Exercise Cancel, Discard, Save All, clean close,
File > Quit, and the compositor close button; verify the editor remains responsive during native
dialogs, no state is lost on cancel/failure, and no process or warning remains after exit.
## Acceptance
- Native close, File > Quit, and programmatic editor exit share one guarded implementation.
- One or many dirty tabs cannot be lost without explicit Discard; failed or cancelled saves do not
exit and preserve the session.
- Undoing exactly to the saved state clears the dirty marker; redo or a divergent edit restores it.
- Saving at nonzero history depth establishes a new clean point without deleting useful history.
- Headless state-machine tests and exact-commit native Linux QA pass with clean logs.
@@ -0,0 +1,94 @@
# Material Library And Targeted Viewport Drop
Working implementation plan for Gitea issues
[`#16`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/16) and
[`#18`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/18).
The shared Material/Material Instance and stable renderer-slot foundation from `#51` is already
present; this slice completes the production-facing catalog and drag/drop workflow.
## Status
Implemented on `codex/material-library-targeted-drop` after collaborative-safety `#49` was
published and integrated into `main`. Focused and full source-only verification plus live editor
acceptance are green; ticket evidence remains before `#16` / `#18` close.
## Resolved Gaps
- The dockable Material Library now provides cross-folder Material/Instance catalog, usage counts,
health, creation, thumbnails, drag sources, and the guarded existing details editors.
- Viewport Material/Texture drops resolve the surface under the pointer and never broaden to the
current selection or every renderer slot.
- `HydratedRendererMaterialBinding` identifies the exact static/skinned renderer slot; primitives
and stable brush-face IDs use their authored component paths.
- Unsupported, locked, linked, missing, and payload-incompatible targets reject with an explicit
reason and no scene mutation.
- Hover previews are reversible, target changes restore the prior snapshot, and release records one
typed operator/history transaction.
- Viewport pointer tracking remains active while another egui widget owns the drag, so exact target
resolution cannot stall at the viewport boundary.
- Visibility hierarchy setup now precedes generated hydration content, preventing Bevy parent/child
visibility warnings when brush draws are created after scene load.
## Material Library
1. Add a dockable `Material Library` panel, opened from Window and placed in the existing bottom dock
without adding another permanent toolbar.
2. Present project Materials and Material Instances with search, Material/Instance filter, thumbnail
grid/list modes, base/dependency health, and source-control status.
3. Add a scene-usage section that counts renderer-slot, primitive, and brush-face references and can
select/locate users. Do not revive ambiguous hidden scene-local material clones.
4. Reuse the existing guarded Material/Instance drafts for Apply, Revert, Create Instance, and
texture-parameter editing. Shared-file edits remain explicit; scene assignment changes use
history.
5. Material and Instance cells are first-class drag sources and preserve the current pointer-following
visual identity.
## Targeted Drop Contract
Introduce a frame-updated `ViewportAssetDropTarget` resolved by the existing mesh-picking path:
- A hydrated static/skinned draw maps through `HydratedRendererMaterialBinding` to the authored actor
and exact stable slot ID.
- A primitive maps to its authored actor-level `MaterialDesc`.
- A brush performs authored face intersection and identifies the stable face ID.
- An authored but unsupported target remains a visible invalid target with a specific reason.
- Empty space remains placement-only for placeable assets and invalid for Material/Texture payloads.
Payload matrix:
| Payload | Renderer slot | Primitive | Brush face |
|---------|---------------|-----------|------------|
| Material / Material Instance | Assign exact hit slot; one-slot actors may assign directly | Replace actor material reference/values | Replace the hit face material reference |
| Texture | Reject with guidance to create/edit a Material Instance | Set base-color texture | Set hit-face base-color texture/material binding |
An explicit `Apply All Slots` command remains available from the renderer inspector/library usage
menu; a viewport hit never silently broadens from one slot to all slots.
## Preview, Commit, And Cancel
1. Start a persistent drop-preview session when a supported Material/Texture payload enters the
viewport. Snapshot only the target's affected authored state.
2. Apply a transient visual preview without pushing history or marking the scene dirty.
3. When the pointer changes target, restore the previous snapshot before previewing the new target.
4. On release, restore the transient state first, then commit exactly one typed history/operator
transaction to the identified slot, primitive, or face.
5. On Escape, drag cancellation, leaving the viewport, invalid target, or missing source, restore the
exact snapshot and remove every preview/helper marker.
6. The drag card and target outline name the payload, actor, slot/face, action, and invalid reason.
## Verification
- Focused tests cover exact multi-slot assignment/undo, brush-face-only preview/restore, primitive
Material/Texture resolution, renderer Texture rejection, Material Library filtering, and scene
usage counts.
- Source checks include editor all-target check, focused tests, and strict editor Clippy.
- Live acceptance covered the docked catalog, search/type/usage filters, grid/list views, resolved
Material Instance thumbnails, exact primitive preview, green actor/surface feedback, one-step
commit/undo, and Escape rollback. The same relaunch produced no hydration hierarchy warnings.
- Static/skinned exact-slot, brush-face, locked/linked, incompatible Texture, and non-dirty preview
contracts remain covered by focused automated tests; shared-asset file creation was deliberately
not invoked during live QA to avoid adding throwaway authored files.
- Full verification passed: workspace all-target check, strict workspace Clippy, all workspace tests,
strict editor Clippy with both `dev` and `hot-reload`, level validation with zero blockers, and
navigation artifact freshness. Packaged testing remains deferred until the project owner requests
it again.
@@ -0,0 +1,73 @@
# Navigation Mesh Authoring, Bake Diagnostics, And Path Preview
Working implementation plan for Gitea issue
[`#48`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/48).
This is the navigation production loop required by the M7 content-production milestone.
## Status
Architecture, dependency compatibility, composed-source resolution, persisted path samples,
corrective source-level QA, and live debug-editor acceptance are complete. Packaged/release
acceptance remains explicitly deferred until the project owner requests another packaged pass.
## Outcome
A level designer can author navigation bounds, obstacles, areas, links, and agent profiles; bake a
deterministic versioned artifact; inspect stale or invalid data; preview a path in the viewport; and
use the same artifact through a game-owned runtime query API and headless release validation.
## Architecture
- Shared reflected components own bounds, obstacles, area volumes, links, and scene bake settings.
- The scene crate owns deterministic composed-source resolution, source fingerprinting, bake
artifact IO, the engine-independent query core, and validation.
- Rerecast performs the 3D walkable-surface bake without coupling navigation to a Bevy plugin
release. Polyanya performs proven any-angle runtime and editor-preview path queries.
- Overlapping primitive and additive-brush triangles enter the deterministic bake source; distant
geometry and navigation authoring are excluded from each bounds fingerprint. No synthetic bounds
floor is added.
- The game crate adapts the shared query core to Bevy types and exposes renderer-free artifact
validation. Editor preview and project validation do not implement separate pathfinders.
- Generated artifacts live under `assets/navigation/generated/`, are project-relative runtime
dependencies, and never serialize viewport helpers into authored scenes.
## Implementation Sequence
1. Add reflected authoring schema, versioned bake artifact, source fingerprint, validation, and
exact agent-profile settings.
2. Add deterministic Rerecast bake input extraction for authored bounds/obstacles and headless bake
command coverage.
3. Add game-owned artifact loading and Polyanya path-query API, including authored off-mesh links.
4. Add typed inspectors, create commands, bake/stale status, viewport overlay, and start/end path
preview.
5. Add owner-attributed project validation for invalid links, missing/stale artifacts, unreachable
preview samples, and bake failures.
6. Commit a small sample scene/artifact and run automated, headless, and live debug-editor
acceptance. PIE and packaged runtime acceptance remain deferred by project-owner direction.
## Acceptance Gates
- A designer can create bounds and obstacles, bake, view the resulting mesh, and preview a valid
start-to-end path.
- Agent radius, height, climb, and slope settings deterministically affect the bake fingerprint.
- Relevant geometry or navigation-authoring changes mark the artifact stale; unrelated scene
metadata does not.
- Invalid or dangling links, samples outside the mesh, isolated regions, and bake failures identify
the owning actor or setting and provide a repair action.
- Runtime path queries and editor preview use the same game-owned API and versioned artifact.
- Helper meshes, lines, endpoints, and bake state are transient and never serialize.
- Headless bake and project validation pass for the committed sample fixture, and package dependency
collection includes the current artifact.
- Visible subscenes and nested prefab contributors resolve identically from editor snapshots and
headless tooling; unsupported structural overrides block with an apply/unpack repair action.
## Deliberate Boundaries
- V1 supports static baked navigation plus explicit links. Dynamic crowd avoidance and runtime tile
carving are separate work.
- Full partial-tile regeneration waits for upstream Rerecast tiling support. V1 records affected
source bounds and debounces a deterministic full bake while reporting the dirty region.
- Area costs are authored and validated in V1; path-cost weighting beyond walkable/blocked areas is
deferred until the runtime exposes per-polygon cost callbacks.
- Imported static meshes remain obstacle-authored in V1 because their normalized manifests do not
yet expose deterministic collision triangles to the headless scene crate.
@@ -0,0 +1,36 @@
# Non-Blocking Native Dialogs
Working implementation plan for the production-readiness defect discovered during live acceptance
of collaborative file safety. Opening an `rfd` picker synchronously from an egui/Bevy system stops
window event processing long enough for Hyprland to report Blacksite as unresponsive.
## Scope
1. Add one project-level native-dialog broker with a typed intent, one active dialog, background
native work, and a main-thread result queue.
2. Convert scene open/save-as, asset import/export, prefab save/source selection, subscene selection,
conflict Save As, diagnostics export, and project-launcher folder selection to the broker.
3. Keep destructive or stateful application logic on the Bevy main thread after a path result is
received. Background work may only own the native dialog and its returned paths.
4. Show a stable pending state and reject duplicate dialog requests while a picker is active.
5. Replace blocking native dirty-scene confirmation dialogs with an editor-owned modal when the
scene-transition state machine can preserve the original action exactly.
## Contract
- The editor continues rendering and processing compositor pings while a native dialog is open.
- Cancel returns a typed empty result and does not mutate editor state.
- A result is applied once to the intent that created it; stale or duplicate results cannot run.
- Paths are validated at the same ownership boundary as before. The dialog broker does not read,
write, import, save, or canonicalize project content.
- Existing collaborative revision guards remain authoritative after Save As selection.
- Project-launcher dialogs use the same broker before the full editor plugin group is active.
## Verification
- Focused tests cover request exclusivity, cancel, one-shot result delivery, and typed intent
preservation.
- Source-only workspace formatting, check, strict Clippy, and tests run; packaged acceptance remains
deferred by project-owner direction.
- Native Wayland QA opens representative file, folder, and Save As dialogs under Hyprland and
confirms the Blacksite window remains responsive without an unresponsive-application prompt.
@@ -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.
@@ -0,0 +1,36 @@
# Physics Placement Tool - 2026-07-12
Issue: Gitea #25 (`BS-JD-304`)
## Outcome
Selected authored props can be released into deterministic Avian gravity, preview their
settled transforms in the Scene viewport, and either commit the result as one undoable
transform operation or cancel back to the exact pre-placement state.
## Contract
- Physics is paused during normal Edit mode and while Play mode is paused.
- Placement runs only in Edit mode and owns a transactional physics session.
- Selected mutable level objects must have active rigid-body and non-trigger collider
authoring. Invalid selections produce a precise, non-destructive diagnostic.
- Selected bodies are temporarily dynamic with clean motion state.
- Other movable bodies are temporarily static so they remain collision surfaces without
advancing unrelated authored state.
- Commit restores all temporary runtime overrides and records only changed local transforms
as one grouped history command.
- Cancel restores transforms and runtime physics state exactly and creates no history entry.
- Escape cancels. Enter commits once the session has reached rest. A bounded timeout keeps
unstable scenes controllable.
## Work
- [x] Establish Edit/Play ownership of `Time<Physics>` and preserve paused single-step PIE.
- [x] Implement placement validation, runtime snapshots, deterministic stepping, settling,
timeout, commit, and cancel.
- [x] Add the placement action and session controls to the existing horizontal viewport
toolbar plus a compact status HUD.
- [x] Add unit/integration coverage for prerequisites, settling, cancel, commit, and history.
- [x] Update editor workflow documentation and implementation checklist.
- [x] Run source gates and live Wayland acceptance; packaged tests remain skipped by request.
- [x] Commit, push, attach native Gitea evidence, and close #25.
@@ -0,0 +1,38 @@
# Production-Readiness Acceptance Gate
Working plan for Gitea issue
[`#50`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/50).
This gate is broader than the M7 feature list: it proves the complete daily authoring, content,
recovery, performance, and release workflow against one exact release-candidate commit.
## Status
Audit in progress. The versioned acceptance matrix exists, but no release candidate is nominated and
the gate is not signed off. Packaged/release testing remains explicitly deferred until the project
owner requests it again.
## Sequence
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. 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.
6. Run the eight-hour soak and measured performance protocol, consolidate limitations by severity
and workaround, and obtain independent first-hour/recovery sign-off.
7. Post the signed Gitea milestone comment linking the exact commit and immutable evidence. Close
`#50` only when every required row passes and no P0 blocker remains.
## Gate Rules
- Feature presence is not acceptance evidence.
- A local dirty worktree is not a release candidate.
- Results from another commit or an old package do not transfer to the candidate.
- Deferred, missing, partial, and implementer-only evidence are not passes.
- Every failure records an owner ticket or a concrete rerun condition.
@@ -0,0 +1,25 @@
# Renderer Foundation Acceptance Split - 2026-07-12
Issue: Gitea #51 (`BS-JD-207`)
## Outcome
Accept the shipped renderer/material/Surface foundation without claiming two independent future
systems. Preserve the existing safe raster/Forward behavior and track each remaining boundary with
its own implementation and acceptance contract.
## Decisions
- #51 owns stable static/skinned slots, shared Material/Instance assets, Surface ABI parity for
eligible geometry, transactional migration, and the honest exclusion of deformed Solari meshes.
- #53 owns actual runtime Material Property Block application and promote-to-instance UX. The
existing component schema/persistence exclusion is not represented as runtime completion.
- #54 owns dynamic post-morph/post-skin buffers and instance BLAS updates. It is a documented P2
Solari enhancement, not a raster/Forward production blocker.
## Work
- [x] Audit #51 scope and repository evidence against current runtime behavior.
- [x] Create focused Gitea follow-ups with independent acceptance criteria.
- [x] Correct ADR, material guide, README checklist, evaluation, and production matrix claims.
- [x] Run documentation/diff gates, commit, push, and close #51 with exact follow-up links.
@@ -0,0 +1,43 @@
# Renderer, material, and component foundation
## Goal
Separate static and skinned renderer ownership, restore deterministic skinned edit poses, add shared
material/material-instance slots, and make authoring components registry-driven and composable.
## Component foundation milestone
- Give authoring components immutable IDs distinct from Rust type paths.
- Split persisted active state from inspector ordering with legacy-state migration.
- Route presence, persistence, add/remove/reset/copy/paste, and component history through Bevy
reflection and atomic transactions.
- Treat `ActorKind` as a derived compatibility/display hint; validate component data and explicit
requirements/conflicts.
- Provide one statically linked extension registration helper and reflection round-trip fixture.
- Verify registry integrity, transaction undo/redo, scene save inclusion, composition, and legacy
enable-state preservation.
## Related renderer/material milestone
- Keep `StaticMeshRenderer` and `SkinnedMeshRenderer` as separate authoring and hydration paths.
- Give both renderer types stable imported-source/explicit Material slots and preserve orphaned
assignments by ID across source changes.
- Add versioned Material and direct-base Material Instance assets, sparse editor overrides, shared
handle live refresh, and runtime-only property blocks.
- Capture and restore imported Transform/MorphWeights baselines; sample only the explicitly chosen
default edit clip and never reload a rig for a material-only change.
- Compose one validated Surface evaluator into raster and Solari, including normal/emissive/unlit
fields and exact cutout candidate acceptance. Safely omit skinned/morph geometry from Solari until
instance-owned deformed vertices and dynamic BLAS updates exist.
- Upgrade scenes/materials explicitly to schema v4 with dry-run, staged writes, backup, rollback,
stable slot normalization, and active-state separation.
## Acceptance
- Shared, scene, game, game-hot, editor, Surface, and maintained Solari-fork tests pass.
- `cargo --locked validate-levels` reports zero blocking findings.
- A second project-upgrade dry run reports no changes after apply.
- Editor evidence shows the stable component cards, static/skinned material slots, Material Instance
workflow, deterministic animated actor pose, and Surface/Solari diagnostics.
- Gitea implementation issue and related roadmap issues link the documentation and screenshot
evidence without claiming unsupported dynamic deformed BLAS behavior.
@@ -0,0 +1,58 @@
# Source-Control Status And Collaborative File Safety
Working implementation plan for Gitea issue
[`#49`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/49).
This is the final M7 implementation slice before the production-readiness acceptance gate.
## Status
Implementation, focused source tests, full editor tests, strict editor clippy, and headless checks
are complete. Live debug-editor visual acceptance remains pending for a desktop-capable QA session.
Packaged/release acceptance is explicitly deferred until the project owner requests another
packaged pass.
## Outcome
External edits cannot be silently overwritten by the editor, common Git/read-only/ownership states
are visible without dominating the shell, and projects without Git or an ownership provider behave
normally.
## Implementation Sequence
1. Add exact file revisions, comparison metadata, guarded atomic replacement, and deterministic
pre-rename race coverage.
2. Capture baselines for scene tabs, material/material-instance drafts, and Project Settings;
protect prefab source Apply and exact-file undo/redo with the same guard.
3. Add a non-destructive asynchronous Git scanner and optional ownership-provider registry.
4. Add compact active-scene and selected-asset status plus a recovery modal with reload, compare
metadata, save-as, and cancel.
5. Cover missing/present/read-only/external-change races, porcelain parsing, provider absence, and
document-specific conflict recovery with focused source tests.
6. Run format, strict affected-crate clippy, source tests, headless validation, and live debug-editor
QA. Do not run packaged tests until requested by the project owner.
## Acceptance Gates
- A loaded authored file changed by another process is never replaced by Save, Apply to source, or
prefab source history.
- File creation is also conditional: a file that appears after a save-as baseline is captured is
not overwritten.
- Conflict and read-only UI identifies the path and recovery choices without a force-overwrite
escape hatch.
- Active-scene and selected-asset Git status remain compact and explain themselves on hover.
- Git absence, a non-repository project, and an empty provider registry are quiet normal states.
- Git commands are read-only and never alter index, worktree, commits, branches, or locks.
- Provider state can block an authored write without coupling core editor code to a vendor.
- Source tests simulate a writer changing the target immediately before rename and prove the old or
external content survives.
## Deliberate Boundaries
- Generated registries, imports, thumbnails, navigation bakes, recovery snapshots, and packages are
regenerative/system-owned and do not open authored-file recovery UI.
- V1 compares metadata rather than rendering a text diff; external diff-tool integration is future
work.
- V1 observes ownership/locks. Acquiring, releasing, or stealing locks belongs in a provider-specific
follow-up.
- Git status is project-local and advisory. The content revision guard remains authoritative even
when Git is absent or stale.
@@ -0,0 +1,46 @@
# Terrain Authoring Foundation
Working implementation plan for Gitea
[`#22`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/22).
This establishes the persistent and hydrated terrain contract required by sculpting `#23`, layer
painting `#24`, physics placement `#25`, and the regression pack `#32`.
## Authored Contract
- Add reflected `TerrainDesc` authoring data with a version, square height-grid resolution, inline
finite heights, horizontal sample spacing, vertical scale, chunk quad size, optional shared
Material/Material Instance reference, collider generation, and shadow flags.
- V1 stores the compact height grid in the scene so save/recovery/history/prefab behavior is exact.
A later external heightmap asset migration must be explicit and versioned rather than silently
changing ownership.
- Validate resolution, exact sample count, finite values, positive scale, and chunk bounds before
hydration or publication.
## Hydration
- Partition the grid into deterministic non-overlapping quad chunks with shared boundary samples.
- Generate triangle-list meshes with normals, UVs, U32 indices, and tangents; each generated child
carries owner/chunk coordinates and remains runtime-only.
- Use the authored shared material when resolvable and an explicit terrain fallback otherwise.
- Optionally attach `ColliderConstructor::TrimeshFromMesh` per chunk.
- Rebuild only the owning terrain's generated chunks when descriptor/material/active state changes;
disabling/removing terrain cleans every generated child.
## Editor Integration
- Register Terrain as a stable authoring component and ActorKind with conflicts against primitive,
brush, static renderer, and skinned renderer geometry sources.
- Add an inspector for resolution, world scale, chunk size, collider/shadow state, material summary,
validation, and a guarded flat-grid resize action. All mutations are one typed history step.
- Include terrain bounds in selection framing and generated chunks in authored-parent picking.
- Expose Add Terrain through the existing component shelf; no new permanent toolbar is added.
## Verification
- Tests cover descriptor validation, deterministic chunk coverage/mesh topology, hydration and
cleanup, generated-child stripping, serialization, and history round-trip.
- Source-only workspace format/check/strict-Clippy/tests and level validation run. Packaged tests
remain deferred by project-owner direction.
- Live native-Wayland acceptance creates or loads a terrain actor, verifies chunk rendering and
selection/inspection, changes scale/chunking, exercises undo/redo, and inspects a saved scene to
confirm generated chunks are absent.
@@ -0,0 +1,28 @@
# Terrain Material Layers And Weight Painting (#24)
## Scope
- Persist up to four shared Material/Material Instance references on each `TerrainDesc`.
- Store normalized RGBA8 layer weights per height sample with an implicit channel-zero default.
- Blend layer albedo, normal, metallic, and roughness in the project-owned raster material path.
- Assign, clear, reorder, and tile layers from the Terrain inspector.
- Paint or erase one selected layer from the existing horizontal viewport toolbar.
- Preserve one reflected history transaction per completed pointer stroke and exact cancel restore.
## Implementation
1. Extend the backward-compatible terrain schema with four layer descriptors and compact weights.
2. Emit normalized weights as terrain chunk vertex colors and attach a runtime-only material binding.
3. Build a terrain-specific `ExtendedMaterial` in `blacksite_surface`; keep invalid references on the visible fallback path with diagnostics.
4. Add inspector layer controls and a mutually exclusive modal paint operator beside Sculpt.
5. Cover serialization, validation, blend transport, paint normalization, cancel, undo, and redo.
6. Update ADR 0040, terrain workflow docs, the implementation checklist, and live evidence.
## Acceptance
- Two or more project materials visibly blend on one terrain.
- Layer weights remain exactly normalized and survive scene save/load.
- Live paint preview follows the sampled terrain surface.
- Escape/right-click restores exact pre-stroke weights; release creates one undo entry.
- Missing or invalid material references remain visible as fallback and produce clear diagnostics.
- Formatting, workspace check/clippy/tests, level validation, and live native-Wayland QA pass.
@@ -0,0 +1,25 @@
# Terrain Sculpt Tools (#23)
## Scope
- Add a modal terrain sculpt operator for raise, lower, flatten, smooth, and deterministic noise.
- Keep activation and brush settings in the existing horizontal viewport toolbar.
- Track a terrain-local cursor hit and render a world-space brush footprint preview.
- Apply live stroke previews while preserving one history entry per completed stroke.
- Restore the exact pre-stroke height grid on Escape or right-click.
## Implementation
1. Add pure heightfield sampling, ray-hit, falloff, and brush-dab functions with focused tests.
2. Add editor-only terrain sculpt state and viewport input/preview systems.
3. Commit strokes through the reflected component transaction after restoring the pre-stroke snapshot.
4. Add compact terrain controls to the existing viewport toolbar and update operator hints.
5. Document controls and validation evidence in the terrain editor guide and root checklist.
## Acceptance
- All five modes visibly modify terrain.
- The brush ring follows the actual terrain surface.
- Escape and right-click cancel without dirtying history.
- Mouse release creates exactly one undoable transaction regardless of dab count.
- Formatting, editor/shared checks, focused tests, and live editor QA pass.
+13
View File
@@ -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,14 @@ jobs:
- name: Validate level scenes
run: cargo validate-levels
- name: Validate editor sample pack
run: cargo validate-samples
- name: Assert validation leaves checkout clean
run: |
git diff --exit-code
test -z "$(git ls-files --others --exclude-standard)"
- name: Clippy launch feature matrix
run: cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
+1
View File
@@ -14,6 +14,7 @@
# Editor/runtime generated session state
/assets/levels/.pie_session.scn.ron
/assets/.trash/
/.blacksite/backups/
# Backup, temporary, and log files
**/*.rs.bk
Generated
+540 -169
View File
File diff suppressed because it is too large. Load diff
+7
View File
@@ -1,5 +1,6 @@
[workspace]
members = [
"crates/blacksite_surface",
"crates/game",
"crates/game_hot",
"crates/shared",
@@ -36,6 +37,7 @@ bevy = { version = "0.19", features = [
] }
bevy_core_pipeline = "0.19"
bevy_solari = "0.19"
blacksite_surface = { path = "crates/blacksite_surface" }
bevy_ufbx = "0.18.1-rc.1"
bevy_egui = "0.40"
bevy-inspector-egui = "0.37"
@@ -43,6 +45,9 @@ egui_dock = { version = "0.19.1", features = ["serde"] }
egui_phosphor_icons = { version = "0.3.1", default-features = false }
transform-gizmo-bevy = "0.9"
serde = { version = "1", features = ["derive"] }
nav_glam = { package = "glam", version = "=0.30.10", features = ["serde"] }
polyanya = { version = "=0.16.1", default-features = false, features = ["recast", "serde"] }
rerecast = { version = "=0.3.2", default-features = false, features = ["std", "serialize"] }
shared = { path = "crates/shared" }
game = { path = "crates/game" }
game_hot = { path = "crates/game_hot" }
@@ -52,6 +57,8 @@ settings = { path = "crates/settings" }
scene = { path = "crates/scene" }
[patch.crates-io]
# Blacksite Surface ABI and deformation-safety integration for Solari.
bevy_solari = { path = "third_party/bevy_solari" }
# Local Bevy 0.19 compatibility patch until upstream publishes a matching FBX loader.
bevy_ufbx = { path = "third_party/bevy_ufbx" }
# Lossless RON editing fixes used by transactional prefab source edits.
+93 -17
View File
@@ -27,6 +27,10 @@ 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
# Machine-readable project dependency and finding report
cargo validate-levels --json
cargo package-project --profile development
@@ -53,8 +57,9 @@ cargo run -p editor --bin project_launcher --features dev
```
The installed **Blacksite Editor** desktop entry also exposes **Open Project Browser** from its
desktop action menu. In the editor, **File > Switch Project...** performs a clean shutdown and
opens the same browser; choosing a project starts a fresh editor process with that root.
desktop action menu. In the editor, **File > Switch Project...** uses the guarded Save All / Discard /
Cancel shutdown path before opening the same browser; choosing a project starts a fresh editor
process with that root.
### Hot reload (gameplay iteration)
@@ -132,7 +137,7 @@ deep-stale variants.
| Click empty viewport / `Esc` | Deselect |
| `Delete` / `Backspace` | Delete selection |
| `Ctrl+D` | Duplicate selection |
| `Ctrl+Z` / `Ctrl+Shift+Z` / `Ctrl+Y` | Undo / redo |
| `Ctrl+Z` / `Ctrl+Shift+Z` / `Ctrl+Y` | Undo / redo; returning exactly to the last loaded or saved authored state clears that scene tab's dirty marker |
| `F2` in Hierarchy | Rename selection |
| `W` / `E` / `R` | Translate / rotate / scale gizmo; multi-selection uses one grouped gizmo and undo step |
| `X` | Toggle world/local gizmo orientation |
@@ -141,6 +146,7 @@ deep-stale variants.
| Brush selected: `1` / `2` / `3` / `4` | Vertex / edge / face / clip edit modes |
| Brush edit mode: LMB / `Shift+LMB` / `W` / `E` / `R` / `Esc` | Select element / toggle element selection / move / rotate / scale selected brush elements / return to object mode |
| Viewport toolbar (sun / brush / box icons) | Shading: Lit, Unlit (albedo), Colliders (mesh off) |
| Collider viewport mode | Inspect world-scale box/sphere/capsule overlays and cooked mesh bounds; green/cyan/gray/amber/red identify ready/trigger/disabled/warning/invalid state, with selected health in the lower-left HUD |
| Viewport eye/options | Toggle actor root icon categories, adjust icon/gizmo size, and control colliders, lights, spawns, gameplay markers, volumes, prefab/model anchors, and runtime player/camera visualizers |
| `Tab` in viewport | Cycle selection through overlapping objects at last click |
| Viewport selection/orientation HUD | Identify the primary selection, multi-selection count, overlapping-pick position, camera axes, shading mode, and active render path |
@@ -149,6 +155,10 @@ deep-stale variants.
| Asset Browser project/file views | Browse `assets/`, search/filter/sort models, textures, materials, audio clips, levels, and prefabs; switch grid/list; expand model subassets; inspect file details; audition audio; drag supported assets/submeshes into the viewport |
| Drag audio clip into viewport | Create an authored audio source; when an audio source is selected, assign the clip instead |
| Asset Browser context/details actions | Apply textures/materials, regenerate thumbnails, reimport models, place assets/submeshes, or move file assets to `assets/.trash/` |
| Window → Material Library | Search/filter project Materials and Material Instances, inspect scene usage and dependency health, create/edit shared assets, and drag them into the viewport |
| Drag Material/Instance onto viewport surface | Preview and assign the exact renderer slot, primitive, or brush face under the pointer; release commits one undo step, while Escape/right-click/outside restores the preview |
| Drag Texture onto viewport surface | Set a primitive base-color texture or exact brush face; renderer slots reject loose textures and direct you to a Material Instance |
| Static/Skinned Mesh Renderer material slots | Assign a shared Material/Material Instance per slot; Browse/Select/Locate the reference, or Clear the override to restore the imported source material |
| `Ctrl+P` | Centered command palette; search human labels or stable command IDs, use arrow keys to select, Enter to run |
| `F7` | While paused in Play: advance one sim tick |
| Shift/Ctrl + click (Hierarchy) | Additive selection |
@@ -156,11 +166,18 @@ 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, Open, transactional Save/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, Switch Project, and Quit |
| Window close / **File > Quit** | Clean sessions exit immediately; dirty scene tabs use one non-blocking **Save All / Discard / Cancel** decision, and cancel or failed saves keep the editor open |
| 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 |
| Prefab Instance inspector | Inspect/recover source health, Apply/Revert overrides by scope, Apply overrides to source, create a variant, **Unpack Layer**, or recursively **Convert to Local** |
| Inspector component card | Collapse with caret, toggle active with status dot, or use triple-dot menu for reset/copy/paste/move/remove actions |
| Inspector footer → Add Component | Expands an inline search shelf for registered authoring, rendering, physics, gameplay, and volume components with descriptions, availability hints, and undo |
| Inspector footer → Add Component → Terrain | Add a height-grid terrain actor; configure grid scale/chunking/collision in its component card and use Resize Flat only for deliberate grid replacement |
| Selected Terrain → viewport mountains tool | Sculpt Raise/Lower/Flatten/Smooth/Noise strokes with a terrain-following footprint; release commits one undo step, while Escape/right-click restores the pre-stroke grid |
| Terrain card → Material Layers; selected Terrain → viewport paint tool | Assign up to four shared materials, then Paint/Erase normalized layer weights with live blended preview; release commits one undo step and Escape/right-click restores the pre-stroke map |
| Selected physics props → viewport hand/down-arrow tool | Release the selection into real gravity/colliders; check commits one grouped transform edit, while Escape/X restores the exact starting state |
| Audio Source / Listener inspector | Assign and audition clips; edit gain, pitch, loop/autoplay, spatial blend, attenuation, bus, listener priority, and ear gap |
| Edit → Project Settings… | Edit `assets/project.ron` rendering, audio buses, physics, and input |
@@ -230,10 +247,22 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
details when you need full `WorldAssetRoot` scene data instead of normalized static slots.
Expanding a model in the Asset Browser exposes normalized mesh/material/texture plus generated
skeleton/animation-clip subassets. Dragging a mesh places that part through the static mesh path;
dragging a clip creates an animated scene instance or assigns an exact-rig-compatible state to
the selected imported model. The Animation Controller inspector edits state IDs, clips,
dragging a clip creates a dedicated skinned renderer or assigns an exact-rig-compatible state to
the selected skinned actor. **Default animation** in Model Import Settings optionally selects the
exact clip sampled and paused as the edit-rest pose; **Imported rest pose** never guesses a clip.
Preview stop and PIE exit restore imported transforms and morph weights before resampling that
explicit default. The Animation Controller inspector edits state IDs, clips,
range/loop/speed/default/crossfade and provides non-dirty play/pause/stop/scrub preview. See the
[animation authoring guide](docs/editor/animation-authoring.md) and [ADR 0031](docs/adr/0031-animation-authoring-runtime-contract.md).
- Navigation bounds, obstacles, areas, and links are created from **Scene > Navigation** or the path
icon in the existing horizontal toolbar. Bounds bake versioned Rerecast artifacts under
`assets/navigation/generated/`; overlapping primitive and additive-brush triangles participate
in the bake fingerprint while distant authoring is excluded. Visible composed subscenes and linked
prefab sources resolve through the same deterministic bake path used by CI. The Inspector reports
stale/current state, pins named validation paths, and provides a Polyanya-backed path test whose
mesh, links, and route render in the viewport. Use
`cargo bake-navigation --project . --check` in CI. See the
[navigation authoring guide](docs/editor/navigation-authoring.md) and [ADR 0032](docs/adr/0032-versioned-navigation-bake-and-runtime-query.md).
- Brush actors are persisted as `ActorKind::Brush + BrushDesc`; valid convex faces hydrate into
generated preview meshes. Vertex, edge, and face selections use the standard transform gizmo,
face material/UV fields are undoable, and clip/intersect/merge/subtract provide conservative
@@ -245,6 +274,13 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
without changing the scene.
- Runtime-only handles/colliders are not serialized directly, keeping scenes stable and portable.
- Editor-only cameras and helper roots are filtered from selection, hierarchy, and scene save.
- Loaded scenes, prefab source Apply/history, Materials, Material Instances, and Project Settings
retain exact BLAKE3 disk revisions. Save verifies the revision again immediately before atomic
replacement; an external edit, create race, read-only target, or provider lock leaves the
existing file untouched and opens the collaborative recovery dialog. Git status is observational
and optional. See the
[collaborative file-safety guide](docs/editor/collaborative-file-safety.md) and
[ADR 0037](docs/adr/0037-collaborative-authored-file-safety.md).
- **PIE restores player sim only** (transform, velocity, jump state) when you stop Play; authored
`LevelObject` edits made during PIE **remain** in the scene (the level may show as dirty).
- Play mode swaps the unified viewport between the player camera (possessed) and editor fly camera
@@ -307,6 +343,16 @@ identity, project and active-scene paths, dirty flags, aggregate validation coun
state, and the bounded Scene I/O log. It excludes scene and asset contents, environment values,
host/user identity, credentials, access tokens, and modal tool state.
### External file changes and read-only assets
The active scene status strip and selected asset header show compact Git/read-only/ownership state
when available. If Save or Apply detects a different disk revision, Blacksite leaves that revision
untouched and opens **Authored File Not Saved**. Use **Compare Metadata** to inspect both revisions,
**Save As** to preserve the editor copy elsewhere, **Reload** to take the disk version, or **Cancel**
to keep the local draft unsaved. Git and ownership providers are optional; the status scanner never
stages, commits, resets, checks out, restores, or discards files. See
[collaborative-file-safety.md](docs/editor/collaborative-file-safety.md).
## Cursor / VSCode Setup
The `.vscode/` folder is preconfigured:
@@ -329,6 +375,10 @@ The `.vscode/` folder is preconfigured:
- [ADR 0014: Unified Viewport Model](docs/adr/0014-unified-viewport-model.md)
- [ADR 0016: Unified Rendering Contract](docs/adr/0016-unified-rendering-contract.md)
- [ADR 0017: Normalized Static Mesh Assets](docs/adr/0017-normalized-static-mesh-assets.md)
- [ADR 0034: Registry-driven Authoring Components](docs/adr/0034-registry-driven-authoring-components.md)
- [ADR 0037: Collaborative Authored-File Safety](docs/adr/0037-collaborative-authored-file-safety.md)
- [ADR 0043: Content-Addressed Import Fingerprints](docs/adr/0043-content-addressed-import-fingerprints.md)
- [ADR 0044: Sandboxed FBX External Texture Dependencies](docs/adr/0044-sandboxed-fbx-external-texture-dependencies.md)
## Project Layout
@@ -358,6 +408,14 @@ crates/
- [x] Filtered hierarchy, inspector, viewport, toolbar, asset browser, and status panels
- [x] Delete, duplicate, rename, and structural/material undo-redo
- [x] Native Bevy scene New/Open/Save/Save As with dirty title tracking
- [x] First-class height-grid Terrain actor with deterministic generated render/collider chunks, reflected history, validation, and a committed showcase fixture ([ADR 0039](docs/adr/0039-inline-height-grid-terrain-foundation.md), [terrain guide](docs/editor/terrain.md), [Gitea #22](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/22))
- [x] Modal terrain Raise/Lower/Flatten/Smooth/Noise sculpting with a terrain-following footprint, deterministic noise, safe cancel restore, and one undo transaction per stroke ([terrain guide](docs/editor/terrain.md), [Gitea #23](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/23))
- [x] Four shared terrain Material/Material Instance layers with compact normalized sample weights, blended raster hydration, drag/browse assignment, Paint/Erase preview, exact cancel, and one undo transaction per stroke ([ADR 0040](docs/adr/0040-terrain-material-layer-weights.md), [terrain guide](docs/editor/terrain.md), [Gitea #24](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/24))
- [x] Transactional physics placement with real Avian gravity/colliders, paused Edit-mode physics, prerequisite diagnostics, isolated non-selected bodies, exact cancel, and grouped transform undo ([ADR 0041](docs/adr/0041-transactional-editor-physics-placement.md), [workflow guide](docs/editor/physics-placement.md), [Gitea #25](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/25))
- [x] Collider authoring health shared by the inspector, Collider viewport, Diagnostics panel, and physics placement, with scaled shape overlays, cooked mesh bounds, missing/stale/invalid/oversized findings, and undoable dimension-preserving shape switching ([collider guide](docs/editor/collider-authoring.md), [Gitea #26](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/26))
- [x] Non-blocking native file/folder/confirmation broker across scene, asset, prefab, composition, collaboration, and Project Browser workflows ([ADR 0038](docs/adr/0038-non-blocking-native-dialog-broker.md), [workflow guide](docs/editor/native-dialogs.md), [Gitea #52](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/52))
- [x] Guarded native/menu/programmatic editor shutdown with asynchronous multi-tab Save All / Discard / Cancel and canonical per-tab clean checkpoints for exact undo/redo dirtiness ([ADR 0042](docs/adr/0042-guarded-editor-shutdown-and-document-savepoints.md), [Gitea #55](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/55))
- [x] Scoped egui action safety for toolbar/navigation spawns, Inspector state, cross-panel selection/tab requests, diagnostics selection, and full-slice selection precedence ([evaluation](docs/editor/evaluations/scoped-ui-actions/), [Gitea #57](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/57))
- [x] Asset import, static mesh/prefab placement, texture assignment, and selection export
- [x] PIE player-only snapshot/restore (authored `LevelObject` edits persist on stop)
- [x] Unified viewport render-to-texture target + Play session bootstrap
@@ -366,21 +424,30 @@ 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] Deterministic imported-source fingerprints for models, textures, and audio; BLAKE3-backed
static/animation manifests; byte-preserving equivalent refresh; and read-only validator checkout
assertions ([ADR 0043](docs/adr/0043-content-addressed-import-fingerprints.md), [evaluation](docs/editor/evaluations/deterministic-asset-fingerprints/), [Gitea #56](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/56))
- [x] Sandboxed FBX external-texture discovery for sibling and `.fbm/` layouts, transactional
referenced-bundle import, manifest-first consolidated validation, deduplicated loader reads, and
stable Asset Browser dependency status ([ADR 0044](docs/adr/0044-sandboxed-fbx-external-texture-dependencies.md), [Gitea #58](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/58))
- [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
- [x] Audio clip catalog/import foundation for Ogg, WAV, MP3, and FLAC with dedicated filtering, file details, and stable runtime-resolvable asset references
- [x] Audio source/listener authoring, non-dirty spatial audition, viewport icons/range gizmos, stable buses, PIE/runtime parity, device diagnostics, and shared release validation ([ADR 0030](docs/adr/0030-audio-authoring-and-bus-schema.md); production acceptance completed in [Gitea #47](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/47))
- [x] glTF/GLB skeletal animation manifests, stable controller states, non-dirty preview, PIE/runtime hydration, and exact-signature compatibility validation ([ADR 0031](docs/adr/0031-animation-authoring-runtime-contract.md); production acceptance completed in [Gitea #46](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/46))
- [x] Navigation bounds/obstacles/areas/links, persisted validation samples, composed-source resolution, deterministic stale-checked bake artifacts, viewport path preview, headless bake, and shared game/runtime query API ([ADR 0032](docs/adr/0032-versioned-navigation-bake-and-runtime-query.md); [evaluation](docs/editor/evaluations/navigation-authoring/); [Gitea #48](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/48))
- [x] Exact authored-file revision guards for scenes, prefab source Apply/history, Materials, Material Instances, and Project Settings; compact observational Git/read-only/ownership state; and explicit Reload/Compare Metadata/Save As/Cancel recovery without force overwrite ([ADR 0037](docs/adr/0037-collaborative-authored-file-safety.md), [collaboration guide](docs/editor/collaborative-file-safety.md), [Gitea #49](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/49))
- [x] Prefab instances (`PrefabInstance`) + save-as-prefab + unpack
- [x] Independent dirty-tab close confirmation and all-tab save guard when switching projects
- [x] Transactional scene writes + bounded user-local recovery snapshots ([ADR 0023](docs/adr/0023-transactional-scene-persistence-and-recovery.md))
- [x] Versioned clean/crash session resume + privacy-bounded diagnostic bundle ([ADR 0024](docs/adr/0024-versioned-editor-session-state.md))
- [x] Hierarchy multi-select, reparent undo, multi-entity gizmo transform
- [x] Typed inspector undo (light, rigid body, collider, primitive, material, static mesh renderer) + registry-driven Add Component footer
- [x] Typed inspector undo (light, rigid body, collider, primitive, material, static mesh renderer) + registry-driven Add Component footer; skinned renderer sources are asset-owned and inspectable
- [x] Gameplay authoring markers + visualizers (`WeaponSpawn`, `TriggerVolume`, etc.)
- [x] Command palette execution; PIE sim step (F7); `xtask validate-levels`
- [x] ADRs 0005–0012 (prefab/registry, scene schema, EditorPlugin, editor structure, authoring/hydration, ActorKind, sun policy, zero-debt)
@@ -392,16 +459,20 @@ crates/
- [x] Project Browser UI, strict manifest validation, `--project` startup activation, recent filtering, sandbox scaffolding, clean process handoff, and desktop launcher action ([ADR 0025](docs/adr/0025-project-root-is-a-startup-boundary.md))
- [x] Independent scene tabs + stable subscene composition, recursive validation, ownership locks, active-world PIE consistency, and per-saved-tab recovery ([ADR 0026](docs/adr/0026-stable-scene-composition-and-active-document.md))
- [x] Editor lib/bin split + `EditorPluginGroup`; game EditorPlugin dogfood panel
- [x] FBX/glTF model import + normalized `StaticMeshRenderer` placement; explicit scene-instance load via `bevy_ufbx` / `ModelRef`
- [x] FBX/glTF model import + normalized static/skinned renderer routing; explicit generic scene-instance load via `bevy_ufbx` / `ModelRef`
- [x] Asset browser model thumbnails (unified `assets/thumbnails/` pipeline; `ThumbnailState` cache; FBX via `FbxThumbnailSource`)
- [x] Material assets (`assets/materials/*.ron`, inspector picker, drag-drop to selection)
- [x] Shared Material/Material Instance assets, stable static/skinned renderer material slots, imported-source fallback, orphan preservation, and a persistence-excluded property-block schema; runtime block application/promotion remains tracked in [Gitea #53](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/53) ([ADR 0035](docs/adr/0035-shared-material-assets-and-renderer-slots.md), [material-system guide](docs/editor/material-system.md))
- [x] Docked Material Library with cross-folder type/usage filters, resolved Material Instance thumbnails, shared guarded editors, and exact reversible viewport Material/Texture drops for renderer slots, primitives, and brush faces ([material-system guide](docs/editor/material-system.md); [Gitea #16](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/16), [Gitea #18](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/18))
- [x] Prefab v2 core: shared stable nested override paths, property/component/structural scopes, recursive graph validation, linked-root variants, conflict recovery, transactional source Apply, and undoable unpack/convert ([ADR 0027](docs/adr/0027-stable-prefab-ownership-and-variants.md))
- [x] Prefab v2 production acceptance: committed base/nested/variant fixtures pass workspace tests, recursive headless validation, packaged release startup, and live editor placement/inspection regression coverage ([Gitea #43](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/43))
- [x] Shared project validation: editor Diagnostics and `cargo validate-levels --json` use one owner-attributed dependency/finding report across project settings, registry/import artifacts, materials, shaders, scenes, prefabs, brushes, and colliders; valid/missing/cyclic/incompatible fixtures fail on blocking content errors ([ADR 0028](docs/adr/0028-authoritative-project-content-validation.md), [Gitea #45](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/45))
- [x] Validation-gated package foundation: versioned development/QA/release profiles, deterministic runtime exclusions, stable input snapshots, transactional staged publication, Cargo-reported artifacts, BLAKE3 metadata, authored default-scene startup, and a non-blocking editor Build panel with live logs/cancel/run/reveal ([ADR 0029](docs/adr/0029-validation-gated-build-profiles-and-packaging.md), [build guide](docs/editor/build-and-package.md), [Gitea #44](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/44))
- [x] Advanced rendering: `GiMode`, post-process volumes, Rendering panel, requested/effective render stack, Solari integration, emissive materials, post FX assets ([ADR 0013](docs/adr/0013-rendering-tiers-and-post-process-volumes.md), [ADR 0016](docs/adr/0016-unified-rendering-contract.md), [rendering guide](docs/editor/rendering.md))
- [x] Surface ABI v1 with shared raster/Solari evaluator dispatch, packed typed parameters/textures, exact cutout ray-candidate evaluation, last-good shader fallback, and explicit exclusion of skinned/morph-deformed Solari geometry ([ADR 0036](docs/adr/0036-surface-abi-and-solari-parity.md), [material-system guide](docs/editor/material-system.md))
- [x] Static mesh renderer component, generated normalized mesh artifacts, source/one-actor hierarchy placement, and inspector renderer slots ([ADR 0017](docs/adr/0017-normalized-static-mesh-assets.md))
- [x] Dedicated `SkinnedMeshRenderer`/`SkinnedMesh` actor path, skinned-part exclusion from static slots, dedicated runtime hierarchy hydration, and v2-to-v3 animated-scene migration ([ADR 0033](docs/adr/0033-dedicated-skinned-mesh-renderer.md))
- [x] Componentized actor inspector, unified component cards, thumbnail static mesh slots, imported asset Browse/Locate/Clear refs with inherited source defaults, collider split, shader-aware actor material data, and texture picker/drop refs ([ADR 0018](docs/adr/0018-componentized-actor-inspector-and-materials.md))
- [x] Stable authoring component IDs, registry-built save filtering, reflected atomic add/remove/reset/copy/paste history, independent active state, static extension registration, and derived composable `ActorKind` hints ([ADR 0034](docs/adr/0034-registry-driven-authoring-components.md), [extensibility guide](docs/editor/extensibility.md))
- [x] Brush authoring schema MVP with `ActorKind::Brush`, cube `BrushDesc`, generated mesh hydration, scene migration, and inspector Add Component support ([ADR 0021](docs/adr/0021-brush-authoring-schema.md))
- [x] Brush draw, vertex/edge/face gizmo editing, face material/UV authoring, clip, and bounds-based CSG preview/commit workflow ([brush guide](docs/editor/brushes.md))
- [x] Searchable command palette with human labels/stable IDs and a status bar that exposes scene I/O, tool, history, mode, and selection feedback
@@ -412,12 +483,17 @@ crates/
- The editor asset browser is filesystem-backed with folder/tree navigation, grid/list views,
texture and model thumbnails (glTF albedo fast-path; offscreen render studio for FBX and
untextured models), material sphere thumbnails, search/filter/sort controls, expandable model
subasset shelves, and a staged details pane. **File → Import Assets**
accepts glTF/GLB and **FBX** (binary; copies sibling `.fbm` texture folders when present).
Model assets generate normalized static mesh manifests under `assets/meshes/generated/`; drag/drop
uses `StaticMeshRenderer` by default with imported asset refs and optional separate static mesh
collider components. Expanded mesh subassets generate independent thumbnails and can be placed independently. Asset details can switch
placement to **Scene Instance** for `ModelRef`/`WorldAssetRoot` playback, shared material assets can be
subasset shelves, and a staged details pane. **File -> Import Assets**
accepts glTF/GLB and binary **FBX**. FBX import parses and transactionally preserves every safe
referenced sibling `textures/` or `.fbm/` file while rejecting traversal and external absolute
paths before project content changes. Missing source textures appear once in validation and Asset
Browser dependency status; **Authoring Override** deliberately permits an untextured model.
Model assets generate normalized model manifests under `assets/meshes/generated/`; drag/drop uses
**Renderable Asset (Auto)**. Unrigged sources use `StaticMeshRenderer` with imported asset refs
and optional separate static mesh colliders. Skin-bound or animated sources and their subasset placement use
`SkinnedMeshRenderer`, preserve the source joint hierarchy, and never create static slots or
automatic triangle colliders. Expanded mesh subassets generate independent thumbnails. Asset details can switch
placement to **Scene Instance** for generic `ModelRef`/`WorldAssetRoot` scenes, shared material assets can be
edited from the browser, and delete actions move files to `assets/.trash/`. Animation authoring
supports glTF/GLB rig and clip manifests, stable controller refs, clip drag assignment/placement,
inspector preview, PIE/runtime playback, and headless compatibility diagnostics. Animated or
@@ -432,7 +508,7 @@ crates/
**Unpack Layer** preserves nested links; **Convert to Local** recursively removes them. Current
authoring UI coverage and production-acceptance gaps are tracked in
[prefab-authoring.md](docs/editor/prefab-authoring.md).
- Material assets are RON files under `assets/materials/`; shader schemas live under `assets/shaders/`. `MaterialDesc` stores shader kind, typed parameters, texture bindings, and StandardMaterial fields. The Asset Browser material details editor can apply shader schemas, edit typed parameters/textures, and regenerate sphere thumbnails. Actor inspector material edits live on the actor `MaterialDesc`; static mesh source-material refs remain imported defaults and shared material assets are edited from the Asset Browser.
- Material and direct-base Material Instance assets live under `assets/materials/`; shader schemas live under `assets/shaders/`. **Window > Material Library** provides cross-folder creation, editing, usage filters, and drag sources. Viewport Material drops target one exact renderer slot, primitive, or brush face and use reversible preview plus one-step history; loose Textures target primitives/brush faces and are rejected on renderer slots. Shared edits propagate through live-updated handles without reloading skinned geometry. Custom Surface evaluators share one constrained ABI between raster and Solari-eligible non-deformed geometry. Runtime property-block application/promotion is tracked in [#53](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/53); dynamic skinned/morph Solari geometry is tracked in [#54](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/54). See the [material-system guide](docs/editor/material-system.md).
- Per-field reflect undo for all components remains future work; typed `shared` inspectors cover the common authoring path.
- The authoring/hydration layer is intentionally small so richer asset workflows (terrain,
material graphs, lighting profiles) can be added without changing the scene format foundation.
+675 -301
View File
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,236 @@
(
schema_version: 3,
asset_id: "113f74df-e39c-41d4-9b5b-e48efe541f7f",
label: "RobotExpressive",
default_animation_clip_id: Some("animation:clip:8:standing"),
source: (
path: "assets/models/RobotExpressive.glb",
format: "glb",
fingerprint: (
byte_len: 463988,
modified_unix_secs: 1783799272,
content_hash: "5869cb813e6a6093eda7af2824a9c13a582750e0443e88ce7c991a1f83415521",
),
dependencies: [],
),
runtime_supported: true,
skeletons: [
(
id: "animation:skeleton:0:skeleton_0",
label: "Skeleton 0",
source_index: 0,
signature: ("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b"),
joint_paths: [
"RootNode/RobotArmature/Bone",
"RootNode/RobotArmature/Bone/Foot.L",
"RootNode/RobotArmature/Bone/Body",
"RootNode/RobotArmature/Bone/Body/Hips",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L/Middle2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L/Thumb2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L/Index2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L/Ring2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R/Middle2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R/Thumb2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R/Index2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R/Ring2.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R",
"RootNode/RobotArmature/Bone/PoleTarget.L",
"RootNode/RobotArmature/Bone/Foot.R",
"RootNode/RobotArmature/Bone/PoleTarget.R",
],
),
(
id: "animation:skeleton:1:skeleton_1",
label: "Skeleton 1",
source_index: 1,
signature: ("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b"),
joint_paths: [
"RootNode/RobotArmature/Bone",
"RootNode/RobotArmature/Bone/Foot.L",
"RootNode/RobotArmature/Bone/Body",
"RootNode/RobotArmature/Bone/Body/Hips",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L/Middle2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L/Thumb2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L/Index2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L/Ring2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R/Middle2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R/Thumb2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R/Index2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R/Ring2.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R",
"RootNode/RobotArmature/Bone/PoleTarget.L",
"RootNode/RobotArmature/Bone/Foot.R",
"RootNode/RobotArmature/Bone/PoleTarget.R",
],
),
],
clips: [
(
id: "animation:clip:0:dance",
label: "Dance",
source_index: 0,
duration_seconds: 3.3333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:1:death",
label: "Death",
source_index: 1,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:2:idle",
label: "Idle",
source_index: 2,
duration_seconds: 3.3333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:3:jump",
label: "Jump",
source_index: 3,
duration_seconds: 0.7083333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:4:no",
label: "No",
source_index: 4,
duration_seconds: 1.6666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:5:punch",
label: "Punch",
source_index: 5,
duration_seconds: 0.8333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:6:running",
label: "Running",
source_index: 6,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:7:sitting",
label: "Sitting",
source_index: 7,
duration_seconds: 0.41666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:8:standing",
label: "Standing",
source_index: 8,
duration_seconds: 0.41666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:9:thumbsup",
label: "ThumbsUp",
source_index: 9,
duration_seconds: 1.5833334,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:10:walking",
label: "Walking",
source_index: 10,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:11:walkjump",
label: "WalkJump",
source_index: 11,
duration_seconds: 0.8333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:12:wave",
label: "Wave",
source_index: 12,
duration_seconds: 1.8333334,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:13:yes",
label: "Yes",
source_index: 13,
duration_seconds: 1.6666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
],
diagnostics: [],
)
@@ -0,0 +1,236 @@
(
schema_version: 3,
asset_id: "3f63f359-45eb-4cb2-8970-71921cbd7bd0",
label: "robot_expressive",
default_animation_clip_id: Some("animation:clip:8:standing"),
source: (
path: "assets/models/robot_expressive.glb",
format: "glb",
fingerprint: (
byte_len: 463988,
modified_unix_secs: 1783750957,
content_hash: "5869cb813e6a6093eda7af2824a9c13a582750e0443e88ce7c991a1f83415521",
),
dependencies: [],
),
runtime_supported: true,
skeletons: [
(
id: "animation:skeleton:0:skeleton_0",
label: "Skeleton 0",
source_index: 0,
signature: ("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b"),
joint_paths: [
"RootNode/RobotArmature/Bone",
"RootNode/RobotArmature/Bone/Foot.L",
"RootNode/RobotArmature/Bone/Body",
"RootNode/RobotArmature/Bone/Body/Hips",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L/Middle2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L/Thumb2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L/Index2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L/Ring2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R/Middle2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R/Thumb2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R/Index2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R/Ring2.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R",
"RootNode/RobotArmature/Bone/PoleTarget.L",
"RootNode/RobotArmature/Bone/Foot.R",
"RootNode/RobotArmature/Bone/PoleTarget.R",
],
),
(
id: "animation:skeleton:1:skeleton_1",
label: "Skeleton 1",
source_index: 1,
signature: ("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b"),
joint_paths: [
"RootNode/RobotArmature/Bone",
"RootNode/RobotArmature/Bone/Foot.L",
"RootNode/RobotArmature/Bone/Body",
"RootNode/RobotArmature/Bone/Body/Hips",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm2.L/Middle1.L/Middle2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Thumb.L/Thumb2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm1.L/Index.L/Index2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/LowerArm.L/Palm3.L/Ring1.L/Ring2.L",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm2.R/Middle1.R/Middle2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Thumb.R/Thumb2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm1.R/Index.R/Index2.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R",
"RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/LowerArm.R/Palm3.R/Ring1.R/Ring2.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R",
"RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R",
"RootNode/RobotArmature/Bone/PoleTarget.L",
"RootNode/RobotArmature/Bone/Foot.R",
"RootNode/RobotArmature/Bone/PoleTarget.R",
],
),
],
clips: [
(
id: "animation:clip:0:dance",
label: "Dance",
source_index: 0,
duration_seconds: 3.3333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:1:death",
label: "Death",
source_index: 1,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:2:idle",
label: "Idle",
source_index: 2,
duration_seconds: 3.3333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:3:jump",
label: "Jump",
source_index: 3,
duration_seconds: 0.7083333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:4:no",
label: "No",
source_index: 4,
duration_seconds: 1.6666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:5:punch",
label: "Punch",
source_index: 5,
duration_seconds: 0.8333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:6:running",
label: "Running",
source_index: 6,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:7:sitting",
label: "Sitting",
source_index: 7,
duration_seconds: 0.41666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:8:standing",
label: "Standing",
source_index: 8,
duration_seconds: 0.41666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:9:thumbsup",
label: "ThumbsUp",
source_index: 9,
duration_seconds: 1.5833334,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:10:walking",
label: "Walking",
source_index: 10,
duration_seconds: 0.9583333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:11:walkjump",
label: "WalkJump",
source_index: 11,
duration_seconds: 0.8333333,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:12:wave",
label: "Wave",
source_index: 12,
duration_seconds: 1.8333334,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
(
id: "animation:clip:13:yes",
label: "Yes",
source_index: 13,
duration_seconds: 1.6666666,
target_skeleton_signature: Some(("e9761f2a198d6a280afd0fc2aca6e8783dc6237bd85c90b8bc07a2e11271dc2b")),
events: [],
),
],
diagnostics: [],
)
@@ -0,0 +1,20 @@
(
schema_version: 3,
asset_id: "b98ef565-3500-49e7-9935-f685fa9b2594",
label: "painted_wooden_chair_02_2k",
default_animation_clip_id: None,
source: (
path: "assets/models/painted_wooden_chair_02_2k.fbx",
format: "fbx",
fingerprint: (
byte_len: 59964,
modified_unix_secs: 1780713434,
content_hash: "b12973a62dcb44589e380ea833eade726ae98a86c81084c842ee3801866d6a46",
),
dependencies: [],
),
runtime_supported: false,
skeletons: [],
clips: [],
diagnostics: [],
)
+21 -25
View File
@@ -1,18 +1,16 @@
(schema_version: 2,
resources: {},
entities: {
4294969001: (
components: {
"bevy_ecs::name::Name": "Audition Tone Source",
"bevy_transform::components::transform::Transform": (
(schema_version: 4,resources: {
},
entities: {
4294969001: (components: {
"bevy_ecs::name::Name": "Audition Tone Source",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 1.5, -4.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::LevelObject": (),
"shared::components::ActorId": ("audio-showcase-source"),
"shared::components::ActorKind": AudioSource,
"shared::components::AudioSourceDesc": (
"shared::components::ActorId": ("audio-showcase-source"),
"shared::components::ActorKind": AudioSource,
"shared::components::AudioSourceDesc": (
clip: Some((
asset_id: "c0a7d10e-53c1-4de0-b0dc-34a66f44ba77",
sub_asset_id: "audio:source",
@@ -32,25 +30,23 @@
),
bus: "sfx",
),
},
),
4294969002: (
components: {
"bevy_ecs::name::Name": "Showcase Listener",
"bevy_transform::components::transform::Transform": (
"shared::components::LevelObject": (),
}),
4294969002: (components: {
"bevy_ecs::name::Name": "Showcase Listener",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 1.7, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::LevelObject": (),
"shared::components::ActorId": ("audio-showcase-listener"),
"shared::components::ActorKind": AudioListener,
"shared::components::AudioListenerDesc": (
"shared::components::ActorId": ("audio-showcase-listener"),
"shared::components::ActorKind": AudioListener,
"shared::components::AudioListenerDesc": (
enabled: true,
priority: 100,
ear_gap: 0.2,
),
},
),
},
)
"shared::components::LevelObject": (),
}),
},
)
@@ -0,0 +1,175 @@
(schema_version: 4, resources: {}, entities: {
1: (components: {
"bevy_ecs::name::Name": "Valid Box Collider",
"bevy_transform::components::transform::Transform": (
translation: (-4.5, 1.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("collider-showcase-box"),
"shared::components::ActorKind": StaticMesh,
"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.18, g: 0.62, b: 0.36, a: 1.0),
metallic: 0.05, roughness: 0.55,
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: [],
),
"shared::components::Primitive": (shape: Box, size: (1.8, 2.0, 1.8)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true, is_trigger: false,
shape: Cuboid(x_length: 1.8, y_length: 2.0, z_length: 1.8),
),
}),
2: (components: {
"bevy_ecs::name::Name": "Valid Sphere Collider",
"bevy_transform::components::transform::Transform": (
translation: (-2.25, 1.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.35, 0.8),
),
"shared::components::ActorId": ("collider-showcase-sphere"),
"shared::components::ActorKind": StaticMesh,
"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.16, g: 0.52, b: 0.78, a: 1.0),
metallic: 0.08, roughness: 0.42,
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: [],
),
"shared::components::Primitive": (shape: Sphere, size: (2.0, 2.0, 2.0)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true, is_trigger: false, shape: Sphere(radius: 1.0),
),
}),
3: (components: {
"bevy_ecs::name::Name": "Valid Capsule Collider",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 1.4, 0.0),
rotation: (0.0, 0.1950903, 0.0, 0.9807853),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("collider-showcase-capsule"),
"shared::components::ActorKind": StaticMesh,
"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.58, g: 0.34, b: 0.78, a: 1.0),
metallic: 0.06, roughness: 0.48,
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: [],
),
"shared::components::Primitive": (shape: Box, size: (1.4, 2.8, 1.4)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true, is_trigger: false, shape: Capsule(radius: 0.7, height: 2.8),
),
}),
4: (components: {
"bevy_ecs::name::Name": "Trigger Collider",
"bevy_transform::components::transform::Transform": (
translation: (2.25, 1.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("collider-showcase-trigger"),
"shared::components::ActorKind": StaticMesh,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (3),
"shared::components::LevelObject": (),
"shared::components::MaterialDesc": (
shader: (kind: StandardLit, schema_path: None, shader_path: None),
base_color: (r: 0.12, g: 0.68, b: 0.82, a: 1.0),
metallic: 0.03, roughness: 0.4,
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: [],
),
"shared::components::Primitive": (shape: Sphere, size: (2.0, 2.0, 2.0)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true, is_trigger: true, shape: Sphere(radius: 1.0),
),
}),
5: (components: {
"bevy_ecs::name::Name": "Disabled Collider",
"bevy_transform::components::transform::Transform": (
translation: (4.5, 1.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("collider-showcase-disabled"),
"shared::components::ActorKind": StaticMesh,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (4),
"shared::components::LevelObject": (),
"shared::components::MaterialDesc": (
shader: (kind: StandardLit, schema_path: None, shader_path: None),
base_color: (r: 0.38, g: 0.40, b: 0.46, a: 1.0),
metallic: 0.02, roughness: 0.68,
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: [],
),
"shared::components::Primitive": (shape: Box, size: (1.8, 2.0, 1.8)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: false, is_trigger: false,
shape: Cuboid(x_length: 1.8, y_length: 2.0, z_length: 1.8),
),
}),
6: (components: {
"bevy_ecs::name::Name": "Missing Collider",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 1.0, -3.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("collider-showcase-missing"),
"shared::components::ActorKind": StaticMesh,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (5),
"shared::components::LevelObject": (),
"shared::components::MaterialDesc": (
shader: (kind: StandardLit, schema_path: None, shader_path: None),
base_color: (r: 0.78, g: 0.16, b: 0.20, a: 1.0),
metallic: 0.02, roughness: 0.58,
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: [],
),
"shared::components::Primitive": (shape: Box, size: (1.8, 2.0, 1.8)),
"shared::components::RigidBodyDesc": (body: Static),
}),
7: (components: {
"bevy_ecs::name::Name": "Collider Showcase 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": ("collider-showcase-sun"),
"shared::components::ActorKind": Light,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (6),
"shared::components::LevelObject": (),
"shared::components::LightDesc": (
kind: Directional, color: (r: 1.0, g: 0.95, b: 0.88, a: 1.0),
intensity: 100000.0, range: 0.0, shadows: true,
inner_angle_deg: 25.0, outer_angle_deg: 35.0,
),
}),
})
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,73 @@
(schema_version: 4,resources: {
},
entities: {
1: (components: {
"bevy_ecs::name::Name": "Navigation Bounds",
"bevy_transform::components::transform::Transform": (translation: (0.0, 0.0, 0.0), rotation: (0.0, 0.0, 0.0, 1.0), scale: (1.0, 1.0, 1.0)),
"shared::components::ActorId": ("navigation-bounds-main"),
"shared::components::ActorKind": Navigation,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (0),
"shared::components::LevelObject": (),
"shared::navigation::NavigationBounds": (
half_extents: (8.0, 2.0, 8.0),
agent: (
id: "humanoid",
radius: 0.35,
height: 1.8,
max_climb: 0.45,
max_slope_deg: 45.0,
cell_size_fraction: 3.0,
cell_height_fraction: 6.0,
min_region_size: 1,
merge_region_size: 2,
),
artifact_path: "assets/navigation/generated/navigation_showcase_humanoid.nav.ron",
auto_bake: false,
validation_samples: [
(id: "around-center-obstacle", start: (-6.0, 0.0, -5.0), end: (6.0, 0.0, -5.0), enabled: true),
],
),
}),
2: (components: {
"bevy_ecs::name::Name": "Center Obstacle",
"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": ("navigation-obstacle-center"),
"shared::components::ActorKind": Navigation,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (1),
"shared::components::LevelObject": (),
"shared::navigation::NavigationObstacle": (half_extents: (1.0, 1.0, 2.5), dynamic: false),
}),
3: (components: {
"bevy_ecs::name::Name": "Slow Area",
"bevy_transform::components::transform::Transform": (translation: (-4.0, 0.5, -4.0), rotation: (0.0, 0.0, 0.0, 1.0), scale: (1.0, 1.0, 1.0)),
"shared::components::ActorId": ("navigation-area-slow"),
"shared::components::ActorKind": Navigation,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (2),
"shared::components::LevelObject": (),
"shared::navigation::NavigationArea": (id: "slow", half_extents: (1.5, 1.0, 1.5), cost: 1.5, walkable: true),
}),
4: (components: {
"bevy_ecs::name::Name": "Obstacle Link",
"bevy_transform::components::transform::Transform": (translation: (0.0, 0.0, 0.0), rotation: (0.0, 0.0, 0.0, 1.0), scale: (1.0, 1.0, 1.0)),
"shared::components::ActorId": ("navigation-link-center"),
"shared::components::ActorKind": Navigation,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (3),
"shared::components::LevelObject": (),
"shared::navigation::NavigationLink": (start: (-1.5, 0.0, 0.0), end: (1.5, 0.0, 0.0), bidirectional: true, cost: 1.2, enabled: true),
}),
5: (components: {
"bevy_ecs::name::Name": "Walkable Floor Geometry",
"bevy_transform::components::transform::Transform": (translation: (0.0, -0.25, 0.0), rotation: (0.0, 0.0, 0.0, 1.0), scale: (1.0, 1.0, 1.0)),
"shared::components::ActorId": ("navigation-floor-geometry"),
"shared::components::ActorKind": StaticMesh,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (4),
"shared::components::LevelObject": (),
"shared::components::Primitive": (shape: Box, size: (16.0, 0.5, 16.0)),
}),
},
)
@@ -0,0 +1,164 @@
(schema_version: 4, resources: {}, entities: {
1: (components: {
"bevy_ecs::name::Name": "Placement Floor",
"bevy_transform::components::transform::Transform": (
translation: (0.0, -0.25, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("physics-placement-floor"),
"shared::components::ActorKind": StaticMesh,
"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.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: [],
),
"shared::components::Primitive": (shape: Box, size: (14.0, 0.5, 10.0)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true,
is_trigger: false,
shape: Cuboid(x_length: 14.0, y_length: 0.5, z_length: 10.0),
),
}),
2: (components: {
"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),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("physics-placement-prop-a"),
"shared::components::ActorKind": StaticMesh,
"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.88, g: 0.48, b: 0.12, a: 1.0),
metallic: 0.1,
roughness: 0.42,
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: [],
),
"shared::components::Primitive": (shape: Box, size: (1.2, 1.2, 1.2)),
"shared::components::RigidBodyDesc": (body: Static),
"shared::components::ColliderDesc": (
enabled: true,
is_trigger: false,
shape: Cuboid(x_length: 1.2, y_length: 1.2, z_length: 1.2),
),
}),
3: (components: {
"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),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("physics-placement-prop-b"),
"shared::components::ActorKind": StaticMesh,
"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.10, g: 0.58, b: 0.72, a: 1.0),
metallic: 0.15,
roughness: 0.35,
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: [],
),
"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: Sphere(radius: 0.8),
),
}),
4: (components: {
"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),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("physics-placement-prop-c"),
"shared::components::ActorKind": StaticMesh,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (3),
"shared::components::LevelObject": (),
"shared::components::MaterialDesc": (
shader: (kind: StandardLit, schema_path: None, shader_path: None),
base_color: (r: 0.62, g: 0.24, b: 0.56, a: 1.0),
metallic: 0.08,
roughness: 0.5,
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: [],
),
"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: Capsule(radius: 0.45, height: 1.8),
),
}),
5: (components: {
"bevy_ecs::name::Name": "Placement Sun",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 8.0, 2.0),
rotation: (-0.3826834, 0.0, 0.0, 0.9238795),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("physics-placement-sun"),
"shared::components::ActorKind": Light,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (4),
"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,
),
}),
})
+223 -56
View File
@@ -1,74 +1,241 @@
(schema_version: 2,
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),
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::LevelObject": (),
"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),
priority: 0,
blend_distance: 2.0,
overrides: (
fog_density: Some(0.004),
fog_color: Some((r: 0.5, g: 0.55, b: 0.65, a: 1.0)),
),
fullscreen_effect: None,
profile: None,
label: Some("Foggy courtyard"),
half_extents: (6.0, 3.0, 6.0),
priority: 0,
blend_distance: 2.0,
overrides: (
fog_density: Some(0.004),
fog_color: Some((r: 0.5, g: 0.55, b: 0.65, a: 1.0)),
),
fullscreen_effect: None,
profile: None,
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),
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::LevelObject": (),
"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),
priority: 5,
blend_distance: 1.5,
overrides: (
exposure_ev100: Some(9.5),
bloom: Some(false),
),
fullscreen_effect: None,
profile: Some("assets/rendering_profiles/cave_dark.ron"),
label: Some("Cave mouth"),
half_extents: (4.0, 2.5, 4.0),
priority: 5,
blend_distance: 1.5,
overrides: (
exposure_ev100: Some(9.5),
bloom: Some(false),
),
fullscreen_effect: None,
profile: Some("assets/rendering_profiles/cave_dark.ron"),
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),
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::LevelObject": (),
"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),
priority: 2,
blend_distance: 2.0,
overrides: (),
fullscreen_effect: Some("assets/post_fx/vignette.ron"),
profile: None,
label: Some("Vignette demo"),
half_extents: (5.0, 2.0, 5.0),
priority: 2,
blend_distance: 2.0,
overrides: (),
fullscreen_effect: Some("assets/post_fx/vignette.ron"),
profile: None,
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,
),
}),
})
+189
View File
@@ -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,87 @@
(schema_version: 4, resources: {}, entities: {
1: (components: {
"bevy_ecs::name::Name": "Terrain Showcase",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 0.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("terrain-showcase-main"),
"shared::components::ActorKind": Terrain,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (0),
"shared::components::LevelObject": (),
"shared::components::TerrainDesc": (
schema_version: 1,
resolution: 5,
heights: [
0.00, 0.00, 0.05, 0.00, 0.00,
0.00, 0.15, 0.30, 0.10, 0.00,
0.05, 0.35, 0.80, 0.25, 0.05,
0.00, 0.20, 0.40, 0.15, 0.00,
0.00, 0.00, 0.05, 0.00, 0.00,
],
sample_spacing: 2.0,
height_scale: 3.0,
chunk_quads: 2,
base_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"),
)),
material_layers: [
(
material: Some((
asset_id: "a57f2891-8536-47b8-b476-01c08b36ac43",
sub_asset_id: "material:source",
label: "Concrete",
source_path: Some("assets/materials/concrete.ron"),
)),
uv_scale: 6.0,
),
(
material: Some((
asset_id: "d6cb4151-7124-4237-aaf9-f7f8abd5fb76",
sub_asset_id: "material:source",
label: "Surface Tint",
source_path: Some("assets/materials/surface_tint.ron"),
)),
uv_scale: 10.0,
),
],
material_weights: [
(255, 0, 0, 0), (255, 0, 0, 0), (224, 31, 0, 0), (255, 0, 0, 0), (255, 0, 0, 0),
(255, 0, 0, 0), (192, 63, 0, 0), (128, 127, 0, 0), (192, 63, 0, 0), (255, 0, 0, 0),
(224, 31, 0, 0), (128, 127, 0, 0), (0, 255, 0, 0), (128, 127, 0, 0), (224, 31, 0, 0),
(255, 0, 0, 0), (192, 63, 0, 0), (128, 127, 0, 0), (192, 63, 0, 0), (255, 0, 0, 0),
(255, 0, 0, 0), (255, 0, 0, 0), (224, 31, 0, 0), (255, 0, 0, 0), (255, 0, 0, 0),
],
generate_colliders: true,
cast_shadows: true,
receive_shadows: true,
),
}),
2: (components: {
"bevy_ecs::name::Name": "Terrain Sun",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 8.0, 0.0),
rotation: (-0.3826834, 0.0, 0.0, 0.9238795),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("terrain-showcase-sun"),
"shared::components::ActorKind": Light,
"shared::components::EditorVisibility": (visible: true),
"shared::components::HierarchySiblingIndex": (1),
"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,
),
}),
})
+30 -2
View File
@@ -1,12 +1,40 @@
(
schema_version: 1,
label: "Concrete",
shader: None,
shader_ref: None,
render_state: (
alpha_mode: Opaque,
alpha_cutoff: 0.5,
double_sided: false,
),
material: (
base_color: (r: 0.55, g: 0.54, b: 0.52, a: 1.0),
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: None,
parameters: [],
textures: [],
),
)
)
+28 -3
View File
@@ -1,15 +1,40 @@
(
schema_version: 1,
label: "Emissive Panel",
shader: None,
shader_ref: None,
render_state: (
alpha_mode: Opaque,
alpha_cutoff: 0.5,
double_sided: false,
),
material: (
base_color: (r: 0.15, g: 0.22, b: 0.28, a: 1.0),
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_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: None,
parameters: [],
textures: [],
),
)
)
+71
View File
@@ -0,0 +1,71 @@
(
schema_version: 1,
label: "Surface Tint",
shader: Some("assets/shaders/surface_tint.shader.ron"),
shader_ref: None,
render_state: (
alpha_mode: Opaque,
alpha_cutoff: 0.5,
double_sided: false,
),
material: (
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: None,
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: [],
),
)
@@ -0,0 +1,12 @@
(
schema_version: 1,
label: "surface_tint Instance",
base: ((
asset_id: "d6cb4151-7124-4237-aaf9-f7f8abd5fb76",
sub_asset_id: "material:source",
label: "surface_tint",
source_path: Some("assets/materials/surface_tint.ron"),
)),
parameters: [],
textures: [],
)
@@ -0,0 +1,360 @@
(
schema_version: 4,
asset_id: "113f74df-e39c-41d4-9b5b-e48efe541f7f",
label: "RobotExpressive",
source: (
path: "assets/models/RobotExpressive.glb",
format: "glb",
fingerprint: (
byte_len: 463988,
content_hash: "5869cb813e6a6093eda7af2824a9c13a582750e0443e88ce7c991a1f83415521",
),
dependencies: [],
),
import: (
scale: 1.0,
generate_collider: true,
lod0_only: true,
placement_mode: SceneInstance,
hierarchy_mode: SourceHierarchy,
material_policy: SourceMaterials,
),
metadata: (
mesh_count: 14,
material_count: 3,
node_count: 74,
animation_count: 14,
skin_count: 2,
light_count: 0,
camera_count: 0,
),
parts: [
(
id: "draw:scene0:node4:mesh0:primitive0",
name: "Foot.L / Primitive 0",
mesh_label: "Mesh0/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (0.62405795, 0.39766362, 0.19111444),
rotation: (0.7071068, 0.00000005228401, 0.000000015504241, -0.70710665),
scale: (100.0, 99.999985, 100.0),
),
source_node: Some("RootNode/RobotArmature/Bone/Foot.L/Foot.L"),
source_mesh: Some("Mesh0"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node7:mesh1:primitive0",
name: "Torso / Primitive 0",
mesh_label: "Mesh1/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.0027156367, 2.1737509, -0.019581214),
rotation: (0.70710677, 0.000000000000031351603, 0.000000000000055267226, -0.7071067),
scale: (100.0, 99.99998, 99.99998),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Torso"),
source_mesh: Some("Mesh1"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node7:mesh1:primitive1",
name: "Torso / Primitive 1",
mesh_label: "Mesh1/Primitive1",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.0027156367, 2.1737509, -0.019581214),
rotation: (0.70710677, 0.000000000000031351603, 0.000000000000055267226, -0.7071067),
scale: (100.0, 99.99998, 99.99998),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Torso"),
source_mesh: Some("Mesh1"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node61:mesh10:primitive0",
name: "Leg.R / Primitive 0",
mesh_label: "Mesh10/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.6746981, 1.1586236, 0.046261936),
rotation: (0.7693698, 0.080835514, 0.110868365, -0.6238942),
scale: (99.99999, 99.99886, 100.00024),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.R/Leg.R"),
source_mesh: Some("Mesh10"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node63:mesh11:primitive0",
name: "LowerLeg.R / Primitive 0",
mesh_label: "Mesh11/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.73626167, 0.34982973, 0.22594015),
rotation: (-0.65091395, -0.099058665, -0.09436109, 0.7467224),
scale: (99.99999, 99.998604, 100.00058),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R/LowerLeg.R"),
source_mesh: Some("Mesh11"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node72:mesh12:primitive0",
name: "Hand.R / Primitive 0",
mesh_label: "Mesh12/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.R"),
source_mesh: Some("Mesh12"),
source_material: Some("Main"),
skinned: true,
),
(
id: "draw:scene0:node72:mesh12:primitive1",
name: "Hand.R / Primitive 1",
mesh_label: "Mesh12/Primitive1",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.R"),
source_mesh: Some("Mesh12"),
source_material: Some("Grey"),
skinned: true,
),
(
id: "draw:scene0:node73:mesh13:primitive0",
name: "Hand.L / Primitive 0",
mesh_label: "Mesh13/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.L"),
source_mesh: Some("Mesh13"),
source_material: Some("Main"),
skinned: true,
),
(
id: "draw:scene0:node73:mesh13:primitive1",
name: "Hand.L / Primitive 1",
mesh_label: "Mesh13/Primitive1",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.L"),
source_mesh: Some("Mesh13"),
source_material: Some("Grey"),
skinned: true,
),
(
id: "draw:scene0:node13:mesh2:primitive0",
name: "Head / Primitive 0",
mesh_label: "Mesh2/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node13:mesh2:primitive1",
name: "Head / Primitive 1",
mesh_label: "Mesh2/Primitive1",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node13:mesh2:primitive2",
name: "Head / Primitive 2",
mesh_label: "Mesh2/Primitive2",
material_id: Some("material:material2"),
material_slot_name: "Black",
material_label: Some("Material2"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Black"),
skinned: false,
),
(
id: "draw:scene0:node68:mesh3:primitive0",
name: "Foot.R / Primitive 0",
mesh_label: "Mesh3/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.637997, 0.3976636, 0.19111452),
rotation: (0.70710677, 0.00000005201811, 0.000000015770217, -0.7071067),
scale: (100.0, 99.999985, 100.0),
),
source_node: Some("RootNode/RobotArmature/Bone/Foot.R/Foot.R"),
source_mesh: Some("Mesh3"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node16:mesh4:primitive0",
name: "Shoulder.L / Primitive 0",
mesh_label: "Mesh4/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.58268076, 2.3724597, -0.020994142),
rotation: (-0.59886926, 0.37597278, -0.37597266, 0.59886944),
scale: (99.99996, 99.999954, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/Shoulder.L"),
source_mesh: Some("Mesh4"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node18:mesh5:primitive0",
name: "Arm.L / Primitive 0",
mesh_label: "Mesh5/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.26500192, 2.8489676, 0.13069445),
rotation: (-0.5164575, 0.4218856, -0.32294926, 0.67155623),
scale: (99.99994, 99.99994, 99.99999),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/Arm.L"),
source_mesh: Some("Mesh5"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node36:mesh6:primitive0",
name: "Shoulder.R / Primitive 0",
mesh_label: "Mesh6/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.6369861, 2.3718858, -0.020994166),
rotation: (0.6017577, 0.37133226, -0.37133226, -0.6017577),
scale: (99.999954, 99.99997, 99.99994),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/Shoulder.R"),
source_mesh: Some("Mesh6"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node38:mesh7:primitive0",
name: "Arm.R / Primitive 0",
mesh_label: "Mesh7/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.82568955, 1.9825263, 0.040243305),
rotation: (0.6276481, 0.35463694, -0.3873087, -0.5747021),
scale: (22.70405, 22.704054, 22.704046),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/Arm.R"),
source_mesh: Some("Mesh7"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node56:mesh8:primitive0",
name: "Leg.L / Primitive 0",
mesh_label: "Mesh8/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.6488191, 1.1620699, 0.057466835),
rotation: (0.76387787, -0.05410902, -0.070370995, -0.6392268),
scale: (99.99999, 100.00079, 100.00024),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.L/Leg.L"),
source_mesh: Some("Mesh8"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node58:mesh9:primitive0",
name: "LowerLeg.L / Primitive 0",
mesh_label: "Mesh9/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.68805873, 0.3497491, 0.23465614),
rotation: (-0.6547612, 0.06408298, 0.061960325, 0.7505613),
scale: (100.000015, 100.0006, 100.000496),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L/LowerLeg.L"),
source_mesh: Some("Mesh9"),
source_material: Some("Main"),
skinned: false,
),
],
warnings: [
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer.",
"Skinned primitives are excluded from StaticMeshRenderer and use SkinnedMeshRenderer.",
],
)
@@ -0,0 +1,360 @@
(
schema_version: 4,
asset_id: "3f63f359-45eb-4cb2-8970-71921cbd7bd0",
label: "robot_expressive",
source: (
path: "assets/models/robot_expressive.glb",
format: "glb",
fingerprint: (
byte_len: 463988,
content_hash: "5869cb813e6a6093eda7af2824a9c13a582750e0443e88ce7c991a1f83415521",
),
dependencies: [],
),
import: (
scale: 1.0,
generate_collider: true,
lod0_only: true,
placement_mode: StaticAsset,
hierarchy_mode: SingleActor,
material_policy: SourceMaterials,
),
metadata: (
mesh_count: 14,
material_count: 3,
node_count: 74,
animation_count: 14,
skin_count: 2,
light_count: 0,
camera_count: 0,
),
parts: [
(
id: "draw:scene0:node4:mesh0:primitive0",
name: "Foot.L / Primitive 0",
mesh_label: "Mesh0/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (0.62405795, 0.39766362, 0.19111444),
rotation: (0.7071068, 0.00000005228401, 0.000000015504241, -0.70710665),
scale: (100.0, 99.999985, 100.0),
),
source_node: Some("RootNode/RobotArmature/Bone/Foot.L/Foot.L"),
source_mesh: Some("Mesh0"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node7:mesh1:primitive0",
name: "Torso / Primitive 0",
mesh_label: "Mesh1/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.0027156367, 2.1737509, -0.019581214),
rotation: (0.70710677, 0.000000000000031351603, 0.000000000000055267226, -0.7071067),
scale: (100.0, 99.99998, 99.99998),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Torso"),
source_mesh: Some("Mesh1"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node7:mesh1:primitive1",
name: "Torso / Primitive 1",
mesh_label: "Mesh1/Primitive1",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.0027156367, 2.1737509, -0.019581214),
rotation: (0.70710677, 0.000000000000031351603, 0.000000000000055267226, -0.7071067),
scale: (100.0, 99.99998, 99.99998),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Torso"),
source_mesh: Some("Mesh1"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node61:mesh10:primitive0",
name: "Leg.R / Primitive 0",
mesh_label: "Mesh10/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.6746981, 1.1586236, 0.046261936),
rotation: (0.7693698, 0.080835514, 0.110868365, -0.6238942),
scale: (99.99999, 99.99886, 100.00024),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.R/Leg.R"),
source_mesh: Some("Mesh10"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node63:mesh11:primitive0",
name: "LowerLeg.R / Primitive 0",
mesh_label: "Mesh11/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.73626167, 0.34982973, 0.22594015),
rotation: (-0.65091395, -0.099058665, -0.09436109, 0.7467224),
scale: (99.99999, 99.998604, 100.00058),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.R/LowerLeg.R/LowerLeg.R"),
source_mesh: Some("Mesh11"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node72:mesh12:primitive0",
name: "Hand.R / Primitive 0",
mesh_label: "Mesh12/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.R"),
source_mesh: Some("Mesh12"),
source_material: Some("Main"),
skinned: true,
),
(
id: "draw:scene0:node72:mesh12:primitive1",
name: "Hand.R / Primitive 1",
mesh_label: "Mesh12/Primitive1",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.R"),
source_mesh: Some("Mesh12"),
source_material: Some("Grey"),
skinned: true,
),
(
id: "draw:scene0:node73:mesh13:primitive0",
name: "Hand.L / Primitive 0",
mesh_label: "Mesh13/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.L"),
source_mesh: Some("Mesh13"),
source_material: Some("Main"),
skinned: true,
),
(
id: "draw:scene0:node73:mesh13:primitive1",
name: "Hand.L / Primitive 1",
mesh_label: "Mesh13/Primitive1",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.002715637, 2.3702974, -0.020994147),
rotation: (0.70710677, 0.0, 0.0, -0.7071067),
scale: (100.0, 99.99999, 99.99999),
),
source_node: Some("RootNode/Hand.L"),
source_mesh: Some("Mesh13"),
source_material: Some("Grey"),
skinned: true,
),
(
id: "draw:scene0:node13:mesh2:primitive0",
name: "Head / Primitive 0",
mesh_label: "Mesh2/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node13:mesh2:primitive1",
name: "Head / Primitive 1",
mesh_label: "Mesh2/Primitive1",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node13:mesh2:primitive2",
name: "Head / Primitive 2",
mesh_label: "Mesh2/Primitive2",
material_id: Some("material:material2"),
material_slot_name: "Black",
material_label: Some("Material2"),
local_transform: (
translation: (-0.05334633, 3.6175368, -0.0068152454),
rotation: (0.7249889, 0.0852804, 0.05460569, -0.6812757),
scale: (99.99997, 99.99996, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Neck/Head/Head"),
source_mesh: Some("Mesh2"),
source_material: Some("Black"),
skinned: false,
),
(
id: "draw:scene0:node68:mesh3:primitive0",
name: "Foot.R / Primitive 0",
mesh_label: "Mesh3/Primitive0",
material_id: Some("material:material0"),
material_slot_name: "Grey",
material_label: Some("Material0"),
local_transform: (
translation: (-0.637997, 0.3976636, 0.19111452),
rotation: (0.70710677, 0.00000005201811, 0.000000015770217, -0.7071067),
scale: (100.0, 99.999985, 100.0),
),
source_node: Some("RootNode/RobotArmature/Bone/Foot.R/Foot.R"),
source_mesh: Some("Mesh3"),
source_material: Some("Grey"),
skinned: false,
),
(
id: "draw:scene0:node16:mesh4:primitive0",
name: "Shoulder.L / Primitive 0",
mesh_label: "Mesh4/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.58268076, 2.3724597, -0.020994142),
rotation: (-0.59886926, 0.37597278, -0.37597266, 0.59886944),
scale: (99.99996, 99.999954, 99.99997),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/Shoulder.L"),
source_mesh: Some("Mesh4"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node18:mesh5:primitive0",
name: "Arm.L / Primitive 0",
mesh_label: "Mesh5/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.26500192, 2.8489676, 0.13069445),
rotation: (-0.5164575, 0.4218856, -0.32294926, 0.67155623),
scale: (99.99994, 99.99994, 99.99999),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.L/UpperArm.L/Arm.L"),
source_mesh: Some("Mesh5"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node36:mesh6:primitive0",
name: "Shoulder.R / Primitive 0",
mesh_label: "Mesh6/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.6369861, 2.3718858, -0.020994166),
rotation: (0.6017577, 0.37133226, -0.37133226, -0.6017577),
scale: (99.999954, 99.99997, 99.99994),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/Shoulder.R"),
source_mesh: Some("Mesh6"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node38:mesh7:primitive0",
name: "Arm.R / Primitive 0",
mesh_label: "Mesh7/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (-0.82568955, 1.9825263, 0.040243305),
rotation: (0.6276481, 0.35463694, -0.3873087, -0.5747021),
scale: (22.70405, 22.704054, 22.704046),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/Hips/Abdomen/Torso/Shoulder.R/UpperArm.R/Arm.R"),
source_mesh: Some("Mesh7"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node56:mesh8:primitive0",
name: "Leg.L / Primitive 0",
mesh_label: "Mesh8/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.6488191, 1.1620699, 0.057466835),
rotation: (0.76387787, -0.05410902, -0.070370995, -0.6392268),
scale: (99.99999, 100.00079, 100.00024),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.L/Leg.L"),
source_mesh: Some("Mesh8"),
source_material: Some("Main"),
skinned: false,
),
(
id: "draw:scene0:node58:mesh9:primitive0",
name: "LowerLeg.L / Primitive 0",
mesh_label: "Mesh9/Primitive0",
material_id: Some("material:material1"),
material_slot_name: "Main",
material_label: Some("Material1"),
local_transform: (
translation: (0.68805873, 0.3497491, 0.23465614),
rotation: (-0.6547612, 0.06408298, 0.061960325, 0.7505613),
scale: (100.000015, 100.0006, 100.000496),
),
source_node: Some("RootNode/RobotArmature/Bone/Body/UpperLeg.L/LowerLeg.L/LowerLeg.L"),
source_mesh: Some("Mesh9"),
source_material: Some("Main"),
skinned: false,
),
],
warnings: [
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer.",
"Skinned primitives are excluded from StaticMeshRenderer and use SkinnedMeshRenderer.",
],
)
@@ -1,5 +1,5 @@
(
schema_version: 1,
schema_version: 4,
asset_id: "b98ef565-3500-49e7-9935-f685fa9b2594",
label: "painted_wooden_chair_02_2k",
source: (
@@ -7,9 +7,13 @@
format: "fbx",
fingerprint: (
byte_len: 59964,
modified_unix_secs: 1780713434,
content_hash: "b12973a62dcb44589e380ea833eade726ae98a86c81084c842ee3801866d6a46",
),
dependencies: [],
dependencies: [
"assets/models/textures/painted_wooden_chair_02_diff_2k.jpg",
"assets/models/textures/painted_wooden_chair_02_nor_gl_2k.exr",
"assets/models/textures/painted_wooden_chair_02_rough_2k.exr",
],
),
import: (
scale: 1.0,
@@ -17,7 +21,7 @@
lod0_only: true,
placement_mode: StaticAsset,
hierarchy_mode: SingleActor,
material_policy: SourceMaterials,
material_policy: AuthoringOverride,
),
metadata: (
mesh_count: 1,
@@ -30,7 +34,7 @@
),
parts: [
(
id: "mesh:mesh1000",
id: "draw:scene0:node1:material0",
name: "painted_wooden_chair_02 / Material 0",
mesh_label: "Mesh1000",
material_id: Some("material:material0"),
@@ -44,7 +48,8 @@
source_node: Some("Node1"),
source_mesh: Some("Mesh1"),
source_material: Some("painted_wooden_chair_02"),
skinned: false,
),
],
warnings: [],
)
)
Binary file not shown.
@@ -0,0 +1,977 @@
(
schema_version: 2,
generator: "blacksite-nav-2/rerecast-0.3.2/polyanya-0.16.1/glam-0.30.10",
source_scene: "assets/levels/navigation_authoring_showcase.scn.ron",
source_fingerprint: "15649e3f7c8f22d642ea318ba1dafb5a3ada82e2713219cb60bbb518c5e45195",
payload_hash: "180b5a4698102e8185ae182bc30cf847466c4e9d65fe7834c315f6d1a03504c2",
bounds_actor_id: "navigation-bounds-main",
center: (0.0, 0.0, 0.0),
half_extents: (8.0, 2.0, 8.0),
agent: (
id: "humanoid",
radius: 0.35,
height: 1.8,
max_climb: 0.45,
max_slope_deg: 45.0,
cell_size_fraction: 3.0,
cell_height_fraction: 6.0,
min_region_size: 1,
merge_region_size: 2,
),
mesh: (
layers: [
(
vertices: [
(
coords: (-1.0, -2.516667),
polygons: [
0,
4294967295,
1,
3,
2,
],
is_corner: true,
),
(
coords: (-0.3000002, -2.516667),
polygons: [
4,
4294967295,
0,
],
is_corner: true,
),
(
coords: (-0.41666698, -7.3),
polygons: [
5,
4,
0,
2,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, -1.5833335),
polygons: [
3,
1,
10,
12,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, -1.5833335),
polygons: [
10,
1,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, -2.516667),
polygons: [
0,
4294967295,
1,
3,
2,
],
is_corner: true,
),
(
coords: (-1.0, -2.516667),
polygons: [
0,
4294967295,
1,
3,
2,
],
is_corner: true,
),
(
coords: (-0.41666698, -7.3),
polygons: [
5,
4,
0,
2,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, -7.3),
polygons: [
2,
3,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, -1.5833335),
polygons: [
3,
1,
10,
12,
4294967295,
],
is_corner: true,
),
(
coords: (-0.3000002, -2.516667),
polygons: [
4,
4294967295,
0,
],
is_corner: true,
),
(
coords: (0.2833333, -2.516667),
polygons: [
6,
4294967295,
4,
5,
],
is_corner: true,
),
(
coords: (0.39999962, -7.3),
polygons: [
8,
6,
5,
4294967295,
],
is_corner: true,
),
(
coords: (-0.41666698, -7.3),
polygons: [
5,
4,
0,
2,
4294967295,
],
is_corner: true,
),
(
coords: (0.39999962, -7.3),
polygons: [
8,
6,
5,
4294967295,
],
is_corner: true,
),
(
coords: (0.2833333, -2.516667),
polygons: [
6,
4294967295,
4,
5,
],
is_corner: true,
),
(
coords: (0.9833336, -2.516667),
polygons: [
8,
9,
7,
4294967295,
6,
],
is_corner: true,
),
(
coords: (0.9833336, -2.516667),
polygons: [
8,
9,
7,
4294967295,
6,
],
is_corner: true,
),
(
coords: (0.9833336, -1.5833335),
polygons: [
7,
13,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, -1.5833335),
polygons: [
15,
13,
7,
9,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, -2.516667),
polygons: [
8,
9,
7,
4294967295,
6,
],
is_corner: true,
),
(
coords: (7.283333, -1.5833335),
polygons: [
15,
13,
7,
9,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, -7.3),
polygons: [
9,
8,
4294967295,
],
is_corner: true,
),
(
coords: (0.39999962, -7.3),
polygons: [
8,
6,
5,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, -0.0666666),
polygons: [
11,
12,
10,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, -1.5833335),
polygons: [
10,
1,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, -1.5833335),
polygons: [
3,
1,
10,
12,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, 1.5666666),
polygons: [
12,
11,
17,
19,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, 1.5666666),
polygons: [
17,
11,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, -0.0666666),
polygons: [
11,
12,
10,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, -1.5833335),
polygons: [
3,
1,
10,
12,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, -1.5833335),
polygons: [
15,
13,
7,
9,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, -1.5833335),
polygons: [
7,
13,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, -0.0666666),
polygons: [
13,
15,
14,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, 1.5666666),
polygons: [
23,
21,
14,
15,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, -1.5833335),
polygons: [
15,
13,
7,
9,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, -0.0666666),
polygons: [
13,
15,
14,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, 1.5666666),
polygons: [
14,
21,
4294967295,
],
is_corner: true,
),
(
coords: (-0.41666698, 7.283333),
polygons: [
24,
25,
4294967295,
18,
16,
],
is_corner: true,
),
(
coords: (-0.3000002, 2.5),
polygons: [
24,
16,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, 2.5),
polygons: [
16,
18,
19,
17,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, 2.5),
polygons: [
16,
18,
19,
17,
4294967295,
],
is_corner: true,
),
(
coords: (-1.0, 1.5666666),
polygons: [
17,
11,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, 1.5666666),
polygons: [
12,
11,
17,
19,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, 7.283333),
polygons: [
19,
18,
4294967295,
],
is_corner: true,
),
(
coords: (-0.41666698, 7.283333),
polygons: [
24,
25,
4294967295,
18,
16,
],
is_corner: true,
),
(
coords: (-1.0, 2.5),
polygons: [
16,
18,
19,
17,
4294967295,
],
is_corner: true,
),
(
coords: (-7.3, 1.5666666),
polygons: [
12,
11,
17,
19,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, 2.5),
polygons: [
21,
23,
22,
20,
4294967295,
],
is_corner: true,
),
(
coords: (0.2833333, 2.5),
polygons: [
20,
25,
24,
4294967295,
],
is_corner: true,
),
(
coords: (0.39999962, 7.283333),
polygons: [
20,
22,
4294967295,
25,
],
is_corner: true,
),
(
coords: (7.283333, 1.5666666),
polygons: [
23,
21,
14,
15,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, 1.5666666),
polygons: [
14,
21,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, 2.5),
polygons: [
21,
23,
22,
20,
4294967295,
],
is_corner: true,
),
(
coords: (0.9833336, 2.5),
polygons: [
21,
23,
22,
20,
4294967295,
],
is_corner: true,
),
(
coords: (0.39999962, 7.283333),
polygons: [
20,
22,
4294967295,
25,
],
is_corner: true,
),
(
coords: (7.283333, 7.283333),
polygons: [
22,
23,
4294967295,
],
is_corner: true,
),
(
coords: (7.283333, 1.5666666),
polygons: [
23,
21,
14,
15,
4294967295,
],
is_corner: true,
),
(
coords: (-0.41666698, 7.283333),
polygons: [
24,
25,
4294967295,
18,
16,
],
is_corner: true,
),
(
coords: (0.39999962, 7.283333),
polygons: [
20,
22,
4294967295,
25,
],
is_corner: true,
),
(
coords: (0.2833333, 2.5),
polygons: [
20,
25,
24,
4294967295,
],
is_corner: true,
),
(
coords: (-0.3000002, 2.5),
polygons: [
24,
16,
4294967295,
],
is_corner: true,
),
],
polygons: [
(
vertices: [
2,
1,
0,
],
is_one_way: false,
),
(
vertices: [
4,
3,
5,
],
is_one_way: false,
),
(
vertices: [
6,
8,
7,
],
is_one_way: false,
),
(
vertices: [
6,
9,
8,
],
is_one_way: false,
),
(
vertices: [
13,
11,
10,
],
is_one_way: false,
),
(
vertices: [
13,
12,
11,
],
is_one_way: false,
),
(
vertices: [
15,
14,
16,
],
is_one_way: false,
),
(
vertices: [
18,
17,
19,
],
is_one_way: false,
),
(
vertices: [
22,
20,
23,
],
is_one_way: false,
),
(
vertices: [
22,
21,
20,
],
is_one_way: false,
),
(
vertices: [
25,
24,
26,
],
is_one_way: false,
),
(
vertices: [
27,
29,
28,
],
is_one_way: false,
),
(
vertices: [
27,
30,
29,
],
is_one_way: false,
),
(
vertices: [
32,
31,
33,
],
is_one_way: false,
),
(
vertices: [
36,
34,
37,
],
is_one_way: false,
),
(
vertices: [
36,
35,
34,
],
is_one_way: false,
),
(
vertices: [
40,
39,
38,
],
is_one_way: false,
),
(
vertices: [
42,
41,
43,
],
is_one_way: false,
),
(
vertices: [
44,
46,
45,
],
is_one_way: false,
),
(
vertices: [
44,
47,
46,
],
is_one_way: false,
),
(
vertices: [
49,
48,
50,
],
is_one_way: false,
),
(
vertices: [
52,
51,
53,
],
is_one_way: false,
),
(
vertices: [
54,
56,
55,
],
is_one_way: false,
),
(
vertices: [
54,
57,
56,
],
is_one_way: false,
),
(
vertices: [
60,
58,
61,
],
is_one_way: false,
),
(
vertices: [
60,
59,
58,
],
is_one_way: false,
),
],
offset: (0.0, 0.0),
baked_polygons: None,
islands: None,
height: [
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
0.10000008,
],
),
],
search_delta: 0.1,
search_steps: 2,
),
links: [
(
actor_id: "navigation-link-center",
start: (-1.5, 0.0, 0.0),
end: (1.5, 0.0, 0.0),
bidirectional: true,
cost: 1.2,
enabled: true,
),
],
areas: [
(
actor_id: "navigation-area-slow",
id: "slow",
center: (-4.0, 0.5, -4.0),
half_extents: (1.5, 1.0, 1.5),
cost: 1.5,
walkable: true,
),
],
samples: [
(
id: "around-center-obstacle",
start: (-6.0, 0.0, -5.0),
end: (6.0, 0.0, -5.0),
enabled: true,
),
],
diagnostics: (
polygon_count: 26,
island_count: 1,
effective_component_count: 1,
),
)
+13 -15
View File
@@ -1,19 +1,17 @@
(schema_version: 2,
resources: {},
entities: {
1: (
components: {
"bevy_ecs::name::Name": "Example Base Mesh",
"bevy_transform::components::transform::Transform": (
(schema_version: 4,resources: {
},
entities: {
1: (components: {
"bevy_ecs::name::Name": "Example Base Mesh",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 0.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("base-mesh"),
"shared::components::ActorKind": Empty,
"shared::components::EditorVisibility": (visible: true),
"shared::components::LevelObject": (),
},
),
},
)
"shared::components::ActorId": ("base-mesh"),
"shared::components::ActorKind": Empty,
"shared::components::EditorVisibility": (visible: true),
"shared::components::LevelObject": (),
}),
},
)
+13 -15
View File
@@ -1,23 +1,21 @@
(schema_version: 2,
resources: {},
entities: {
1: (
components: {
"bevy_ecs::name::Name": "Example Base Link",
"bevy_transform::components::transform::Transform": (
(schema_version: 4,resources: {
},
entities: {
1: (components: {
"bevy_ecs::name::Name": "Example Base Link",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 0.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("base-link"),
"shared::components::ActorKind": PrefabAnchor,
"shared::components::LevelObject": (),
"shared::components::PrefabInstance": (
"shared::components::ActorId": ("base-link"),
"shared::components::ActorKind": PrefabAnchor,
"shared::components::LevelObject": (),
"shared::components::PrefabInstance": (
asset_id: "11111111-1111-4111-8111-111111111111",
source_path: "assets/prefabs/example_base.scn.ron",
overrides_ron: None,
),
},
),
},
)
}),
},
)
+13 -15
View File
@@ -1,23 +1,21 @@
(schema_version: 2,
resources: {},
entities: {
1: (
components: {
"bevy_ecs::name::Name": "Example Nested Variant Link",
"bevy_transform::components::transform::Transform": (
(schema_version: 4,resources: {
},
entities: {
1: (components: {
"bevy_ecs::name::Name": "Example Nested Variant Link",
"bevy_transform::components::transform::Transform": (
translation: (0.0, 0.0, 0.0),
rotation: (0.0, 0.0, 0.0, 1.0),
scale: (1.0, 1.0, 1.0),
),
"shared::components::ActorId": ("nested-link"),
"shared::components::ActorKind": PrefabAnchor,
"shared::components::LevelObject": (),
"shared::components::PrefabInstance": (
"shared::components::ActorId": ("nested-link"),
"shared::components::ActorKind": PrefabAnchor,
"shared::components::LevelObject": (),
"shared::components::PrefabInstance": (
asset_id: "22222222-2222-4222-8222-222222222222",
source_path: "assets/prefabs/example_nested.scn.ron",
overrides_ron: Some("(format_version:2,source_revision:None,transform:None,material:None,child_visibility:{},properties:[],components:[(target:(instance_chain:[\"base-link\"],actor_id:\"base-mesh\"),component_type:\"shared::components::EditorVisibility\",base_component_ron:Some(\"(visible:true)\"),value_component_ron:Some(\"(visible:false)\"))],structural:[])"),
),
},
),
},
)
}),
},
)
+65
View File
@@ -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",
],
),
],
)
+42
View File
@@ -0,0 +1,42 @@
#import bevy_pbr::{
pbr_fragment::pbr_input_from_standard_material,
pbr_functions::alpha_discard,
}
#ifdef PREPASS_PIPELINE
#import bevy_pbr::{
prepass_io::{VertexOutput, FragmentOutput},
pbr_deferred_functions::deferred_output,
}
#else
#import bevy_pbr::{
forward_io::{VertexOutput, FragmentOutput},
pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
}
#endif
struct SurfaceUniform {
shader_id: u32,
flags: u32,
alpha_cutoff: f32,
abi_version: u32,
params: array<vec4<f32>, 16>,
uv_transforms: array<vec4<f32>, 8>,
}
@group(#{MATERIAL_BIND_GROUP}) @binding(100) var<uniform> surface_uniform: SurfaceUniform;
@fragment
fn fragment(in: VertexOutput, @builtin(front_facing) is_front: bool) -> FragmentOutput {
var pbr_input = pbr_input_from_standard_material(in, is_front);
pbr_input.material.base_color = alpha_discard(pbr_input.material, pbr_input.material.base_color);
#ifdef PREPASS_PIPELINE
return deferred_output(in, pbr_input);
#else
var out: FragmentOutput;
out.color = apply_pbr_lighting(pbr_input);
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
return out;
#endif
}
+65 -10
View File
@@ -1,18 +1,73 @@
(
schema_version: 1,
label: "Standard Lit",
kind: StandardLit,
wgsl_path: None,
parameters: [
(name: "base_color", display_name: "Base Color", group: "Surface", property_type: Color),
(name: "metallic", display_name: "Metallic", group: "Surface", property_type: Float(min: Some(0.0), max: Some(1.0))),
(name: "roughness", display_name: "Roughness", group: "Surface", property_type: Float(min: Some(0.0), max: Some(1.0))),
(name: "emissive_color", display_name: "Emissive Color", group: "Emission", property_type: Color),
(name: "emissive_intensity", display_name: "Emissive Nits", group: "Emission", property_type: Float(min: Some(0.0), max: Some(20000.0))),
(name: "base_color_texture", display_name: "Base Color Texture", group: "Textures", property_type: Texture),
(name: "normal_map_texture", display_name: "Normal Map", group: "Textures", property_type: Texture),
(name: "metallic_roughness_texture", display_name: "Metallic/Roughness Texture", group: "Textures", property_type: Texture),
(name: "emissive_texture", display_name: "Emissive Texture", group: "Textures", property_type: Texture),
(
name: "base_color",
display_name: "Base Color",
group: "Surface",
property_type: Color,
),
(
name: "metallic",
display_name: "Metallic",
group: "Surface",
property_type: Float(
min: Some(0.0),
max: Some(1.0),
),
),
(
name: "roughness",
display_name: "Roughness",
group: "Surface",
property_type: Float(
min: Some(0.0),
max: Some(1.0),
),
),
(
name: "emissive_color",
display_name: "Emissive Color",
group: "Emission",
property_type: Color,
),
(
name: "emissive_intensity",
display_name: "Emissive Nits",
group: "Emission",
property_type: Float(
min: Some(0.0),
max: Some(20000.0),
),
),
(
name: "base_color_texture",
display_name: "Base Color Texture",
group: "Textures",
property_type: Texture,
),
(
name: "normal_map_texture",
display_name: "Normal Map",
group: "Textures",
property_type: Texture,
),
(
name: "metallic_roughness_texture",
display_name: "Metallic/Roughness Texture",
group: "Textures",
property_type: Texture,
),
(
name: "emissive_texture",
display_name: "Emissive Texture",
group: "Textures",
property_type: Texture,
),
],
default_values: [],
default_textures: [],
)
)
+80
View File
@@ -0,0 +1,80 @@
(
schema_version: 1,
label: "Surface Tint",
kind: Custom,
wgsl_path: Some("assets/shaders/surface_tint.wgsl"),
parameters: [
(
name: "tint",
display_name: "Tint",
group: "Surface",
property_type: Color,
),
(
name: "roughness",
display_name: "Roughness",
group: "Surface",
property_type: Float(
min: Some(0.001),
max: Some(1.0),
),
),
(
name: "metallic",
display_name: "Metallic",
group: "Surface",
property_type: Float(
min: Some(0.0),
max: Some(1.0),
),
),
(
name: "emissive",
display_name: "Emissive",
group: "Emission",
property_type: Color,
),
(
name: "emissive_intensity",
display_name: "Emissive Nits",
group: "Emission",
property_type: Float(
min: Some(0.0),
max: Some(20000.0),
),
),
],
default_values: [
(
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),
),
],
default_textures: [],
)
+14
View File
@@ -0,0 +1,14 @@
fn evaluate(
input: SurfaceInput,
params: SurfaceParams,
samples: SurfaceSamples,
) -> Surface {
var surface = surface_default();
surface.base_color = params.lanes[0];
surface.perceptual_roughness = params.lanes[1].x;
surface.metallic = params.lanes[2].x;
surface.emissive = params.lanes[3].rgb * params.lanes[4].x;
surface.reflectance = 0.5;
surface.occlusion = 1.0;
return surface;
}
+116
View File
@@ -0,0 +1,116 @@
#import bevy_pbr::{
pbr_fragment::pbr_input_from_standard_material,
pbr_functions::{alpha_discard, calculate_tbn_mikktspace},
}
#ifdef PREPASS_PIPELINE
#import bevy_pbr::{
prepass_io::{VertexOutput, FragmentOutput},
pbr_deferred_functions::deferred_output,
}
#else
#import bevy_pbr::{
forward_io::{VertexOutput, FragmentOutput},
pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
}
#endif
struct TerrainLayerUniform {
base_colors: array<vec4<f32>, 4>,
properties: array<vec4<f32>, 4>,
uv_scales: vec4<f32>,
base_texture_enabled: vec4<f32>,
}
@group(#{MATERIAL_BIND_GROUP}) @binding(100) var<uniform> terrain_layers: TerrainLayerUniform;
@group(#{MATERIAL_BIND_GROUP}) @binding(101) var base_color0: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(102) var base_sampler0: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(103) var normal0: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(104) var normal_sampler0: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(105) var base_color1: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(106) var base_sampler1: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(107) var normal1: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(108) var normal_sampler1: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(109) var base_color2: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(110) var base_sampler2: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(111) var normal2: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(112) var normal_sampler2: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(113) var base_color3: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(114) var base_sampler3: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(115) var normal3: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(116) var normal_sampler3: sampler;
fn layer_base(index: u32, uv: vec2<f32>) -> vec4<f32> {
if index == 0u { return textureSample(base_color0, base_sampler0, uv); }
if index == 1u { return textureSample(base_color1, base_sampler1, uv); }
if index == 2u { return textureSample(base_color2, base_sampler2, uv); }
return textureSample(base_color3, base_sampler3, uv);
}
fn layer_normal(index: u32, uv: vec2<f32>) -> vec3<f32> {
var sample = vec3<f32>(0.5, 0.5, 1.0);
if index == 0u { sample = textureSample(normal0, normal_sampler0, uv).xyz; }
if index == 1u { sample = textureSample(normal1, normal_sampler1, uv).xyz; }
if index == 2u { sample = textureSample(normal2, normal_sampler2, uv).xyz; }
if index == 3u { sample = textureSample(normal3, normal_sampler3, uv).xyz; }
return normalize(sample * 2.0 - 1.0);
}
@fragment
fn fragment(in: VertexOutput, @builtin(front_facing) is_front: bool) -> FragmentOutput {
var pbr_input = pbr_input_from_standard_material(in, is_front);
#ifdef VERTEX_UVS_A
let uv = in.uv;
#else
let uv = vec2<f32>(0.0);
#endif
#ifdef VERTEX_COLORS
var weights = max(in.color, vec4<f32>(0.0));
#else
var weights = vec4<f32>(1.0, 0.0, 0.0, 0.0);
#endif
let enabled = vec4<f32>(
terrain_layers.properties[0].w,
terrain_layers.properties[1].w,
terrain_layers.properties[2].w,
terrain_layers.properties[3].w,
);
weights *= enabled;
let total = dot(weights, vec4<f32>(1.0));
weights = select(vec4<f32>(1.0, 0.0, 0.0, 0.0), weights / total, total > 0.0001);
var color = vec4<f32>(0.0);
var normal_ts = vec3<f32>(0.0);
var metallic = 0.0;
var roughness = 0.0;
for (var index = 0u; index < 4u; index += 1u) {
let weight = weights[index];
let layer_uv = uv * terrain_layers.uv_scales[index];
let base_sample = mix(
vec4<f32>(1.0),
layer_base(index, layer_uv),
terrain_layers.base_texture_enabled[index],
);
color += base_sample * terrain_layers.base_colors[index] * weight;
let normal_enabled = terrain_layers.properties[index].z;
normal_ts += mix(vec3<f32>(0.0, 0.0, 1.0), layer_normal(index, layer_uv), normal_enabled) * weight;
metallic += terrain_layers.properties[index].x * weight;
roughness += terrain_layers.properties[index].y * weight;
}
pbr_input.material.base_color = alpha_discard(pbr_input.material, color);
pbr_input.material.metallic = clamp(metallic, 0.0, 1.0);
pbr_input.material.perceptual_roughness = clamp(roughness, 0.001, 1.0);
#ifdef VERTEX_TANGENTS
let tbn = calculate_tbn_mikktspace(pbr_input.world_normal, in.world_tangent);
let n = normalize(normal_ts);
pbr_input.N = normalize(n.x * tbn[0] + n.y * tbn[1] + n.z * tbn[2]);
#endif
#ifdef PREPASS_PIPELINE
return deferred_output(in, pbr_input);
#else
var out: FragmentOutput;
out.color = apply_pbr_lighting(pbr_input);
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
return out;
#endif
}
+29 -5
View File
@@ -1,13 +1,37 @@
(
schema_version: 1,
label: "Unlit",
kind: Unlit,
wgsl_path: None,
parameters: [
(name: "base_color", display_name: "Base Color", group: "Surface", property_type: Color),
(name: "base_color_texture", display_name: "Base Color Texture", group: "Textures", property_type: Texture),
(name: "emissive_color", display_name: "Emissive Color", group: "Emission", property_type: Color),
(name: "emissive_intensity", display_name: "Emissive Nits", group: "Emission", property_type: Float(min: Some(0.0), max: Some(20000.0))),
(
name: "base_color",
display_name: "Base Color",
group: "Surface",
property_type: Color,
),
(
name: "base_color_texture",
display_name: "Base Color Texture",
group: "Textures",
property_type: Texture,
),
(
name: "emissive_color",
display_name: "Emissive Color",
group: "Emission",
property_type: Color,
),
(
name: "emissive_intensity",
display_name: "Emissive Nits",
group: "Emission",
property_type: Float(
min: Some(0.0),
max: Some(20000.0),
),
),
],
default_values: [],
default_textures: [],
)
)
+13
View File
@@ -0,0 +1,13 @@
[package]
name = "blacksite_surface"
version.workspace = true
edition.workspace = true
license.workspace = true
description = "Blacksite raster and ray-tracing Surface ABI material runtime"
[dependencies]
bevy.workspace = true
naga = { version = "29", features = ["wgsl-in"] }
ron = "0.8"
shared.workspace = true
uuid = "1"
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,41 @@
@fragment
fn fragment(in: VertexOutput, @builtin(front_facing) is_front: bool) -> FragmentOutput {
var pbr_input = pbr_input_from_standard_material(in, is_front);
#ifdef VERTEX_UVS_A
let uv0 = in.uv;
#else
let uv0 = vec2<f32>(0.0);
#endif
let input = SurfaceInput(uv0, pbr_input.world_position.xyz, pbr_input.N);
let params = SurfaceParams(surface_uniform.params);
let surface = evaluate(input, params, surface_samples(uv0));
pbr_input.material.base_color = surface.base_color;
pbr_input.material.emissive = vec4<f32>(surface.emissive, 1.0);
pbr_input.material.metallic = clamp(surface.metallic, 0.0, 1.0);
pbr_input.material.perceptual_roughness = clamp(surface.perceptual_roughness, 0.001, 1.0);
pbr_input.material.reflectance = vec3<f32>(clamp(surface.reflectance, 0.0, 1.0));
pbr_input.diffuse_occlusion = vec3<f32>(clamp(surface.occlusion, 0.0, 1.0));
#ifdef VERTEX_TANGENTS
let surface_tbn = calculate_tbn_mikktspace(pbr_input.world_normal, in.world_tangent);
let surface_nt = normalize(surface.normal_ts);
pbr_input.N = normalize(
surface_nt.x * surface_tbn[0]
+ surface_nt.y * surface_tbn[1]
+ surface_nt.z * surface_tbn[2]
);
#endif
if surface.model == BLACKSITE_SURFACE_UNLIT {
pbr_input.material.flags |= STANDARD_MATERIAL_FLAGS_UNLIT_BIT;
} else {
pbr_input.material.flags &= ~STANDARD_MATERIAL_FLAGS_UNLIT_BIT;
}
pbr_input.material.base_color = alpha_discard(pbr_input.material, pbr_input.material.base_color);
#ifdef PREPASS_PIPELINE
return deferred_output(in, pbr_input);
#else
var out: FragmentOutput;
out.color = apply_pbr_lighting(pbr_input);
out.color = main_pass_post_lighting_processing(pbr_input, out.color);
return out;
#endif
}
@@ -0,0 +1,103 @@
#import bevy_pbr::{
pbr_fragment::pbr_input_from_standard_material,
pbr_functions::{alpha_discard, calculate_tbn_mikktspace},
}
#ifdef PREPASS_PIPELINE
#import bevy_pbr::{
prepass_io::{VertexOutput, FragmentOutput},
pbr_deferred_functions::deferred_output,
}
#else
#import bevy_pbr::{
forward_io::{VertexOutput, FragmentOutput},
pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
}
#endif
const BLACKSITE_SURFACE_ABI_VERSION: u32 = 1u;
const BLACKSITE_SURFACE_UNLIT: u32 = 1u;
const STANDARD_MATERIAL_FLAGS_UNLIT_BIT: u32 = 1u << 5u;
struct SurfaceUniform {
shader_id: u32,
flags: u32,
alpha_cutoff: f32,
abi_version: u32,
params: array<vec4<f32>, 16>,
uv_transforms: array<vec4<f32>, 8>,
}
@group(#{MATERIAL_BIND_GROUP}) @binding(100) var<uniform> surface_uniform: SurfaceUniform;
@group(#{MATERIAL_BIND_GROUP}) @binding(101) var surface_texture0: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(102) var surface_sampler0: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(103) var surface_texture1: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(104) var surface_sampler1: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(105) var surface_texture2: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(106) var surface_sampler2: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(107) var surface_texture3: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(108) var surface_sampler3: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(109) var surface_texture4: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(110) var surface_sampler4: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(111) var surface_texture5: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(112) var surface_sampler5: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(113) var surface_texture6: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(114) var surface_sampler6: sampler;
@group(#{MATERIAL_BIND_GROUP}) @binding(115) var surface_texture7: texture_2d<f32>;
@group(#{MATERIAL_BIND_GROUP}) @binding(116) var surface_sampler7: sampler;
struct SurfaceInput {
uv0: vec2<f32>,
world_position: vec3<f32>,
world_normal: vec3<f32>,
}
struct SurfaceParams {
lanes: array<vec4<f32>, 16>,
}
struct SurfaceSamples {
values: array<vec4<f32>, 8>,
}
struct Surface {
base_color: vec4<f32>,
normal_ts: vec3<f32>,
emissive: vec3<f32>,
metallic: f32,
perceptual_roughness: f32,
reflectance: f32,
occlusion: f32,
model: u32,
}
fn surface_default() -> Surface {
var surface: Surface;
surface.base_color = vec4<f32>(1.0);
surface.normal_ts = vec3<f32>(0.0, 0.0, 1.0);
surface.emissive = vec3<f32>(0.0);
surface.metallic = 0.0;
surface.perceptual_roughness = 0.5;
surface.reflectance = 0.5;
surface.occlusion = 1.0;
surface.model = 0u;
return surface;
}
fn surface_uv(index: u32, uv: vec2<f32>) -> vec2<f32> {
let transform = surface_uniform.uv_transforms[index];
return uv * transform.xy + transform.zw;
}
fn surface_samples(uv: vec2<f32>) -> SurfaceSamples {
var samples: SurfaceSamples;
samples.values[0] = textureSample(surface_texture0, surface_sampler0, surface_uv(0u, uv));
samples.values[1] = textureSample(surface_texture1, surface_sampler1, surface_uv(1u, uv));
samples.values[2] = textureSample(surface_texture2, surface_sampler2, surface_uv(2u, uv));
samples.values[3] = textureSample(surface_texture3, surface_sampler3, surface_uv(3u, uv));
samples.values[4] = textureSample(surface_texture4, surface_sampler4, surface_uv(4u, uv));
samples.values[5] = textureSample(surface_texture5, surface_sampler5, surface_uv(5u, uv));
samples.values[6] = textureSample(surface_texture6, surface_sampler6, surface_uv(6u, uv));
samples.values[7] = textureSample(surface_texture7, surface_sampler7, surface_uv(7u, uv));
return samples;
}
+1
View File
@@ -33,6 +33,7 @@ egui_phosphor_icons.workspace = true
bevy_ufbx.workspace = true
ufbx = "0.9"
game.workspace = true
polyanya.workspace = true
game_hot.workspace = true
hot-lib-reloader = { version = "0.8.2", optional = true }
notify = { version = "6.1", optional = true }
+97 -26
View File
@@ -3,7 +3,6 @@
use std::collections::BTreeSet;
use std::fs;
use std::path::Path;
use std::time::UNIX_EPOCH;
use serde::Deserialize;
use shared::{
@@ -14,6 +13,7 @@ use shared::{
};
use crate::asset_db::AssetRecord;
use crate::assets::fingerprint::write_pretty_ron_if_changed;
pub fn animation_manifest_path(asset_id: &str) -> String {
format!("{ANIMATION_ARTIFACT_DIR}/{asset_id}.animation.ron")
@@ -32,15 +32,9 @@ pub fn refresh_animation_artifact(record: &mut AssetRecord) -> Result<AnimationM
record.dependencies.sort();
record.dependencies.dedup();
let text = ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default())
.map_err(|error| format!("could not serialize animation manifest: {error}"))?;
if let Some(parent) = Path::new(&path).parent() {
fs::create_dir_all(parent)
.map_err(|error| format!("could not create {}: {error}", parent.display()))?;
}
if fs::read_to_string(&path).ok().as_deref() != Some(text.as_str()) {
fs::write(&path, text)
.map_err(|error| format!("could not write animation manifest {path}: {error}"))?;
if write_pretty_ron_if_changed(&path, &manifest)
.map_err(|error| format!("could not publish animation manifest {path}: {error}"))?
{
bevy::log::info!(
"Animation manifest refreshed: source={} artifact={} skeletons={} clips={} runtime_supported={}",
record.path,
@@ -63,7 +57,7 @@ pub fn load_animation_manifest(path: &str) -> Result<AnimationManifest, String>
pub fn build_animation_manifest(record: &AssetRecord) -> Result<AnimationManifest, String> {
let bytes = fs::read(&record.path)
.map_err(|error| format!("could not read {}: {error}", record.path))?;
let fingerprint = source_fingerprint(&record.path, &bytes)?;
let fingerprint = source_fingerprint(&bytes);
let format = source_format(&record.path)?;
match format.as_str() {
"gltf" | "glb" => build_gltf_manifest(record, format, fingerprint, &bytes),
@@ -210,6 +204,13 @@ fn build_gltf_manifest(
});
}
let default_animation_clip_id = record.import_settings.default_animation_clip_id.clone();
validate_default_animation_clip(
default_animation_clip_id.as_deref(),
&clips,
&mut diagnostics,
);
let runtime_supported = animation_roots.len() <= 1;
if !runtime_supported {
let roots = animation_roots
@@ -232,6 +233,7 @@ fn build_gltf_manifest(
schema_version: ANIMATION_MANIFEST_SCHEMA_VERSION,
asset_id: record.id.as_string(),
label: record.label.clone(),
default_animation_clip_id,
source: AnimationManifestSource {
path: record.path.clone(),
format,
@@ -313,15 +315,22 @@ fn build_fbx_manifest(
})
.collect::<Vec<_>>();
let (runtime_supported, diagnostics) = fbx_runtime_support(
let (runtime_supported, mut diagnostics) = fbx_runtime_support(
scene.anim_stacks.as_ref().len(),
scene.skin_deformers.as_ref().len(),
);
let default_animation_clip_id = record.import_settings.default_animation_clip_id.clone();
validate_default_animation_clip(
default_animation_clip_id.as_deref(),
&clips,
&mut diagnostics,
);
Ok(AnimationManifest {
schema_version: ANIMATION_MANIFEST_SCHEMA_VERSION,
asset_id: record.id.as_string(),
label: record.label.clone(),
default_animation_clip_id,
source: AnimationManifestSource {
path: record.path.clone(),
format,
@@ -335,6 +344,27 @@ fn build_fbx_manifest(
})
}
fn validate_default_animation_clip(
default_clip_id: Option<&str>,
clips: &[AnimationClipRecord],
diagnostics: &mut Vec<AnimationImportDiagnostic>,
) {
let Some(default_clip_id) = default_clip_id.filter(|id| !id.trim().is_empty()) else {
return;
};
if clips.iter().any(|clip| clip.id == default_clip_id) {
return;
}
diagnostics.push(AnimationImportDiagnostic {
severity: AnimationDiagnosticSeverity::Error,
code: "animation.default_clip_missing".into(),
message: format!(
"configured default animation clip `{default_clip_id}` no longer exists in the imported source"
),
repair: "Choose an existing Default animation in Model Import Settings, or select Imported rest pose, then reimport.".into(),
});
}
fn fbx_runtime_support(
animation_count: usize,
skin_count: usize,
@@ -546,19 +576,8 @@ fn fbx_matrix_bytes(matrix: &ufbx::Matrix) -> Vec<u8> {
.collect()
}
fn source_fingerprint(path: &str, bytes: &[u8]) -> Result<AnimationSourceFingerprint, String> {
let metadata = fs::metadata(path).map_err(|error| format!("could not stat {path}: {error}"))?;
let modified_unix_secs = metadata
.modified()
.ok()
.and_then(|time| time.duration_since(UNIX_EPOCH).ok())
.map(|duration| duration.as_secs())
.unwrap_or_default();
Ok(AnimationSourceFingerprint {
byte_len: metadata.len(),
modified_unix_secs,
content_hash: blake3::hash(bytes).to_hex().to_string(),
})
fn source_fingerprint(bytes: &[u8]) -> AnimationSourceFingerprint {
AnimationSourceFingerprint::from_bytes(bytes)
}
fn source_format(path: &str) -> Result<String, String> {
@@ -590,6 +609,7 @@ mod tests {
path: path.to_string_lossy().replace('\\', "/"),
label: "Animated Hero".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
}
@@ -696,7 +716,8 @@ mod tests {
let second = build_animation_manifest(&record).unwrap();
assert_eq!(first, second);
assert_eq!(first.schema_version, 2);
assert_eq!(first.schema_version, ANIMATION_MANIFEST_SCHEMA_VERSION);
assert!(first.default_animation_clip_id.is_none());
assert!(first.runtime_supported);
assert_eq!(first.source.dependencies.len(), 1);
assert_eq!(first.skeletons.len(), 1);
@@ -717,6 +738,56 @@ mod tests {
fs::remove_dir_all(root).unwrap();
}
#[test]
fn legacy_mtime_metadata_does_not_rewrite_equivalent_animation_manifest() {
let root =
std::env::temp_dir().join(format!("blacksite-animation-legacy-{}", Uuid::new_v4()));
let path = write_animated_gltf(&root);
let manifest = build_animation_manifest(&fixture_record(&path)).unwrap();
let canonical =
ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default()).unwrap();
let marker = format!("byte_len: {},", manifest.source.fingerprint.byte_len);
let legacy = canonical.replacen(
&marker,
&format!("{marker}\n modified_unix_secs: 123456,"),
1,
);
assert_ne!(legacy, canonical);
let artifact = root.join("legacy.animation.ron");
fs::write(&artifact, &legacy).unwrap();
assert!(!write_pretty_ron_if_changed(&artifact, &manifest).unwrap());
assert_eq!(fs::read_to_string(&artifact).unwrap(), legacy);
fs::remove_dir_all(root).unwrap();
}
#[test]
fn explicit_default_clip_is_stable_and_stale_ids_are_diagnostic() {
let root =
std::env::temp_dir().join(format!("blacksite-animation-default-{}", Uuid::new_v4()));
let path = write_animated_gltf(&root);
let mut record = fixture_record(&path);
record.import_settings.default_animation_clip_id =
Some("animation:clip:0:idle_loop".into());
let manifest = build_animation_manifest(&record).unwrap();
assert_eq!(
manifest.default_animation_clip_id.as_deref(),
Some("animation:clip:0:idle_loop")
);
assert!(manifest.diagnostics.is_empty());
record.import_settings.default_animation_clip_id = Some("animation:clip:99:removed".into());
let stale = build_animation_manifest(&record).unwrap();
assert!(stale.diagnostics.iter().any(|diagnostic| {
diagnostic.code == "animation.default_clip_missing"
&& diagnostic.severity == AnimationDiagnosticSeverity::Error
}));
fs::remove_dir_all(root).unwrap();
}
#[test]
fn exact_signature_changes_with_joint_path_or_bind_pose() {
let identity = identity_matrix_bytes();
+187 -34
View File
@@ -2,9 +2,12 @@
use bevy::prelude::*;
use serde::{Deserialize, Serialize};
use shared::AssetSourceFingerprint;
use std::collections::{HashMap, HashSet};
use uuid::Uuid;
use crate::assets::fingerprint::{fingerprint_file, write_pretty_ron_if_changed};
/// Stable asset identity for dependency tracking and prefab references.
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct AssetId(pub Uuid);
@@ -27,8 +30,12 @@ impl Default for AssetId {
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
pub enum ModelPlacementMode {
/// Place renderable content through the appropriate normalized renderer. Imports containing
/// skins or animation route to `SkinnedMeshRenderer`; unrigged, non-animated content routes to
/// `StaticMeshRenderer`.
#[default]
StaticAsset,
/// Instantiate the complete source scene as a generic imported model.
SceneInstance,
}
@@ -61,6 +68,10 @@ pub struct ImportSettings {
pub static_mesh_manifest_path: Option<String>,
#[serde(default)]
pub animation_manifest_path: Option<String>,
/// Stable animation clip sub-asset ID used as this model's edit-mode rest presentation.
/// `None` preserves the imported node pose and never guesses a clip.
#[serde(default)]
pub default_animation_clip_id: Option<String>,
}
impl Default for ImportSettings {
@@ -74,6 +85,7 @@ impl Default for ImportSettings {
material_policy: MaterialImportPolicy::default(),
static_mesh_manifest_path: None,
animation_manifest_path: None,
default_animation_clip_id: None,
}
}
}
@@ -84,6 +96,8 @@ pub struct AssetRecord {
pub path: String,
pub label: String,
pub kind_tag: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub source_fingerprint: Option<AssetSourceFingerprint>,
#[serde(default)]
pub import_settings: ImportSettings,
#[serde(default)]
@@ -113,9 +127,10 @@ fn sync_registry_from_browser(
return;
}
let mut existing: HashMap<String, AssetRecord> = registry
.records
.drain(..)
let previous_records = std::mem::take(&mut registry.records);
let mut existing: HashMap<String, AssetRecord> = previous_records
.iter()
.cloned()
.map(|record| (record.path.clone(), record))
.collect();
let current_paths = assets
@@ -137,12 +152,30 @@ fn sync_registry_from_browser(
seen_paths.insert(path.clone(), ());
let kind_tag = format!("{:?}", asset.kind);
let source_fingerprint = if imported_source_kind(&kind_tag) {
match fingerprint_file(&path) {
Ok(fingerprint) => Some(fingerprint),
Err(error) => {
warn!("Imported source fingerprint failed for {path}: {error}");
None
}
}
} else {
None
};
let mut record = if let Some(mut prior) = existing.remove(&path).or_else(|| {
take_uniquely_moved_model_record(&mut existing, &current_paths, &path, &kind_tag)
source_fingerprint.as_ref().and_then(|fingerprint| {
take_uniquely_moved_import_record(
&mut existing,
&current_paths,
&kind_tag,
fingerprint,
)
})
}) {
if prior.path != path {
info!(
"Asset registry preserved model identity {} across move {} -> {}",
"Asset registry preserved imported source identity {} across move {} -> {}",
prior.id.as_string(),
prior.path,
path
@@ -150,18 +183,26 @@ fn sync_registry_from_browser(
prior.path = path.clone();
}
prior.label = asset.label.clone();
prior.kind_tag = kind_tag;
prior.kind_tag = kind_tag.clone();
prior
} else {
AssetRecord {
id: AssetId::new(),
path: path.clone(),
label: asset.label.clone(),
kind_tag,
kind_tag: kind_tag.clone(),
source_fingerprint: None,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
}
};
if imported_source_kind(&kind_tag) {
if let Some(source_fingerprint) = source_fingerprint {
record.source_fingerprint = Some(source_fingerprint);
}
} else {
record.source_fingerprint = None;
}
if record.kind_tag == "Model" {
if let Err(error) = super::refresh_model_artifacts(&mut record) {
warn!(
@@ -174,7 +215,8 @@ fn sync_registry_from_browser(
next_records.push(record);
}
let changed = registry.records != next_records;
sort_registry_records(&mut next_records);
let changed = previous_records != next_records;
registry.records = next_records;
if changed {
registry.index_dirty = true;
@@ -189,26 +231,32 @@ fn sync_registry_from_browser(
}
}
fn take_uniquely_moved_model_record(
fn imported_source_kind(kind_tag: &str) -> bool {
matches!(kind_tag, "Model" | "Texture" | "AudioClip")
}
fn sort_registry_records(records: &mut [AssetRecord]) {
records.sort_by(|left, right| left.path.cmp(&right.path));
}
fn take_uniquely_moved_import_record(
existing: &mut HashMap<String, AssetRecord>,
current_paths: &HashSet<String>,
new_path: &str,
kind_tag: &str,
fingerprint: &AssetSourceFingerprint,
) -> Option<AssetRecord> {
if kind_tag != "Model" {
if !imported_source_kind(kind_tag) {
return None;
}
let bytes = std::fs::read(new_path).ok()?;
let content_hash = blake3::hash(&bytes).to_hex().to_string();
let candidates = existing
.iter()
.filter_map(|(old_path, record)| {
if current_paths.contains(old_path) || record.kind_tag != "Model" {
if current_paths.contains(old_path) || record.kind_tag != kind_tag {
return None;
}
let manifest_path = record.import_settings.animation_manifest_path.as_deref()?;
let manifest = super::animation::load_animation_manifest(manifest_path).ok()?;
(manifest.source.fingerprint.content_hash == content_hash).then(|| old_path.clone())
recorded_source_fingerprint(record)
.is_some_and(|prior| prior == *fingerprint)
.then(|| old_path.clone())
})
.collect::<Vec<_>>();
if candidates.len() != 1 {
@@ -217,6 +265,15 @@ fn take_uniquely_moved_model_record(
existing.remove(&candidates[0])
}
fn recorded_source_fingerprint(record: &AssetRecord) -> Option<AssetSourceFingerprint> {
record.source_fingerprint.clone().or_else(|| {
let manifest_path = record.import_settings.animation_manifest_path.as_deref()?;
super::animation::load_animation_manifest(manifest_path)
.ok()
.map(|manifest| manifest.source.fingerprint)
})
}
pub fn find_asset_by_path(registry: &AssetRegistry, path: &str) -> Option<AssetRecord> {
registry
.records
@@ -253,11 +310,16 @@ pub fn ensure_asset_record(
if let Some(record) = find_asset_by_path(registry, &path) {
return Ok(record);
}
let kind_tag = kind_tag.into();
let source_fingerprint = imported_source_kind(&kind_tag)
.then(|| fingerprint_file(&path).ok())
.flatten();
let record = AssetRecord {
id: AssetId::new(),
path,
label: label.into(),
kind_tag: kind_tag.into(),
kind_tag,
source_fingerprint,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
};
@@ -283,6 +345,9 @@ pub fn update_import_settings(
else {
return false;
};
if record.import_settings == settings {
return false;
}
record.import_settings = settings;
registry.index_dirty = true;
true
@@ -293,13 +358,7 @@ pub fn registry_index_path() -> &'static str {
}
pub fn save_registry(registry: &AssetRegistry) -> Result<(), String> {
let path = registry_index_path();
if let Some(parent) = std::path::Path::new(path).parent() {
std::fs::create_dir_all(parent).map_err(|e| e.to_string())?;
}
let text = ron::ser::to_string_pretty(&registry.records, ron::ser::PrettyConfig::default())
.map_err(|e| e.to_string())?;
std::fs::write(path, text).map_err(|e| e.to_string())
write_pretty_ron_if_changed(registry_index_path(), &registry.records).map(|_| ())
}
pub fn load_registry() -> AssetRegistry {
@@ -324,6 +383,101 @@ mod tests {
ANIMATION_MANIFEST_SCHEMA_VERSION,
};
#[test]
fn imported_source_policy_covers_model_texture_and_audio_only() {
for kind in ["Model", "Texture", "AudioClip"] {
assert!(imported_source_kind(kind), "missing imported kind {kind}");
}
for kind in ["Material", "Level", "Prefab", "PostProcessEffect"] {
assert!(
!imported_source_kind(kind),
"authored kind {kind} was hashed"
);
}
}
#[test]
fn registry_publication_order_is_stable_across_discovery_orders() {
let records = [
("assets/textures/z.png", "Texture"),
("assets/audio/a.ogg", "AudioClip"),
("assets/models/m.glb", "Model"),
]
.into_iter()
.map(|(path, kind_tag)| AssetRecord {
id: AssetId::new(),
path: path.into(),
label: path.into(),
kind_tag: kind_tag.into(),
source_fingerprint: None,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
})
.collect::<Vec<_>>();
let mut forward = records.clone();
let mut reverse = records.into_iter().rev().collect::<Vec<_>>();
sort_registry_records(&mut forward);
sort_registry_records(&mut reverse);
assert_eq!(forward, reverse);
assert_eq!(
forward
.iter()
.map(|record| record.path.as_str())
.collect::<Vec<_>>(),
[
"assets/audio/a.ogg",
"assets/models/m.glb",
"assets/textures/z.png",
]
);
}
#[test]
fn legacy_registry_record_loads_without_forcing_a_new_identity() {
let source = r#"(
id: ("00000000-0000-0000-0000-000000000000"),
path: "assets/textures/legacy.png",
label: "Legacy",
kind_tag: "Texture",
)"#;
let record: AssetRecord = ron::from_str(source).unwrap();
assert_eq!(record.id, AssetId(Uuid::nil()));
assert!(record.source_fingerprint.is_none());
assert_eq!(record.import_settings, ImportSettings::default());
}
#[test]
fn content_match_preserves_every_imported_source_kind_across_move() {
let fingerprint = AssetSourceFingerprint::from_bytes(b"stable imported bytes");
for kind in ["Model", "Texture", "AudioClip"] {
let record = AssetRecord {
id: AssetId::new(),
path: format!("assets/old/{kind}"),
label: kind.into(),
kind_tag: kind.into(),
source_fingerprint: Some(fingerprint.clone()),
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
};
let expected_id = record.id.clone();
let mut existing = HashMap::from([(record.path.clone(), record)]);
let moved = take_uniquely_moved_import_record(
&mut existing,
&HashSet::new(),
kind,
&fingerprint,
)
.expect("unique content identity should preserve the record");
assert_eq!(moved.id, expected_id);
assert!(existing.is_empty());
}
}
fn moved_model_fixture(bytes: &[u8]) -> (std::path::PathBuf, std::path::PathBuf, AssetRecord) {
let key = Uuid::new_v4();
let source_path = std::env::temp_dir().join(format!("blacksite-moved-model-{key}.glb"));
@@ -336,12 +490,12 @@ mod tests {
schema_version: ANIMATION_MANIFEST_SCHEMA_VERSION,
asset_id: id.as_string(),
label: "Moved Model".into(),
default_animation_clip_id: None,
source: AnimationManifestSource {
path: old_path.clone(),
format: "glb".into(),
fingerprint: AnimationSourceFingerprint {
byte_len: bytes.len() as u64,
modified_unix_secs: 0,
content_hash: blake3::hash(bytes).to_hex().to_string(),
},
dependencies: Vec::new(),
@@ -361,6 +515,7 @@ mod tests {
path: old_path,
label: "Moved Model".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: ImportSettings {
animation_manifest_path: Some(manifest_path.to_string_lossy().into_owned()),
..Default::default()
@@ -375,12 +530,13 @@ mod tests {
let (source_path, manifest_path, record) = moved_model_fixture(b"stable model bytes");
let expected_id = record.id.clone();
let mut existing = HashMap::from([(record.path.clone(), record)]);
let fingerprint = fingerprint_file(&source_path).unwrap();
let moved = take_uniquely_moved_model_record(
let moved = take_uniquely_moved_import_record(
&mut existing,
&HashSet::new(),
&source_path.to_string_lossy(),
"Model",
&fingerprint,
)
.expect("unique moved model should retain its registry record");
@@ -396,13 +552,10 @@ mod tests {
let old_path = record.path.clone();
let mut existing = HashMap::from([(old_path.clone(), record)]);
let current_paths = HashSet::from([old_path]);
let fingerprint = fingerprint_file(&source_path).unwrap();
let moved = take_uniquely_moved_model_record(
&mut existing,
&current_paths,
&source_path.to_string_lossy(),
"Model",
);
let moved =
take_uniquely_moved_import_record(&mut existing, &current_paths, "Model", &fingerprint);
assert!(moved.is_none());
assert_eq!(existing.len(), 1);
+355 -18
View File
@@ -524,6 +524,7 @@ fn empty_snapshot_for_asset(asset: &EditorAsset, translation: Vec3) -> EditorEnt
primitive: None,
brush: None,
static_mesh_renderer: None,
skinned_mesh_renderer: None,
material: None,
material_override: None,
rigid_body: None,
@@ -542,8 +543,18 @@ fn empty_snapshot_for_asset(asset: &EditorAsset, translation: Vec3) -> EditorEnt
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: 0,
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
}
}
@@ -672,17 +683,33 @@ pub fn spawn_asset_at(world: &mut World, asset: &EditorAsset, translation: Vec3)
record.import_settings.placement_mode,
ModelPlacementMode::StaticAsset
) {
if let Some(renderer) = static_mesh_renderer_for_asset(world, path) {
let collider = record
.import_settings
.generate_collider
.then(|| static_mesh_collider_for_renderer(&renderer));
apply_static_mesh_placement_mode(
&mut snapshot,
renderer,
collider,
record.import_settings.hierarchy_mode,
);
if let Some((renderer, requires_skinned_renderer)) =
static_mesh_renderer_for_asset(world, path)
{
if requires_skinned_renderer {
apply_skinned_mesh_placement_mode_with_materials(
&mut snapshot,
renderer.materials.clone(),
);
match default_animation_controller_for_record(&record) {
Ok(controller) => snapshot.animation_controller = controller,
Err(error) => warn!(
"Default animation was not applied while placing {}: {error}",
record.path
),
}
} else {
let collider = record
.import_settings
.generate_collider
.then(|| static_mesh_collider_for_renderer(&renderer));
apply_static_mesh_placement_mode(
&mut snapshot,
renderer,
collider,
record.import_settings.hierarchy_mode,
);
}
} else {
warn!(
"Static mesh placement fell back to SceneRoot for {} because no renderer manifest was available",
@@ -760,6 +787,11 @@ pub fn spawn_subasset_at(
.parts
.iter()
.find(|part| part_effective_id_for_selection(part) == *sub_asset_id)?;
let part_requires_skinned_renderer = manifest.metadata.animation_count > 0
|| part.skinned
|| (manifest.schema_version < 2
&& crate::assets::gltf_skinned_primitive_labels(parent_path)
.contains(&part.mesh_label));
let mesh_ref = shared::EditorAssetRef::new(
manifest.asset_id.clone(),
@@ -784,6 +816,10 @@ pub fn spawn_subasset_at(
id: shared::ComponentInstanceId::new("slot:0"),
name: label.clone(),
mesh: mesh_ref.clone(),
material_slot_id: shared::ComponentInstanceId::new(format!(
"slot:{}",
part_effective_id_for_selection(part)
)),
material,
local_transform: part.local_transform,
visible: true,
@@ -800,6 +836,7 @@ pub fn spawn_subasset_at(
primitive: None,
brush: None,
static_mesh_renderer: Some(shared::StaticMeshRenderer::single(slot)),
skinned_mesh_renderer: None,
material: None,
material_override: None,
rigid_body: None,
@@ -818,11 +855,41 @@ pub fn spawn_subasset_at(
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: 0,
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
};
snapshot.transform.scale *= record.import_settings.scale;
if part_requires_skinned_renderer {
snapshot.actor_kind = ActorKind::SkinnedMesh;
snapshot.static_mesh_renderer = None;
snapshot.skinned_mesh_renderer = Some(shared::SkinnedMeshRenderer {
materials: crate::assets::static_mesh::renderer_materials_from_manifest(
&manifest,
&record.import_settings,
),
..shared::SkinnedMeshRenderer::new(parent_path.clone())
.with_asset_id(record.id.as_string())
});
match default_animation_controller_for_record(&record) {
Ok(controller) => snapshot.animation_controller = controller,
Err(error) => warn!(
"Default animation was not applied while placing {}: {error}",
record.path
),
}
return Some(spawn_with_history(world, snapshot));
}
if record.import_settings.generate_collider {
snapshot.rigid_body = Some(RigidBodyDesc::default());
snapshot.collider = Some(ColliderDesc::static_mesh(vec![mesh_ref]));
@@ -840,6 +907,7 @@ pub struct AnimationClipAuthoringData {
pub skeleton: shared::EditorAssetRef,
pub skeleton_signature: shared::AnimationSkeletonSignature,
pub state: shared::AnimationStateDesc,
pub renderer_materials: shared::RendererMaterialSet,
}
pub fn animation_clip_authoring_data(
@@ -905,6 +973,18 @@ pub fn animation_clip_authoring_data(
let clip_ref = shared::EditorAssetRef::new(asset_id, clip.id.clone(), clip.label.clone())
.with_source_path(parent_path);
let state_id = animation_state_id(&clip.label, clip.source_index);
let renderer_materials = record
.import_settings
.static_mesh_manifest_path
.as_deref()
.and_then(|path| load_static_mesh_manifest(path).ok())
.map(|render_manifest| {
crate::assets::static_mesh::renderer_materials_from_manifest(
&render_manifest,
&record.import_settings,
)
})
.unwrap_or_default();
Ok(AnimationClipAuthoringData {
model_asset_id: record.id.as_string(),
model_path: parent_path.clone(),
@@ -920,6 +1000,7 @@ pub fn animation_clip_authoring_data(
speed: 1.0,
range: shared::AnimationPlaybackRange::default(),
},
renderer_materials,
})
}
@@ -957,7 +1038,7 @@ pub fn animation_skeleton_signature_for_ref(
pub fn compatible_animation_skeleton_for_model(
world: &World,
model: &ModelRef,
model: &shared::SkinnedMeshRenderer,
signature: &shared::AnimationSkeletonSignature,
) -> Result<shared::EditorAssetRef, String> {
let record = world
@@ -1017,6 +1098,82 @@ fn animation_state_id(label: &str, source_index: usize) -> String {
}
}
fn default_animation_controller_for_record(
record: &crate::asset_db::AssetRecord,
) -> Result<Option<shared::AnimationControllerDesc>, String> {
let Some(manifest_path) = record.import_settings.animation_manifest_path.as_deref() else {
return Ok(None);
};
let manifest = load_animation_manifest(manifest_path)?;
if manifest.default_animation_clip_id != record.import_settings.default_animation_clip_id {
return Err(
"model import settings and generated animation manifest disagree; reimport the model"
.into(),
);
}
let Some(default_clip_id) = manifest
.default_animation_clip_id
.as_deref()
.filter(|id| !id.trim().is_empty())
else {
return Ok(None);
};
if !manifest.runtime_supported {
return Err(format!(
"configured clip `{default_clip_id}` belongs to a model unsupported by the animation runtime"
));
}
let clip = manifest
.clips
.iter()
.find(|clip| clip.id == default_clip_id)
.ok_or_else(|| {
format!(
"configured clip `{default_clip_id}` is missing from {manifest_path}; choose an existing clip or Imported rest pose"
)
})?;
let signature = clip.target_skeleton_signature.as_ref().ok_or_else(|| {
format!(
"configured clip `{}` has no uniquely resolved target skeleton",
clip.label
)
})?;
let skeleton = manifest
.skeletons
.iter()
.find(|skeleton| &skeleton.signature == signature)
.ok_or_else(|| {
format!(
"configured clip `{}` targets skeleton `{}` but no exact match exists",
clip.label, signature.0
)
})?;
let state_id = animation_state_id(&clip.label, clip.source_index);
let source_path = manifest.source.path.clone();
let asset_id = manifest.asset_id.clone();
Ok(Some(shared::AnimationControllerDesc {
skeleton: Some(
shared::EditorAssetRef::new(
asset_id.clone(),
skeleton.id.clone(),
skeleton.label.clone(),
)
.with_source_path(&source_path),
),
states: vec![shared::AnimationStateDesc {
id: state_id.clone(),
label: clip.label.clone(),
clip: shared::EditorAssetRef::new(asset_id, clip.id.clone(), clip.label.clone())
.with_source_path(source_path),
looping: true,
speed: 1.0,
range: shared::AnimationPlaybackRange::default(),
}],
default_state: state_id,
..default()
}))
}
fn spawn_animation_clip_at(
world: &mut World,
selection: &AssetSelection,
@@ -1035,7 +1192,7 @@ fn spawn_animation_clip_at(
let default_state = authored.state.id.clone();
let snapshot = EditorEntitySnapshot {
actor_id: None,
actor_kind: ActorKind::ImportedModel,
actor_kind: ActorKind::SkinnedMesh,
actor_name: None,
name: Some(authored.model_label),
transform: Transform {
@@ -1046,6 +1203,11 @@ fn spawn_animation_clip_at(
primitive: None,
brush: None,
static_mesh_renderer: None,
skinned_mesh_renderer: Some(shared::SkinnedMeshRenderer {
materials: authored.renderer_materials,
..shared::SkinnedMeshRenderer::new(authored.model_path)
.with_asset_id(authored.model_asset_id)
}),
material: None,
material_override: None,
rigid_body: None,
@@ -1061,7 +1223,7 @@ fn spawn_animation_clip_at(
audio_source: None,
audio_listener: None,
player_spawn: false,
model: Some(ModelRef::new(authored.model_path).with_asset_id(authored.model_asset_id)),
model: None,
prefab: None,
prefab_instance: None,
weapon_spawn: None,
@@ -1069,8 +1231,18 @@ fn spawn_animation_clip_at(
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: 0,
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
};
Some(spawn_with_history(world, snapshot))
@@ -1118,6 +1290,7 @@ fn apply_static_mesh_placement_mode(
primitive: None,
brush: None,
static_mesh_renderer: Some(shared::StaticMeshRenderer::single(entry)),
skinned_mesh_renderer: None,
material: None,
material_override: None,
rigid_body: collider.as_ref().map(|_| RigidBodyDesc::default()),
@@ -1136,8 +1309,18 @@ fn apply_static_mesh_placement_mode(
post_process_volume: None,
team_spawn: None,
objective: None,
navigation_bounds: None,
navigation_obstacle: None,
navigation_area: None,
navigation_link: None,
hierarchy_sibling_index: index as i32,
editor_visibility: EditorVisibility::default(),
inspector_order: None,
component_states: None,
children: Vec::new(),
}
})
@@ -1146,6 +1329,35 @@ fn apply_static_mesh_placement_mode(
}
}
#[cfg(test)]
fn apply_skinned_mesh_placement_mode(snapshot: &mut EditorEntitySnapshot) {
apply_skinned_mesh_placement_mode_with_materials(
snapshot,
shared::RendererMaterialSet::default(),
);
}
fn apply_skinned_mesh_placement_mode_with_materials(
snapshot: &mut EditorEntitySnapshot,
materials: shared::RendererMaterialSet,
) {
let Some(model) = snapshot.model.take() else {
return;
};
snapshot.actor_kind = ActorKind::SkinnedMesh;
snapshot.static_mesh_renderer = None;
snapshot.skinned_mesh_renderer = Some(shared::SkinnedMeshRenderer {
asset_id: model.asset_id,
path: model.path,
scene_index: model.scene_index,
materials,
});
// Triangle-mesh colliders are a static-geometry concern. Animated collision must be authored
// explicitly (capsules, hitboxes, or another gameplay-specific representation).
snapshot.rigid_body = None;
snapshot.collider = None;
}
fn static_mesh_collider_for_renderer(renderer: &shared::StaticMeshRenderer) -> ColliderDesc {
ColliderDesc::static_mesh(
renderer
@@ -1177,14 +1389,26 @@ fn part_effective_material_id_for_selection(
fn static_mesh_renderer_for_asset(
world: &mut World,
path: &str,
) -> Option<shared::StaticMeshRenderer> {
) -> Option<(shared::StaticMeshRenderer, bool)> {
let mut manifest_path = None;
if let Some(mut registry) = world.get_resource_mut::<AssetRegistry>() {
let mut renderer = None;
if let Some(record) = find_asset_mut_by_path(&mut registry, path) {
match super::refresh_model_artifacts(record) {
Ok(manifest) => {
renderer = Some(renderer_from_manifest(&manifest, &record.import_settings));
let requires_skinned_renderer = manifest.metadata.animation_count > 0
|| manifest.metadata.skin_count > 0
|| manifest.parts.iter().any(|part| part.skinned);
let mut authored_renderer =
renderer_from_manifest(&manifest, &record.import_settings);
if requires_skinned_renderer {
authored_renderer.materials =
crate::assets::static_mesh::renderer_materials_from_manifest(
&manifest,
&record.import_settings,
);
}
renderer = Some((authored_renderer, requires_skinned_renderer));
registry.index_dirty = true;
}
Err(error) => {
@@ -1207,7 +1431,17 @@ fn static_mesh_renderer_for_asset(
let registry = world.get_resource::<AssetRegistry>()?;
let record = find_asset_by_path(registry, path)?;
let manifest = load_static_mesh_manifest(&manifest_path).ok()?;
Some(renderer_from_manifest(&manifest, &record.import_settings))
let requires_skinned_renderer = manifest.metadata.animation_count > 0
|| manifest.metadata.skin_count > 0
|| manifest.parts.iter().any(|part| part.skinned);
let mut renderer = renderer_from_manifest(&manifest, &record.import_settings);
if requires_skinned_renderer {
renderer.materials = crate::assets::static_mesh::renderer_materials_from_manifest(
&manifest,
&record.import_settings,
);
}
Some((renderer, requires_skinned_renderer))
}
pub fn import_external_assets(paths: &[PathBuf]) -> Result<usize, String> {
@@ -1221,7 +1455,7 @@ pub fn import_external_assets(paths: &[PathBuf]) -> Result<usize, String> {
};
let dest_dir = import_dir_for_extension(extension);
if extension.eq_ignore_ascii_case("fbx") {
super::import::copy_fbx_with_sidecar(source, Path::new(dest_dir))?;
super::import::copy_fbx_bundle(source, Path::new(dest_dir))?;
copied += 1;
continue;
}
@@ -1314,6 +1548,7 @@ mod tests {
path: asset.path.clone().unwrap(),
label: asset.label.clone(),
kind_tag: "AudioClip".into(),
source_fingerprint: None,
import_settings: Default::default(),
dependencies: Vec::new(),
}],
@@ -1348,4 +1583,106 @@ mod tests {
);
assert!(world.resource::<crate::history::EditorHistory>().can_undo());
}
#[test]
fn skinned_model_placement_replaces_static_and_generic_model_renderers() {
let asset = EditorAsset {
label: "Hero".into(),
path: Some("assets/models/hero.glb".into()),
folder_path: "assets/models".into(),
kind: EditorAssetKind::Model,
};
let mut snapshot = snapshot_for_asset(&asset, Vec3::ZERO).unwrap();
snapshot.model.as_mut().unwrap().asset_id = "hero-id".into();
snapshot.static_mesh_renderer = Some(shared::StaticMeshRenderer::default());
snapshot.rigid_body = Some(RigidBodyDesc::default());
snapshot.collider = Some(ColliderDesc::static_cuboid(Vec3::ONE));
apply_skinned_mesh_placement_mode(&mut snapshot);
assert_eq!(snapshot.actor_kind, ActorKind::SkinnedMesh);
assert!(snapshot.model.is_none());
assert!(snapshot.static_mesh_renderer.is_none());
assert!(snapshot.rigid_body.is_none());
assert!(snapshot.collider.is_none());
assert_eq!(
snapshot.skinned_mesh_renderer,
Some(
shared::SkinnedMeshRenderer::new("assets/models/hero.glb").with_asset_id("hero-id")
)
);
}
#[test]
fn model_default_clip_builds_one_explicit_controller_state() {
let key = Uuid::new_v4();
let manifest_path =
std::env::temp_dir().join(format!("blacksite-default-animation-{key}.animation.ron"));
let asset_id = key.to_string();
let signature = shared::AnimationSkeletonSignature::new("rig-signature");
let clip_id = shared::animation_clip_sub_asset_id(8, "Standing");
let manifest = shared::AnimationManifest {
schema_version: shared::ANIMATION_MANIFEST_SCHEMA_VERSION,
asset_id: asset_id.clone(),
label: "Robot".into(),
default_animation_clip_id: Some(clip_id.clone()),
source: shared::AnimationManifestSource {
path: "assets/models/robot.glb".into(),
format: "glb".into(),
fingerprint: shared::AnimationSourceFingerprint {
byte_len: 1,
content_hash: "fixture".into(),
},
dependencies: Vec::new(),
},
runtime_supported: true,
skeletons: vec![shared::AnimationSkeletonRecord {
id: shared::animation_skeleton_sub_asset_id(0, "Rig"),
label: "Rig".into(),
source_index: 0,
signature: signature.clone(),
joint_paths: vec!["Root".into()],
}],
clips: vec![shared::AnimationClipRecord {
id: clip_id.clone(),
label: "Standing".into(),
source_index: 8,
duration_seconds: 0.4,
target_skeleton_signature: Some(signature),
events: Vec::new(),
}],
diagnostics: Vec::new(),
};
std::fs::write(
&manifest_path,
ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default()).unwrap(),
)
.unwrap();
let record = AssetRecord {
id: AssetId(key),
path: "assets/models/robot.glb".into(),
label: "Robot".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: crate::asset_db::ImportSettings {
animation_manifest_path: Some(manifest_path.to_string_lossy().into_owned()),
default_animation_clip_id: Some(clip_id.clone()),
..Default::default()
},
dependencies: Vec::new(),
};
let controller = default_animation_controller_for_record(&record)
.unwrap()
.expect("explicit default should produce a controller");
assert_eq!(controller.default_state, "standing");
assert_eq!(controller.states.len(), 1);
assert_eq!(controller.states[0].clip.sub_asset_id, clip_id);
assert_eq!(
controller.skeleton.unwrap().sub_asset_id,
shared::animation_skeleton_sub_asset_id(0, "Rig")
);
std::fs::remove_file(manifest_path).unwrap();
}
}
+114
View File
@@ -0,0 +1,114 @@
use std::fs;
use std::path::Path;
use serde::de::DeserializeOwned;
use serde::Serialize;
use shared::AssetSourceFingerprint;
pub(crate) fn fingerprint_file(path: impl AsRef<Path>) -> Result<AssetSourceFingerprint, String> {
let path = path.as_ref();
let bytes = fs::read(path)
.map_err(|error| format!("could not read imported source {}: {error}", path.display()))?;
Ok(AssetSourceFingerprint::from_bytes(&bytes))
}
/// Writes canonical pretty RON only when the parsed document changes semantically.
///
/// Equivalent existing bytes, including custom formatting and final-newline policy, stay intact.
pub(crate) fn write_pretty_ron_if_changed<T>(
path: impl AsRef<Path>,
value: &T,
) -> Result<bool, String>
where
T: DeserializeOwned + PartialEq + Serialize,
{
let path = path.as_ref();
if fs::read_to_string(path)
.ok()
.and_then(|text| ron::from_str::<T>(&text).ok())
.is_some_and(|existing| existing == *value)
{
return Ok(false);
}
let text = ron::ser::to_string_pretty(value, ron::ser::PrettyConfig::default())
.map_err(|error| format!("could not serialize RON: {error}"))?;
if fs::read(path).ok().as_deref() == Some(text.as_bytes()) {
return Ok(false);
}
if let Some(parent) = path.parent() {
fs::create_dir_all(parent)
.map_err(|error| format!("could not create {}: {error}", parent.display()))?;
}
fs::write(path, text)
.map_err(|error| format!("could not write {}: {error}", path.display()))?;
Ok(true)
}
#[cfg(test)]
mod tests {
use super::*;
use serde::Deserialize;
use std::fs::{File, FileTimes};
use std::time::{Duration, SystemTime};
use uuid::Uuid;
#[derive(Debug, Deserialize, PartialEq, Serialize)]
struct Fixture {
count: u32,
label: String,
}
fn fixture_path(name: &str) -> std::path::PathBuf {
std::env::temp_dir().join(format!(
"blacksite-fingerprint-{name}-{}.ron",
Uuid::new_v4()
))
}
#[test]
fn metadata_only_drift_does_not_change_content_identity() {
let path = fixture_path("mtime");
fs::write(&path, b"stable source bytes").unwrap();
let before = fingerprint_file(&path).unwrap();
File::options()
.write(true)
.open(&path)
.unwrap()
.set_times(
FileTimes::new().set_modified(SystemTime::now() + Duration::from_secs(86_400)),
)
.unwrap();
assert_eq!(fingerprint_file(&path).unwrap(), before);
fs::remove_file(path).unwrap();
}
#[test]
fn same_size_byte_change_updates_content_identity() {
let path = fixture_path("same-size");
fs::write(&path, b"source-a").unwrap();
let before = fingerprint_file(&path).unwrap();
fs::write(&path, b"source-b").unwrap();
let after = fingerprint_file(&path).unwrap();
assert_eq!(before.byte_len, after.byte_len);
assert_ne!(before.content_hash, after.content_hash);
fs::remove_file(path).unwrap();
}
#[test]
fn equivalent_ron_preserves_exact_existing_bytes() {
let path = fixture_path("semantic");
let existing = b"( label: \"stable\", count: 7, )\n\n";
fs::write(&path, existing).unwrap();
let value = Fixture {
count: 7,
label: "stable".into(),
};
assert!(!write_pretty_ron_if_changed(&path, &value).unwrap());
assert_eq!(fs::read(&path).unwrap(), existing);
fs::remove_file(path).unwrap();
}
}
+535 -42
View File
@@ -1,71 +1,564 @@
//! External asset import helpers (FBX sidecar folders, etc.).
//! External asset bundle inspection and transactional import.
use std::collections::BTreeMap;
use std::fs;
use std::path::{Path, PathBuf};
use std::path::{Component, Path, PathBuf};
/// Copies an FBX file and its sibling `.fbm` embedded-texture folder when present.
pub fn copy_fbx_with_sidecar(source: &Path, dest_dir: &Path) -> Result<(), String> {
let Some(file_name) = source.file_name() else {
return Err("FBX import path has no file name".into());
};
fs::create_dir_all(dest_dir)
.map_err(|err| format!("could not create {}: {err}", dest_dir.display()))?;
let dest = dest_dir.join(file_name);
fs::copy(source, &dest).map_err(|err| {
use bevy_ufbx::texture::external_texture_paths;
#[derive(Debug, Clone, PartialEq, Eq)]
pub(crate) struct FbxDependencyInspection {
pub relative_paths: Vec<String>,
pub resolved_paths: Vec<PathBuf>,
pub missing_paths: Vec<PathBuf>,
}
/// Parses every external FBX texture reference without loading it through Bevy.
pub(crate) fn inspect_fbx_dependencies(source: &Path) -> Result<FbxDependencyInspection, String> {
let bytes = fs::read(source)
.map_err(|error| format!("could not read FBX {}: {error}", source.display()))?;
let filename_hint = source.to_string_lossy();
let scene = ufbx::load_memory(
&bytes,
ufbx::LoadOpts {
target_unit_meters: 1.0,
target_axes: ufbx::CoordinateAxes::right_handed_y_up(),
filename: ufbx::StringOpt::Ref(&filename_hint),
..Default::default()
},
)
.map_err(|error| format!("could not parse FBX {}: {error:?}", source.display()))?;
let relative_paths = external_texture_paths(&scene).map_err(|errors| {
format!(
"could not copy {} to {}: {err}",
"unsafe FBX texture reference(s) in {}: {}",
source.display(),
dest.display()
errors
.into_iter()
.map(|error| error.to_string())
.collect::<Vec<_>>()
.join("; ")
)
})?;
let source_root = source.parent().unwrap_or_else(|| Path::new(""));
let canonical_root = fs::canonicalize(source_root).map_err(|error| {
format!(
"could not resolve FBX source directory {}: {error}",
source_root.display()
)
})?;
let mut resolved_paths = Vec::new();
let mut missing_paths = Vec::new();
for relative_path in &relative_paths {
let resolved = source_root.join(relative_path);
if !resolved.is_file() {
missing_paths.push(resolved.clone());
resolved_paths.push(resolved);
continue;
}
let canonical = fs::canonicalize(&resolved).map_err(|error| {
format!(
"could not resolve FBX dependency {}: {error}",
resolved.display()
)
})?;
if !canonical.starts_with(&canonical_root) {
return Err(format!(
"FBX dependency {} resolves outside source directory {}",
resolved.display(),
source_root.display()
));
}
resolved_paths.push(resolved);
}
missing_paths.sort();
Ok(FbxDependencyInspection {
relative_paths,
resolved_paths,
missing_paths,
})
}
if let Some(fbm_dir) = fbm_sidecar_dir(source) {
if fbm_dir.is_dir() {
let dest_fbm = dest_dir.join(fbm_dir.file_name().unwrap_or_default());
copy_dir_recursive(&fbm_dir, &dest_fbm)?;
/// Returns one stable browser-facing error for all missing FBX source textures.
pub(crate) fn validate_fbx_dependencies(source: &Path) -> Result<(), String> {
let inspection = inspect_fbx_dependencies(source)?;
if inspection.missing_paths.is_empty() {
return Ok(());
}
Err(format!(
"missing {} FBX source texture(s): {}",
inspection.missing_paths.len(),
inspection
.missing_paths
.iter()
.map(|path| path.to_string_lossy().replace('\\', "/"))
.collect::<Vec<_>>()
.join(", ")
))
}
/// Copies an FBX and every referenced external texture as one staged filesystem transaction.
pub fn copy_fbx_bundle(source: &Path, dest_dir: &Path) -> Result<(), String> {
let inspection = inspect_fbx_dependencies(source)?;
if !inspection.missing_paths.is_empty() {
return Err(format!(
"FBX import is missing {} required texture(s): {}",
inspection.missing_paths.len(),
inspection
.missing_paths
.iter()
.map(|path| path.display().to_string())
.collect::<Vec<_>>()
.join(", ")
));
}
let file_name = source
.file_name()
.ok_or_else(|| "FBX import path has no file name".to_string())?;
let mut entries = BTreeMap::new();
entries.insert(PathBuf::from(file_name), source.to_path_buf());
for (relative, resolved) in inspection
.relative_paths
.iter()
.zip(inspection.resolved_paths.iter())
{
let relative = PathBuf::from(relative);
if let Some(existing) = entries.insert(relative.clone(), resolved.clone()) {
if existing != *resolved {
return Err(format!(
"FBX import maps multiple source files to {}",
relative.display()
));
}
}
}
Ok(())
copy_bundle_transactionally(&entries, dest_dir)
}
fn fbm_sidecar_dir(source: &Path) -> Option<PathBuf> {
let stem = source.file_stem()?.to_str()?;
let parent = source.parent()?;
Some(parent.join(format!("{stem}.fbm")))
}
fn copy_bundle_transactionally(
entries: &BTreeMap<PathBuf, PathBuf>,
dest_dir: &Path,
) -> Result<(), String> {
fs::create_dir_all(dest_dir)
.map_err(|error| format!("could not create {}: {error}", dest_dir.display()))?;
let canonical_dest_dir = fs::canonicalize(dest_dir).map_err(|error| {
format!(
"could not resolve FBX import destination {}: {error}",
dest_dir.display()
)
})?;
for relative in entries.keys() {
validate_bundle_relative_path(relative)?;
validate_existing_destination_parents(dest_dir, &canonical_dest_dir, relative)?;
let target = dest_dir.join(relative);
if target.is_dir() {
return Err(format!(
"FBX import target {} is an existing directory",
target.display()
));
}
}
fn copy_dir_recursive(source: &Path, dest: &Path) -> Result<(), String> {
fs::create_dir_all(dest)
.map_err(|err| format!("could not create {}: {err}", dest.display()))?;
for entry in fs::read_dir(source).map_err(|err| err.to_string())? {
let entry = entry.map_err(|err| err.to_string())?;
let src_path = entry.path();
let dest_path = dest.join(entry.file_name());
if src_path.is_dir() {
copy_dir_recursive(&src_path, &dest_path)?;
} else {
fs::copy(&src_path, &dest_path).map_err(|err| {
let stage_root = dest_dir.join(format!(".blacksite-import-{}", uuid::Uuid::new_v4()));
let staged_root = stage_root.join("new");
let backup_root = stage_root.join("backup");
let stage_result = (|| {
for (relative, source) in entries {
let staged = staged_root.join(relative);
if let Some(parent) = staged.parent() {
fs::create_dir_all(parent).map_err(|error| {
format!(
"could not create import staging {}: {error}",
parent.display()
)
})?;
}
fs::copy(source, &staged).map_err(|error| {
format!(
"could not copy {} to {}: {err}",
src_path.display(),
dest_path.display()
"could not stage FBX bundle file {} as {}: {error}",
source.display(),
relative.display()
)
})?;
}
commit_staged_bundle(
entries,
dest_dir,
&canonical_dest_dir,
&staged_root,
&backup_root,
)
})();
let cleanup_result = fs::remove_dir_all(&stage_root);
match (stage_result, cleanup_result) {
(Err(error), _) => Err(error),
(Ok(()), Ok(())) => Ok(()),
(Ok(()), Err(error)) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
(Ok(()), Err(error)) => {
bevy::log::warn!(
"FBX bundle imported but staging cleanup failed for {}: {error}",
stage_root.display()
);
Ok(())
}
}
}
fn validate_bundle_relative_path(relative: &Path) -> Result<(), String> {
if relative.as_os_str().is_empty()
|| !relative
.components()
.all(|component| matches!(component, Component::Normal(_)))
{
return Err(format!(
"FBX import target path {} is not a safe relative path",
relative.display()
));
}
Ok(())
}
fn validate_existing_destination_parents(
dest_dir: &Path,
canonical_dest_dir: &Path,
relative: &Path,
) -> Result<(), String> {
let mut current = dest_dir.to_path_buf();
let Some(parent) = relative.parent() else {
return Ok(());
};
for component in parent.components() {
let Component::Normal(segment) = component else {
return Err(format!(
"FBX import target path {} is not a safe relative path",
relative.display()
));
};
current.push(segment);
let metadata = match fs::symlink_metadata(&current) {
Ok(metadata) => metadata,
Err(error) if error.kind() == std::io::ErrorKind::NotFound => break,
Err(error) => {
return Err(format!(
"could not inspect FBX import target {}: {error}",
current.display()
));
}
};
if metadata.file_type().is_symlink() {
return Err(format!(
"FBX import target parent {} is a symbolic link",
current.display()
));
}
if !metadata.is_dir() {
return Err(format!(
"FBX import target parent {} is not a directory",
current.display()
));
}
let canonical = fs::canonicalize(&current).map_err(|error| {
format!(
"could not resolve FBX import target parent {}: {error}",
current.display()
)
})?;
if !canonical.starts_with(canonical_dest_dir) {
return Err(format!(
"FBX import target parent {} resolves outside destination {}",
current.display(),
dest_dir.display()
));
}
}
Ok(())
}
fn commit_staged_bundle(
entries: &BTreeMap<PathBuf, PathBuf>,
dest_dir: &Path,
canonical_dest_dir: &Path,
staged_root: &Path,
backup_root: &Path,
) -> Result<(), String> {
let mut installed = Vec::new();
let mut backups = Vec::new();
for relative in entries.keys() {
let target = dest_dir.join(relative);
let staged = staged_root.join(relative);
if let Some(parent) = target.parent() {
if let Err(error) = fs::create_dir_all(parent) {
return rollback_bundle(
&installed,
&backups,
format!(
"could not create import target {}: {error}",
parent.display()
),
);
}
let canonical_parent = match fs::canonicalize(parent) {
Ok(canonical_parent) => canonical_parent,
Err(error) => {
return rollback_bundle(
&installed,
&backups,
format!(
"could not resolve import target {}: {error}",
parent.display()
),
);
}
};
if !canonical_parent.starts_with(canonical_dest_dir) {
return rollback_bundle(
&installed,
&backups,
format!(
"FBX import target {} resolves outside destination {}",
parent.display(),
dest_dir.display()
),
);
}
}
if target.exists() {
let backup = backup_root.join(relative);
if let Some(parent) = backup.parent() {
if let Err(error) = fs::create_dir_all(parent) {
return rollback_bundle(
&installed,
&backups,
format!(
"could not create import backup {}: {error}",
parent.display()
),
);
}
}
if let Err(error) = fs::rename(&target, &backup) {
return rollback_bundle(
&installed,
&backups,
format!(
"could not back up import target {}: {error}",
target.display()
),
);
}
backups.push((backup, target.clone()));
}
if let Err(error) = fs::rename(&staged, &target) {
return rollback_bundle(
&installed,
&backups,
format!(
"could not publish import target {}: {error}",
target.display()
),
);
}
installed.push(target);
}
Ok(())
}
fn rollback_bundle(
installed: &[PathBuf],
backups: &[(PathBuf, PathBuf)],
cause: String,
) -> Result<(), String> {
let mut rollback_errors = Vec::new();
for target in installed.iter().rev() {
if let Err(error) = fs::remove_file(target) {
if error.kind() != std::io::ErrorKind::NotFound {
rollback_errors.push(format!("remove {}: {error}", target.display()));
}
}
}
for (backup, target) in backups.iter().rev() {
if let Err(error) = fs::rename(backup, target) {
rollback_errors.push(format!(
"restore {} to {}: {error}",
backup.display(),
target.display()
));
}
}
if rollback_errors.is_empty() {
Err(cause)
} else {
Err(format!(
"{cause}; rollback also failed: {}",
rollback_errors.join("; ")
))
}
}
#[cfg(test)]
mod tests {
use super::fbm_sidecar_dir;
use std::path::Path;
use super::*;
fn temp_root(label: &str) -> PathBuf {
std::env::temp_dir().join(format!("blacksite-fbx-{label}-{}", uuid::Uuid::new_v4()))
}
fn committed_chair_bytes() -> Vec<u8> {
fs::read(
Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/models/painted_wooden_chair_02_2k.fbx"),
)
.unwrap()
}
fn replace_equal_length(bytes: &mut [u8], from: &[u8], to: &[u8]) -> usize {
assert_eq!(from.len(), to.len());
let mut count = 0;
let mut offset = 0;
while let Some(index) = bytes[offset..]
.windows(from.len())
.position(|window| window == from)
{
let start = offset + index;
bytes[start..start + from.len()].copy_from_slice(to);
offset = start + from.len();
count += 1;
}
count
}
fn write_textures(root: &Path, folder: &str) {
let folder = root.join(folder);
fs::create_dir_all(&folder).unwrap();
for name in [
"painted_wooden_chair_02_diff_2k.jpg",
"painted_wooden_chair_02_nor_gl_2k.exr",
"painted_wooden_chair_02_rough_2k.exr",
] {
fs::write(folder.join(name), name.as_bytes()).unwrap();
}
}
#[test]
fn fbm_sidecar_path() {
fn committed_chair_reports_one_stable_missing_dependency_state() {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/models/painted_wooden_chair_02_2k.fbx");
let error = validate_fbx_dependencies(&path).unwrap_err();
assert!(error.starts_with("missing 3 FBX source texture(s):"));
assert_eq!(error.matches("painted_wooden_chair_02_").count(), 3);
}
#[test]
fn sibling_texture_bundle_is_copied_with_relative_layout() {
let root = temp_root("sibling");
let source_root = root.join("source");
let destination = root.join("destination");
fs::create_dir_all(&source_root).unwrap();
let source = source_root.join("chair.fbx");
fs::write(&source, committed_chair_bytes()).unwrap();
write_textures(&source_root, "textures");
copy_fbx_bundle(&source, &destination).unwrap();
assert!(destination.join("chair.fbx").is_file());
assert!(destination
.join("textures/painted_wooden_chair_02_diff_2k.jpg")
.is_file());
assert!(!destination.read_dir().unwrap().any(|entry| entry
.unwrap()
.file_name()
.to_string_lossy()
.starts_with(".blacksite-import-")));
fs::remove_dir_all(root).unwrap();
}
#[test]
fn fbm_texture_bundle_is_copied_with_relative_layout() {
let root = temp_root("fbm");
let source_root = root.join("source");
let destination = root.join("destination");
fs::create_dir_all(&source_root).unwrap();
let source = source_root.join("chair.fbx");
let mut bytes = committed_chair_bytes();
assert!(replace_equal_length(&mut bytes, b"textures/", b"test.fbm/") > 0);
fs::write(&source, bytes).unwrap();
write_textures(&source_root, "test.fbm");
copy_fbx_bundle(&source, &destination).unwrap();
assert!(destination
.join("test.fbm/painted_wooden_chair_02_diff_2k.jpg")
.is_file());
fs::remove_dir_all(root).unwrap();
}
#[test]
fn traversal_reference_is_rejected_before_destination_changes() {
let root = temp_root("traversal");
let source_root = root.join("source");
let destination = root.join("destination");
fs::create_dir_all(&source_root).unwrap();
fs::create_dir_all(&destination).unwrap();
let source = source_root.join("chair.fbx");
let mut bytes = committed_chair_bytes();
assert!(replace_equal_length(&mut bytes, b"textures/", b"../evil//") > 0);
fs::write(&source, bytes).unwrap();
fs::write(destination.join("chair.fbx"), b"original").unwrap();
let error = copy_fbx_bundle(&source, &destination).unwrap_err();
assert!(error.contains("parent traversal"));
assert_eq!(
fbm_sidecar_dir(Path::new("/tmp/Character.fbx")),
Some(Path::new("/tmp/Character.fbm").to_path_buf())
fs::read(destination.join("chair.fbx")).unwrap(),
b"original"
);
fs::remove_dir_all(root).unwrap();
}
#[test]
fn missing_bundle_preserves_existing_destination() {
let root = temp_root("missing");
let source_root = root.join("source");
let destination = root.join("destination");
fs::create_dir_all(&source_root).unwrap();
fs::create_dir_all(&destination).unwrap();
let source = source_root.join("chair.fbx");
fs::write(&source, committed_chair_bytes()).unwrap();
fs::write(destination.join("chair.fbx"), b"original").unwrap();
let error = copy_fbx_bundle(&source, &destination).unwrap_err();
assert!(error.contains("missing 3 required texture(s)"));
assert_eq!(
fs::read(destination.join("chair.fbx")).unwrap(),
b"original"
);
fs::remove_dir_all(root).unwrap();
}
#[cfg(unix)]
#[test]
fn destination_symlink_escape_is_rejected_before_external_changes() {
use std::os::unix::fs::symlink;
let root = temp_root("destination-symlink");
let source_root = root.join("source");
let destination = root.join("destination");
let outside = root.join("outside");
fs::create_dir_all(&source_root).unwrap();
fs::create_dir_all(&destination).unwrap();
fs::create_dir_all(&outside).unwrap();
let source = source_root.join("chair.fbx");
fs::write(&source, committed_chair_bytes()).unwrap();
write_textures(&source_root, "textures");
symlink(&outside, destination.join("textures")).unwrap();
let error = copy_fbx_bundle(&source, &destination).unwrap_err();
assert!(error.contains("symbolic link"));
assert!(!destination.join("chair.fbx").exists());
assert!(!outside.join("painted_wooden_chair_02_diff_2k.jpg").exists());
fs::remove_dir_all(root).unwrap();
}
}
+101 -14
View File
@@ -2,10 +2,13 @@
use bevy::prelude::*;
use bevy_egui::egui;
use shared::{LevelObject, MaterialAsset, MaterialDesc};
use shared::{
ComponentInstanceId, LevelObject, MaterialAsset, MaterialDesc, MaterialRef,
RendererMaterialSlot,
};
use crate::assets::{EditorAsset, EditorAssetKind, EditorAssets};
use crate::history::set_material_group_with_history;
use crate::history::{reflected_component_transaction, set_material_group_with_history};
use crate::ui::inspector::property_row;
pub fn load_material_asset(catalog_path: &str) -> Result<MaterialAsset, String> {
@@ -13,10 +16,7 @@ pub fn load_material_asset(catalog_path: &str) -> Result<MaterialAsset, String>
}
pub fn material_desc_from_asset(catalog_path: &str) -> Result<MaterialDesc, String> {
let asset = load_material_asset(catalog_path)?;
let mut desc = asset.material;
desc.material_asset_path = Some(catalog_path.to_string());
Ok(desc)
shared::load_resolved_material_from_path(catalog_path).map(|(desc, _)| desc)
}
pub fn apply_material_asset_to_selection(
@@ -28,18 +28,105 @@ pub fn apply_material_asset_to_selection(
.path
.clone()
.ok_or_else(|| format!("Material has no source path: {}", asset.label))?;
let desc = material_desc_from_asset(&path)?;
let changes = crate::ui::helpers::selected_level_entities(world, selected)
.into_iter()
.filter(|entity| world.get::<LevelObject>(*entity).is_some())
.map(|entity| (entity, desc.clone()))
.collect::<Vec<_>>();
set_material_group_with_history(world, changes);
let record = world
.get_resource::<crate::asset_db::AssetRegistry>()
.and_then(|registry| crate::asset_db::find_asset_by_path(registry, &path))
.ok_or_else(|| format!("Material is missing from the asset registry: {path}"))?;
let sub_asset_id = if shared::MaterialInstanceAsset::load_from_path(&path).is_ok() {
"material:instance"
} else {
"material:source"
};
let material_ref = MaterialRef::new(
shared::EditorAssetRef::new(record.id.as_string(), sub_asset_id, asset.label.clone())
.with_source_path(path.clone()),
);
let desc = material_desc_from_asset(&path).ok();
let entities = crate::ui::helpers::selected_level_entities(world, selected);
let mut renderer_changes = 0usize;
let mut legacy_changes = Vec::new();
for entity in entities {
if world.get::<LevelObject>(entity).is_none() {
continue;
}
if let Some(mut renderer) = world.get::<shared::StaticMeshRenderer>(entity).cloned() {
ensure_static_material_slots(&mut renderer);
for slot in &mut renderer.materials.slots {
slot.material = Some(material_ref.clone());
}
reflected_component_transaction(
world,
entity,
"Assign Material Slots",
shared::AUTHORING_COMPONENT_STATIC_MESH_RENDERER,
shared::COMPONENT_STATIC_MESH_RENDERER,
move |world, entity| {
world.entity_mut(entity).insert(renderer);
Ok(())
},
)?;
renderer_changes += 1;
continue;
}
if let Some(mut renderer) = world.get::<shared::SkinnedMeshRenderer>(entity).cloned() {
if renderer.materials.slots.is_empty() {
return Err(format!(
"Skinned renderer `{}` has no imported material slots; reimport its model",
renderer.path
));
}
for slot in &mut renderer.materials.slots {
slot.material = Some(material_ref.clone());
}
reflected_component_transaction(
world,
entity,
"Assign Material Slots",
shared::AUTHORING_COMPONENT_SKINNED_MESH_RENDERER,
shared::COMPONENT_SKINNED_MESH_RENDERER,
move |world, entity| {
world.entity_mut(entity).insert(renderer);
Ok(())
},
)?;
renderer_changes += 1;
continue;
}
if let Some(desc) = desc.as_ref() {
legacy_changes.push((entity, desc.clone()));
}
}
if !legacy_changes.is_empty() {
set_material_group_with_history(world, legacy_changes);
}
if renderer_changes == 0 && desc.is_none() {
return Err("No selected renderable actor accepts this material".into());
}
world.resource_mut::<crate::scene_io::SceneIo>().status =
format!("Applied material {}", asset.label);
format!("Applied shared material {}", asset.label);
Ok(())
}
pub(crate) fn ensure_static_material_slots(renderer: &mut shared::StaticMeshRenderer) {
for part in &mut renderer.slots {
if part.material_slot_id.0.trim().is_empty() {
part.material_slot_id = if part.id.0.trim().is_empty() {
ComponentInstanceId::new("slot:legacy")
} else {
ComponentInstanceId::new(format!("slot:{}", part.id.0))
};
}
if renderer.materials.slot(&part.material_slot_id).is_none() {
renderer.materials.slots.push(RendererMaterialSlot {
id: part.material_slot_id.clone(),
name: part.name.clone(),
source_material: part.material.clone().map(MaterialRef::new),
material: None,
});
}
}
}
pub fn material_asset_picker_ui(
world: &mut World,
ui: &mut egui::Ui,
+3 -2
View File
@@ -3,6 +3,7 @@
pub mod animation;
pub mod asset_db;
mod catalog;
mod fingerprint;
mod import;
pub mod materials;
pub mod operators;
@@ -13,8 +14,8 @@ pub mod thumbnails;
pub use catalog::*;
pub use thumbnails::{
draw_asset_cell_with, gltf_skinned_primitive_labels, invalidate_on_catalog_refresh, kind_icon,
prefetch_folder_thumbnails, AssetThumbnailCache, ThumbnailCacheSnapshot, ThumbnailState,
ThumbnailStudio, ThumbnailsPlugin,
prefetch_asset_thumbnails, prefetch_folder_thumbnails, AssetThumbnailCache,
ThumbnailCacheSnapshot, ThumbnailState, ThumbnailStudio, ThumbnailsPlugin,
};
/// Refreshes both generated contracts derived from one imported model source.
+183 -8
View File
@@ -119,10 +119,10 @@ pub fn assign_animation_clip_operator(
selection: AssetSelection,
entity: Entity,
) -> bool {
let availability = if world.get::<shared::ModelRef>(entity).is_some() {
let availability = if world.get::<shared::SkinnedMeshRenderer>(entity).is_some() {
OperatorAvailability::Ready
} else {
OperatorAvailability::Disabled("Select an authored imported-model actor".to_string())
OperatorAvailability::Disabled("Select an authored skinned-mesh actor".to_string())
};
let label = format!("Assign Animation Clip {}", selection.display_label());
run_immediate_operator(
@@ -133,9 +133,9 @@ pub fn assign_animation_clip_operator(
move |world| {
let authored = animation_clip_authoring_data(world, &selection)?;
let model = world
.get::<shared::ModelRef>(entity)
.get::<shared::SkinnedMeshRenderer>(entity)
.cloned()
.ok_or_else(|| "Selected actor has no ModelRef".to_string())?;
.ok_or_else(|| "Selected actor has no SkinnedMeshRenderer".to_string())?;
let mut controller = world
.get::<shared::AnimationControllerDesc>(entity)
.cloned()
@@ -197,7 +197,7 @@ mod tests {
animation_clip_sub_asset_id, animation_skeleton_sub_asset_id, ActorKind,
AnimationClipRecord, AnimationControllerDesc, AnimationManifest, AnimationManifestSource,
AnimationSkeletonRecord, AnimationSkeletonSignature, AnimationSourceFingerprint,
AudioSourceDesc, LevelObject, MaterialDesc, ModelRef, PrimitiveShape,
AudioSourceDesc, LevelObject, MaterialDesc, PrimitiveShape, SkinnedMeshRenderer,
ANIMATION_MANIFEST_SCHEMA_VERSION,
};
@@ -222,12 +222,12 @@ mod tests {
schema_version: ANIMATION_MANIFEST_SCHEMA_VERSION,
asset_id: asset_id.as_string(),
label: "Operator Fixture".into(),
default_animation_clip_id: None,
source: AnimationManifestSource {
path: model_path.clone(),
format: "glb".into(),
fingerprint: AnimationSourceFingerprint {
byte_len: 1,
modified_unix_secs: 0,
content_hash: "fixture".into(),
},
dependencies: Vec::new(),
@@ -264,6 +264,7 @@ mod tests {
path: model_path.clone(),
label: "Operator Fixture".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: ImportSettings {
animation_manifest_path: Some(path.to_string_lossy().into_owned()),
..Default::default()
@@ -301,6 +302,43 @@ mod tests {
assert_undo_redo_round_trip(&mut world, 0, 1, authored_count);
}
#[test]
fn animation_clip_placement_creates_only_the_skinned_renderer_path() {
let mut world = World::new();
world.init_resource::<ActiveOperator>();
world.init_resource::<EditorHistory>();
world.init_resource::<SceneIo>();
world.init_resource::<SelectedEntity>();
let (manifest_path, record, selection) = animation_fixture();
world.insert_resource(AssetRegistry {
records: vec![record],
index_dirty: false,
});
let harness = OperatorInvariantHarness::capture(&mut world);
assert!(place_subasset_operator(
&mut world,
selection,
Vec3::new(1.0, 2.0, 3.0),
));
let entity = world
.query_filtered::<Entity, With<LevelObject>>()
.single(&world)
.unwrap();
assert_eq!(
world.get::<ActorKind>(entity),
Some(&ActorKind::SkinnedMesh)
);
assert!(world.get::<SkinnedMeshRenderer>(entity).is_some());
assert!(world.get::<AnimationControllerDesc>(entity).is_some());
assert!(world.get::<shared::ModelRef>(entity).is_none());
assert!(world.get::<shared::StaticMeshRenderer>(entity).is_none());
harness.assert_committed(&mut world, 1, 1);
assert_undo_redo_round_trip(&mut world, 0, 1, authored_count);
let _ = std::fs::remove_file(manifest_path);
}
#[test]
fn audio_clip_assignment_is_one_undoable_operator() {
let mut world = World::new();
@@ -314,6 +352,7 @@ mod tests {
path: path.clone(),
label: "Impact".into(),
kind_tag: "AudioClip".into(),
source_fingerprint: None,
import_settings: Default::default(),
dependencies: Vec::new(),
}],
@@ -363,8 +402,8 @@ mod tests {
let entity = world
.spawn((
LevelObject,
ActorKind::ImportedModel,
ModelRef::new(model_path),
ActorKind::SkinnedMesh,
SkinnedMeshRenderer::new(model_path),
))
.id();
let harness = OperatorInvariantHarness::capture(&mut world);
@@ -431,6 +470,87 @@ 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(),
source_fingerprint: None,
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();
@@ -495,4 +615,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);
}
}
+97 -7
View File
@@ -22,6 +22,7 @@ use crate::asset_db::{ensure_asset_record, AssetRegistry};
use crate::history::{
capture_prefab_edit_state, record_prefab_edit_state, record_prefab_source_apply,
};
use crate::native_dialog::NativeDialogBroker;
use crate::ui::inspector::{
apply_component_card_response, component_card, component_card_context, property_row,
ComponentCardOptions,
@@ -751,13 +752,44 @@ fn relink_prefab_source(world: &mut World, entity: Entity) {
else {
return;
};
let Some(path) = rfd::FileDialog::new()
.set_directory(project_root.join("assets/prefabs"))
.add_filter("Bevy prefab", &["scn.ron", "ron"])
.pick_file()
else {
let directory = project_root.join("assets/prefabs");
let result = world.resource::<NativeDialogBroker>().request(
move || {
rfd::FileDialog::new()
.set_directory(directory)
.add_filter("Bevy prefab", &["scn.ron", "ron"])
.pick_file()
},
move |world, path| {
let Some(path) = path else {
world
.resource_mut::<crate::scene_io::SceneIo>()
.set_status("Prefab relink cancelled");
return;
};
finish_relink_prefab_source(world, entity, project_root, path);
},
);
world
.resource_mut::<crate::scene_io::SceneIo>()
.set_status(match result {
Ok(()) => "Choose a prefab source".into(),
Err(error) => format!("Prefab relink unavailable: {error}"),
});
}
fn finish_relink_prefab_source(
world: &mut World,
entity: Entity,
project_root: PathBuf,
path: PathBuf,
) {
if world.get_entity(entity).is_err() {
world
.resource_mut::<crate::scene_io::SceneIo>()
.set_status("Prefab relink failed: the initiating actor no longer exists");
return;
};
}
let Ok(path) = path.canonicalize() else {
return;
};
@@ -1248,6 +1280,10 @@ fn apply_prefab_scope_to_source(
return;
}
};
let before_snapshot = crate::collaboration::FileSnapshot::from_loaded_bytes(
&source_path,
before_source.as_bytes(),
);
let mut document = match SceneDocument::from_ron_text(&before_source) {
Ok(document) => document,
Err(error) => {
@@ -1361,7 +1397,13 @@ fn apply_prefab_scope_to_source(
}
let after_source = document.to_ron_text()?;
scene::validate_prefab_graph_text(&after_source, &source_path, &project_root)?;
crate::scene::recovery::atomic_write(&source_path, after_source.as_bytes())?;
crate::collaboration::publish_authored_file(
world,
&source_path,
after_source.as_bytes(),
&before_snapshot,
crate::collaboration::FileWriteIntent::PrefabSource { instance_root },
)?;
Ok::<_, String>(after_source)
})();
let after_source = match apply_result {
@@ -2607,6 +2649,22 @@ fn retry_prefab_source(world: &mut World, entity: Entity) {
"Prefab source queued for reload".into();
}
pub(crate) fn reload_prefab_source_after_file_conflict(
world: &mut World,
instance_root: Entity,
) -> Result<String, String> {
if world.get::<PrefabInstance>(instance_root).is_none() {
return Err("the prefab instance no longer exists".into());
}
retry_prefab_source(world, instance_root);
let status = world.resource::<crate::scene_io::SceneIo>().status.clone();
if status.starts_with("Prefab retry failed") {
Err(status)
} else {
Ok(status)
}
}
pub fn prefab_member_inspector_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
let Some((instance_root, target)) = prefab_member_override_target(world, entity) else {
ui.label(egui::RichText::new("Prefab target unavailable").color(ERROR));
@@ -3258,6 +3316,38 @@ mod tests {
assert_eq!(read_overrides(&instance), PrefabOverrides::default());
}
#[test]
fn collaboration_reload_restarts_prefab_hydration_without_dropping_overrides() {
let root = std::env::temp_dir().join(format!(
"blacksite-prefab-collaboration-reload-{}",
uuid::Uuid::new_v4()
));
let source_path = root.join("assets/prefabs/base.scn.ron");
std::fs::create_dir_all(source_path.parent().unwrap()).unwrap();
std::fs::write(&source_path, prefab_source("mesh", None)).unwrap();
let mut world = prefab_test_world(&root);
let mut instance = PrefabInstance::new("base", "assets/prefabs/base.scn.ron");
instance.overrides_ron = encode_prefab_overrides(&PrefabOverrides {
source_revision: Some("previous".into()),
..Default::default()
})
.unwrap();
let instance_root = world.spawn((instance.clone(), HydratedPrefabReady)).id();
let status = reload_prefab_source_after_file_conflict(&mut world, instance_root).unwrap();
assert_eq!(status, "Prefab source queued for reload");
assert_eq!(
world
.get::<PrefabInstance>(instance_root)
.map(|current| &current.overrides_ron),
Some(&instance.overrides_ron)
);
assert!(world.get::<HydratedPrefabReady>(instance_root).is_none());
assert!(world.get::<PrefabRef>(instance_root).is_some());
std::fs::remove_dir_all(root).unwrap();
}
#[test]
fn nested_unpack_fold_is_transactional_when_a_later_link_is_invalid() {
let mut world = World::new();
+286 -79
View File
@@ -2,21 +2,26 @@
use std::fs;
use std::path::Path;
use std::time::UNIX_EPOCH;
use bevy::gltf::GltfAssetLabel;
use bevy::prelude::*;
use bevy_ufbx::label::FbxAssetLabel;
use bevy_ufbx::mesh::group_faces_by_material;
use bevy_ufbx::texture::external_texture_paths;
use bevy_ufbx::utils::convert_matrix;
use serde::{Deserialize, Serialize};
use crate::asset_db::{
AssetRecord, ImportSettings, MaterialImportPolicy, ModelHierarchyMode, ModelPlacementMode,
};
use shared::{ComponentInstanceId, EditorAssetRef, StaticMeshRenderer, StaticMeshRendererEntry};
use shared::{
AssetSourceFingerprint, ComponentInstanceId, EditorAssetRef, MaterialRef, RendererMaterialSet,
RendererMaterialSlot, StaticMeshRenderer, StaticMeshRendererEntry,
};
pub const STATIC_MESH_MANIFEST_SCHEMA: u32 = 1;
use crate::assets::fingerprint::{fingerprint_file, write_pretty_ron_if_changed};
pub const STATIC_MESH_MANIFEST_SCHEMA: u32 = 4;
pub const STATIC_MESH_ARTIFACT_DIR: &str = "assets/meshes/generated";
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -39,11 +44,7 @@ pub struct StaticMeshSource {
pub dependencies: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct StaticMeshSourceFingerprint {
pub byte_len: u64,
pub modified_unix_secs: u64,
}
pub type StaticMeshSourceFingerprint = AssetSourceFingerprint;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct StaticMeshImportSnapshot {
@@ -80,6 +81,10 @@ pub struct StaticMeshPart {
pub source_node: Option<String>,
pub source_mesh: Option<String>,
pub source_material: Option<String>,
/// Whether the source primitive is bound to a skin and therefore must never become a static
/// renderer slot.
#[serde(default)]
pub skinned: bool,
}
pub fn static_mesh_manifest_path(asset_id: &str) -> String {
@@ -94,6 +99,17 @@ pub fn material_id_from_label(label: &str) -> String {
format!("material:{}", stable_sub_asset_slug(label))
}
fn gltf_draw_id(node_index: Option<usize>, mesh_index: usize, primitive_index: usize) -> String {
let node = node_index
.map(|index| index.to_string())
.unwrap_or_else(|| "unbound".into());
format!("draw:scene0:node{node}:mesh{mesh_index}:primitive{primitive_index}")
}
fn fbx_draw_id(node_index: usize, material_index: usize) -> String {
format!("draw:scene0:node{node_index}:material{material_index}")
}
fn stable_sub_asset_slug(label: &str) -> String {
let mut slug = String::new();
for ch in label.chars() {
@@ -116,16 +132,9 @@ pub fn refresh_static_mesh_artifact(
manifest.source.dependencies.dedup();
record.dependencies = manifest.source.dependencies.clone();
let text = ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default())
.map_err(|err| format!("could not serialize static mesh manifest: {err}"))?;
if let Some(parent) = Path::new(&path).parent() {
fs::create_dir_all(parent)
.map_err(|err| format!("could not create {}: {err}", parent.display()))?;
}
let should_write = fs::read_to_string(&path).ok().as_deref() != Some(text.as_str());
if should_write {
fs::write(&path, text)
.map_err(|err| format!("could not write static mesh manifest {path}: {err}"))?;
if write_pretty_ron_if_changed(&path, &manifest)
.map_err(|error| format!("could not publish static mesh manifest {path}: {error}"))?
{
info!(
"Static mesh manifest refreshed: source={} artifact={} parts={}",
record.path,
@@ -151,38 +160,106 @@ pub fn renderer_from_manifest(
MaterialImportPolicy::SourceMaterials
);
StaticMeshRenderer {
let parts: Vec<_> = manifest
.parts
.iter()
.filter(|part| !part.skinned && manifest.metadata.animation_count == 0)
.map(|part| StaticMeshRendererEntry {
id: ComponentInstanceId::new(part_effective_id(part)),
name: part.name.clone(),
mesh: EditorAssetRef::new(
manifest.asset_id.clone(),
part_effective_id(part),
part.name.clone(),
),
material_slot_id: ComponentInstanceId::new(material_slot_id(part)),
material: use_source_materials
.then(|| {
part_effective_material_id(part).map(|id| {
EditorAssetRef::new(
manifest.asset_id.clone(),
id,
part.material_slot_name.clone(),
)
})
})
.flatten(),
local_transform: part.local_transform,
visible: true,
cast_shadows: true,
receive_shadows: true,
})
.collect();
let materials = RendererMaterialSet {
slots: manifest
.parts
.iter()
.map(|part| StaticMeshRendererEntry {
id: ComponentInstanceId::new(part_effective_id(part)),
name: part.name.clone(),
mesh: EditorAssetRef::new(
manifest.asset_id.clone(),
part_effective_id(part),
part.name.clone(),
),
material: use_source_materials
.filter(|part| !part.skinned && manifest.metadata.animation_count == 0)
.map(|part| RendererMaterialSlot {
id: ComponentInstanceId::new(material_slot_id(part)),
name: part.material_slot_name.clone(),
source_material: use_source_materials
.then(|| {
part_effective_material_id(part).map(|id| {
EditorAssetRef::new(
MaterialRef::new(EditorAssetRef::new(
manifest.asset_id.clone(),
id,
part.material_slot_name.clone(),
)
))
})
})
.flatten(),
local_transform: part.local_transform,
visible: true,
cast_shadows: true,
receive_shadows: true,
material: None,
})
.collect(),
orphaned_assignments: Vec::new(),
};
StaticMeshRenderer {
slots: parts,
materials,
}
}
/// Builds the shared material slots for a full imported hierarchy. Unlike static renderer
/// construction this intentionally includes skin-bound and rigid animated draw bindings.
pub fn renderer_materials_from_manifest(
manifest: &StaticMeshManifest,
settings: &ImportSettings,
) -> RendererMaterialSet {
let use_source_materials = matches!(
settings.material_policy,
MaterialImportPolicy::SourceMaterials
);
RendererMaterialSet {
slots: manifest
.parts
.iter()
.map(|part| RendererMaterialSlot {
id: ComponentInstanceId::new(material_slot_id(part)),
name: part.material_slot_name.clone(),
source_material: use_source_materials
.then(|| {
part_effective_material_id(part).map(|id| {
MaterialRef::new(EditorAssetRef::new(
manifest.asset_id.clone(),
id,
part.material_slot_name.clone(),
))
})
})
.flatten(),
material: None,
})
.collect(),
orphaned_assignments: Vec::new(),
}
}
fn material_slot_id(part: &StaticMeshPart) -> String {
format!("slot:{}", part_effective_id(part))
}
fn part_effective_id(part: &StaticMeshPart) -> String {
if part.id.trim().is_empty() {
part_id_from_label(&part.mesh_label)
@@ -201,7 +278,7 @@ fn part_effective_material_id(part: &StaticMeshPart) -> Option<String> {
fn build_static_mesh_manifest(record: &AssetRecord) -> Result<StaticMeshManifest, String> {
let format = source_format(&record.path)?;
let fingerprint = source_fingerprint(&record.path)?;
let fingerprint = fingerprint_file(&record.path)?;
let import = StaticMeshImportSnapshot {
scale: record.import_settings.scale,
generate_collider: record.import_settings.generate_collider,
@@ -255,23 +332,23 @@ fn build_gltf_manifest(
.or_else(|| gltf.document.scenes().next())
{
for node in scene.nodes() {
collect_gltf_node_parts(node, Mat4::IDENTITY, &mut parts);
collect_gltf_node_parts(node, Mat4::IDENTITY, "", &mut parts);
}
} else {
for mesh in gltf.document.meshes() {
collect_gltf_mesh_parts(None, None, mesh, Mat4::IDENTITY, &mut parts);
collect_gltf_mesh_parts(None, None, None, mesh, Mat4::IDENTITY, false, &mut parts);
}
}
if gltf.document.animations().count() > 0 {
warnings.push(
"Animations are recorded as metadata; use Scene Instance placement for playback."
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer."
.into(),
);
}
if gltf.document.skins().count() > 0 {
warnings.push(
"Skins are recorded as metadata; skinned playback stays on the Scene Instance path."
"Skinned primitives are excluded from StaticMeshRenderer and use SkinnedMeshRenderer."
.into(),
);
}
@@ -306,29 +383,44 @@ fn build_gltf_manifest(
fn collect_gltf_node_parts(
node: gltf::Node<'_>,
parent_transform: Mat4,
parent_path: &str,
parts: &mut Vec<StaticMeshPart>,
) {
let local = Mat4::from_cols_array_2d(&node.transform().matrix());
let world_transform = parent_transform * local;
let segment = node
.name()
.map(str::to_string)
.unwrap_or_else(|| format!("Node{}", node.index()));
let node_path = if parent_path.is_empty() {
segment
} else {
format!("{parent_path}/{segment}")
};
let skinned = node.skin().is_some();
if let Some(mesh) = node.mesh() {
collect_gltf_mesh_parts(
node.name().map(str::to_string),
Some(node.index()),
Some(node_path.clone()),
mesh,
world_transform,
skinned,
parts,
);
}
for child in node.children() {
collect_gltf_node_parts(child, world_transform, parts);
collect_gltf_node_parts(child, world_transform, &node_path, parts);
}
}
fn collect_gltf_mesh_parts(
node_name: Option<String>,
node_index: Option<usize>,
node_path: Option<String>,
mesh: gltf::Mesh<'_>,
transform: Mat4,
skinned: bool,
parts: &mut Vec<StaticMeshPart>,
) {
let mesh_index = mesh.index();
@@ -359,9 +451,11 @@ fn collect_gltf_mesh_parts(
.clone()
.or_else(|| mesh_name.clone())
.unwrap_or_else(|| format!("Mesh {mesh_index}"));
let source_node = node_index.map(|index| format!("Node{index}"));
let source_node = node_path
.clone()
.or_else(|| node_index.map(|index| format!("Node{index}")));
parts.push(StaticMeshPart {
id: part_id_from_label(&mesh_label),
id: gltf_draw_id(node_index, mesh_index, primitive_index),
name: format!("{name} / Primitive {primitive_index}"),
material_id: material_label
.as_ref()
@@ -373,6 +467,7 @@ fn collect_gltf_mesh_parts(
source_node,
source_mesh: Some(format!("Mesh{mesh_index}")),
source_material: Some(material_name),
skinned,
});
}
}
@@ -390,6 +485,7 @@ fn build_fbx_manifest(
ufbx::LoadOpts {
target_unit_meters: 1.0,
target_axes: ufbx::CoordinateAxes::right_handed_y_up(),
filename: ufbx::StringOpt::Ref(&record.path),
..Default::default()
},
)
@@ -405,6 +501,7 @@ fn build_fbx_manifest(
if mesh.num_vertices == 0 || mesh.faces.as_ref().is_empty() {
continue;
}
let skinned = !mesh.skin_deformers.as_ref().is_empty();
let mut groups: Vec<(usize, Vec<u32>)> =
group_faces_by_material(mesh).into_iter().collect();
@@ -428,7 +525,7 @@ fn build_fbx_manifest(
};
let mesh_label = FbxAssetLabel::Mesh(node_index * 1000 + material_index).to_string();
parts.push(StaticMeshPart {
id: part_id_from_label(&mesh_label),
id: fbx_draw_id(node_index, material_index),
name: format!("{node_name} / Material {material_index}"),
material_id: material_label
.as_ref()
@@ -440,19 +537,20 @@ fn build_fbx_manifest(
source_node: Some(format!("Node{node_index}")),
source_mesh: Some(format!("Mesh{node_index}")),
source_material: Some(material_name),
skinned,
});
}
}
if !scene.anim_stacks.as_ref().is_empty() {
warnings.push(
"Animations are recorded as metadata; use Scene Instance placement for playback."
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer."
.into(),
);
}
if !scene.skin_deformers.as_ref().is_empty() {
warnings.push(
"Skins are recorded as metadata; skinned playback stays on the Scene Instance path."
"Skinned primitives are excluded from StaticMeshRenderer and use SkinnedMeshRenderer."
.into(),
);
}
@@ -467,7 +565,7 @@ fn build_fbx_manifest(
path: record.path.clone(),
format,
fingerprint,
dependencies: fbx_dependencies(&record.path),
dependencies: fbx_dependencies(&record.path, &scene)?,
},
import,
metadata: StaticMeshMetadata {
@@ -496,25 +594,26 @@ fn fbx_material_label(scene: &ufbx::Scene, element_id: u32) -> Option<String> {
.map(|index| FbxAssetLabel::Material(index).to_string())
}
fn fbx_dependencies(source_path: &str) -> Vec<String> {
fn fbx_dependencies(source_path: &str, scene: &ufbx::Scene) -> Result<Vec<String>, String> {
let path = Path::new(source_path);
let Some(stem) = path.file_stem().and_then(|stem| stem.to_str()) else {
return Vec::new();
};
let Some(parent) = path.parent() else {
return Vec::new();
};
let sidecar = parent.join(format!("{stem}.fbm"));
if !sidecar.is_dir() {
return Vec::new();
}
walkdir::WalkDir::new(sidecar)
.follow_links(false)
.into_iter()
.filter_map(Result::ok)
.filter(|entry| entry.file_type().is_file())
.map(|entry| entry.path().to_string_lossy().replace('\\', "/"))
.collect()
let parent = path.parent().unwrap_or_else(|| Path::new(""));
external_texture_paths(scene)
.map_err(|errors| {
format!(
"unsafe FBX texture reference(s) in {source_path}: {}",
errors
.into_iter()
.map(|error| error.to_string())
.collect::<Vec<_>>()
.join("; ")
)
})
.map(|paths| {
paths
.into_iter()
.map(|relative| parent.join(relative).to_string_lossy().replace('\\', "/"))
.collect()
})
}
fn source_format(path: &str) -> Result<String, String> {
@@ -525,20 +624,6 @@ fn source_format(path: &str) -> Result<String, String> {
.ok_or_else(|| format!("asset path `{path}` has no extension"))
}
fn source_fingerprint(path: &str) -> Result<StaticMeshSourceFingerprint, String> {
let metadata = fs::metadata(path).map_err(|err| format!("could not stat {path}: {err}"))?;
let modified_unix_secs = metadata
.modified()
.ok()
.and_then(|time| time.duration_since(UNIX_EPOCH).ok())
.map(|duration| duration.as_secs())
.unwrap_or_default();
Ok(StaticMeshSourceFingerprint {
byte_len: metadata.len(),
modified_unix_secs,
})
}
fn resolve_dependency(source_path: &str, uri: &str) -> String {
if uri.starts_with("data:") || uri.contains("://") {
return uri.to_string();
@@ -554,6 +639,7 @@ fn resolve_dependency(source_path: &str, uri: &str) -> String {
#[cfg(test)]
mod tests {
use super::*;
use crate::asset_db::AssetId;
fn test_manifest() -> StaticMeshManifest {
StaticMeshManifest {
@@ -565,7 +651,7 @@ mod tests {
format: "glb".into(),
fingerprint: StaticMeshSourceFingerprint {
byte_len: 42,
modified_unix_secs: 10,
content_hash: "a".repeat(64),
},
dependencies: Vec::new(),
},
@@ -597,6 +683,7 @@ mod tests {
source_node: Some("Node0".into()),
source_mesh: Some("Mesh0".into()),
source_material: Some("Wood".into()),
skinned: false,
}],
warnings: Vec::new(),
}
@@ -633,6 +720,55 @@ mod tests {
);
}
#[test]
fn schema_v3_manifest_without_hash_migrates_to_content_fingerprint() {
let root = std::env::temp_dir().join(format!(
"blacksite-static-mesh-legacy-{}",
uuid::Uuid::new_v4()
));
fs::create_dir_all(&root).unwrap();
let path = root.join("legacy.static_mesh.ron");
let expected = test_manifest();
let canonical =
ron::ser::to_string_pretty(&expected, ron::ser::PrettyConfig::default()).unwrap();
let legacy = canonical
.replacen("schema_version: 4", "schema_version: 3", 1)
.lines()
.filter(|line| !line.contains("content_hash:"))
.collect::<Vec<_>>()
.join("\n");
fs::write(&path, legacy).unwrap();
assert!(write_pretty_ron_if_changed(&path, &expected).unwrap());
assert_eq!(
load_static_mesh_manifest(&path.to_string_lossy()).unwrap(),
expected
);
fs::remove_dir_all(root).unwrap();
}
#[test]
fn equivalent_static_manifest_preserves_existing_formatting_and_newline() {
let root = std::env::temp_dir().join(format!(
"blacksite-static-mesh-semantic-{}",
uuid::Uuid::new_v4()
));
fs::create_dir_all(&root).unwrap();
let path = root.join("stable.static_mesh.ron");
let manifest = test_manifest();
let exact = format!(
"{}\n\n",
ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default()).unwrap()
);
fs::write(&path, &exact).unwrap();
assert!(!write_pretty_ron_if_changed(&path, &manifest).unwrap());
assert_eq!(fs::read_to_string(&path).unwrap(), exact);
fs::remove_dir_all(root).unwrap();
}
#[test]
fn renderer_from_manifest_can_ignore_source_materials() {
let manifest = test_manifest();
@@ -645,4 +781,75 @@ mod tests {
assert!(renderer.slots[0].material.is_none());
}
#[test]
fn renderer_from_manifest_excludes_skinned_primitives() {
let mut manifest = test_manifest();
manifest.parts[0].skinned = true;
let renderer = renderer_from_manifest(&manifest, &ImportSettings::default());
assert!(renderer.slots.is_empty());
}
#[test]
fn renderer_from_manifest_excludes_node_animated_geometry() {
let mut manifest = test_manifest();
manifest.metadata.animation_count = 1;
let renderer = renderer_from_manifest(&manifest, &ImportSettings::default());
assert!(renderer.slots.is_empty());
}
#[test]
fn committed_rigged_fixture_never_builds_static_renderer_slots() {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/models/robot_expressive.glb")
.to_string_lossy()
.into_owned();
let record = AssetRecord {
id: AssetId::new(),
path,
label: "Robot Expressive".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
};
let manifest = build_static_mesh_manifest(&record).unwrap();
let renderer = renderer_from_manifest(&manifest, &record.import_settings);
assert!(manifest.metadata.skin_count > 0);
assert!(manifest.metadata.animation_count > 0);
assert!(manifest.parts.iter().any(|part| part.skinned));
assert!(renderer.slots.is_empty());
}
#[test]
fn committed_fbx_records_sibling_texture_dependencies() {
let path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/models/painted_wooden_chair_02_2k.fbx")
.to_string_lossy()
.into_owned();
let record = AssetRecord {
id: AssetId::new(),
path,
label: "Painted Chair".into(),
kind_tag: "Model".into(),
source_fingerprint: None,
import_settings: ImportSettings::default(),
dependencies: Vec::new(),
};
let manifest = build_static_mesh_manifest(&record).unwrap();
assert_eq!(manifest.source.dependencies.len(), 3);
assert!(manifest
.source
.dependencies
.iter()
.all(|path| path.contains("assets/models/textures/painted_wooden_chair_02_")));
}
}
+154 -6
View File
@@ -1,7 +1,9 @@
//! Thumbnail cache for asset browser grid cells.
use std::collections::{HashMap, HashSet};
use std::path::Path;
use bevy::asset::LoadState;
use bevy::prelude::*;
use bevy_egui::{egui, EguiPrimaryContextPass, EguiTextureHandle, EguiUserTextures};
use egui_phosphor_icons::icons;
@@ -79,6 +81,9 @@ impl AssetThumbnailCache {
if self.failed.contains_key(&key) {
return;
}
if !self.texture_source_ready(&key, &path) {
return;
}
let handle: Handle<Image> = asset_server.load(asset_server_path(&path));
self.pending.insert(key, handle);
}
@@ -161,7 +166,7 @@ impl AssetThumbnailCache {
{
return;
}
if !self.model_source_ready(&key, &model_path) {
if !self.source_material_ready(&key, &model_path) {
return;
}
if studio.enqueue_source(
@@ -188,18 +193,24 @@ impl AssetThumbnailCache {
{
return;
}
let material = match shared::MaterialAsset::load_from_path(&path) {
Ok(asset) => asset,
let material = match shared::load_resolved_material_from_path(&path) {
Ok((material, _)) => material,
Err(error) => {
self.mark_studio_failed(&key, &error, true);
return;
}
};
let label = shared::MaterialAsset::load_from_path(&path)
.map(|asset| asset.label)
.or_else(|_| {
shared::MaterialInstanceAsset::load_from_path(&path).map(|asset| asset.label)
})
.unwrap_or_else(|_| "Material".into());
if studio.enqueue_source(
key.clone(),
ThumbnailJobSource::MaterialAsset {
label: material.label.clone(),
material: Box::new(material.material),
label,
material: Box::new(material),
},
) {
self.studio_pending.insert(key);
@@ -218,6 +229,32 @@ impl AssetThumbnailCache {
true
}
fn texture_source_ready(&mut self, key: &str, texture_path: &str) -> bool {
if Path::new(texture_path).is_file() {
return true;
}
self.mark_studio_failed(key, &format!("missing texture: {texture_path}"), false);
false
}
fn source_material_ready(&mut self, key: &str, model_path: &str) -> bool {
if !self.model_source_ready(key, model_path) {
return false;
}
if model_path
.rsplit_once('.')
.is_some_and(|(_, extension)| extension.eq_ignore_ascii_case("fbx"))
{
if let Err(reason) =
crate::assets::import::validate_fbx_dependencies(std::path::Path::new(model_path))
{
self.mark_studio_failed(key, &reason, false);
return false;
}
}
true
}
pub(crate) fn complete_studio_thumbnail(
&mut self,
key: &str,
@@ -262,6 +299,11 @@ impl AssetThumbnailCache {
.cloned()
.collect(),
failed_keys: self.failed.keys().cloned().collect(),
failure_reasons: self
.failed
.iter()
.map(|(key, failure)| (key.clone(), failure.reason.clone()))
.collect(),
}
}
}
@@ -271,6 +313,14 @@ fn register_loaded_thumbnails(
mut cache: ResMut<AssetThumbnailCache>,
mut textures: ResMut<EguiUserTextures>,
) {
let failed: Vec<(String, String)> = cache
.pending
.iter()
.filter_map(|(key, handle)| match asset_server.load_state(handle.id()) {
LoadState::Failed(error) => Some((key.clone(), error.to_string())),
_ => None,
})
.collect();
let ready: Vec<(String, Handle<Image>)> = cache
.pending
.iter()
@@ -278,6 +328,10 @@ fn register_loaded_thumbnails(
.map(|(key, handle)| (key.clone(), handle.clone()))
.collect();
for (key, error) in failed {
cache.mark_studio_failed(&key, &format!("texture load failed: {error}"), false);
}
for (key, handle) in ready {
cache.pending.remove(&key);
cache.failed.remove(&key);
@@ -391,7 +445,11 @@ pub fn draw_asset_cell_with(
},
);
response
if let Some(reason) = failed {
response.on_hover_text(reason)
} else {
response
}
}
#[derive(Clone)]
@@ -399,6 +457,7 @@ pub struct ThumbnailCacheSnapshot {
pub texture_ids: HashMap<String, egui::TextureId>,
pub pending_keys: Vec<String>,
pub failed_keys: Vec<String>,
pub failure_reasons: HashMap<String, String>,
}
impl ThumbnailCacheSnapshot {
@@ -414,6 +473,10 @@ impl ThumbnailCacheSnapshot {
self.failed_keys.iter().any(|failed| failed == key)
}
pub fn failure_reason_for_key(&self, key: &str) -> Option<&str> {
self.failure_reasons.get(key).map(String::as_str)
}
pub fn texture_for(&self, asset: &EditorAsset) -> Option<egui::TextureId> {
self.texture_ids.get(&asset_cache_key(asset)).copied()
}
@@ -429,6 +492,10 @@ impl ThumbnailCacheSnapshot {
.iter()
.any(|key| key == &asset_cache_key(asset))
}
pub fn failure_reason(&self, asset: &EditorAsset) -> Option<&str> {
self.failure_reason_for_key(&asset_cache_key(asset))
}
}
pub fn prefetch_folder_thumbnails(world: &mut World, folder: &str) {
@@ -482,6 +549,37 @@ pub fn prefetch_folder_thumbnails(world: &mut World, folder: &str) {
.prefetched_folder = Some(folder.to_string());
}
/// Requests thumbnails for an explicit cross-folder asset set.
pub fn prefetch_asset_thumbnails(world: &mut World, assets: &[EditorAsset]) {
let requests = assets
.iter()
.filter_map(|asset| {
Some((
asset_cache_key(asset),
asset.path.clone()?,
asset.kind.clone(),
))
})
.collect::<Vec<_>>();
let asset_server = world.resource::<AssetServer>().clone();
world.resource_scope(|world, mut cache: Mut<AssetThumbnailCache>| {
world.resource_scope(|_world, mut studio: Mut<ThumbnailStudio>| {
for (key, path, kind) in requests {
match kind {
EditorAssetKind::Texture => cache.request_texture(key, path, &asset_server),
EditorAssetKind::Model => {
cache.request_model(key, path, &asset_server, &mut studio)
}
EditorAssetKind::Material => {
cache.request_material_asset(key, path, &mut studio)
}
_ => {}
}
}
});
});
}
pub fn invalidate_on_catalog_refresh(world: &mut World) {
world.resource_mut::<AssetThumbnailCache>().invalidate_all();
if !world.contains_resource::<ThumbnailStudio>() {
@@ -497,3 +595,53 @@ pub fn invalidate_on_catalog_refresh(world: &mut World) {
world.commands().entity(root).despawn();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn missing_fbx_material_dependencies_are_one_stable_non_retryable_state() {
let model_path = Path::new(env!("CARGO_MANIFEST_DIR"))
.join("../../assets/models/painted_wooden_chair_02_2k.fbx")
.to_string_lossy()
.into_owned();
let mut cache = AssetThumbnailCache::default();
assert!(cache.model_source_ready("model", &model_path));
assert!(!cache.source_material_ready("material", &model_path));
let first = cache.state("material");
assert!(!cache.source_material_ready("material", &model_path));
assert_eq!(cache.state("material"), first);
let Some(ThumbnailState::Failed { reason, retryable }) = first else {
panic!("missing FBX textures should produce one stable failure");
};
assert!(!retryable);
assert!(reason.starts_with("missing 3 FBX source texture(s):"));
assert!(cache.studio_pending.is_empty());
}
#[test]
fn missing_texture_is_one_stable_non_retryable_state() {
let path = std::env::temp_dir().join(format!(
"blacksite-missing-thumbnail-{}-{}.png",
std::process::id(),
std::thread::current().name().unwrap_or("test")
));
let path = path.to_string_lossy().into_owned();
let mut cache = AssetThumbnailCache::default();
assert!(!cache.texture_source_ready("texture", &path));
let first = cache.state("texture");
assert!(!cache.texture_source_ready("texture", &path));
assert_eq!(cache.state("texture"), first);
let Some(ThumbnailState::Failed { reason, retryable }) = first else {
panic!("missing texture should produce one stable failure");
};
assert!(!retryable);
assert_eq!(reason, format!("missing texture: {path}"));
assert!(cache.pending.is_empty());
}
}
+3 -2
View File
@@ -8,8 +8,9 @@ mod sources;
mod studio;
pub use cache::{
draw_asset_cell_with, invalidate_on_catalog_refresh, kind_icon, prefetch_folder_thumbnails,
AssetThumbnailCache, AssetThumbnailsPlugin, ThumbnailCacheSnapshot, ThumbnailState,
draw_asset_cell_with, invalidate_on_catalog_refresh, kind_icon, prefetch_asset_thumbnails,
prefetch_folder_thumbnails, AssetThumbnailCache, AssetThumbnailsPlugin, ThumbnailCacheSnapshot,
ThumbnailState,
};
pub use job::{ThumbnailJob, ThumbnailJobSource};
pub use sources::{
@@ -83,6 +83,72 @@ impl ThumbnailModelSource for FbxThumbnailSource {
}
}
pub(crate) fn spawn_fbx_mesh_subasset_preview(
commands: &mut Commands,
meshes: &mut Assets<Mesh>,
materials: &mut Assets<StandardMaterial>,
root: Entity,
catalog_path: &str,
mesh_label: &str,
) -> bool {
let Some(encoded_index) = mesh_label
.strip_prefix("Mesh")
.and_then(|index| index.parse::<usize>().ok())
else {
warn!("FBX thumbnail: unsupported mesh label {mesh_label}");
return false;
};
let node_index = encoded_index / 1000;
let material_index = encoded_index % 1000;
let Ok(bytes) = std::fs::read(catalog_path) else {
warn!("FBX thumbnail: could not read {catalog_path}");
return false;
};
let Ok(scene) = ufbx::load_memory(
&bytes,
ufbx::LoadOpts {
target_unit_meters: 1.0,
target_axes: ufbx::CoordinateAxes::right_handed_y_up(),
..Default::default()
},
) else {
warn!("FBX thumbnail: failed to parse {catalog_path}");
return false;
};
let Some(node) = scene.nodes.as_ref().get(node_index) else {
warn!("FBX thumbnail: mesh label {mesh_label} has no source node");
return false;
};
let Some(mesh_ref) = node.mesh.as_ref() else {
warn!("FBX thumbnail: mesh label {mesh_label} has no source mesh");
return false;
};
let Some(indices) = group_faces_by_material(mesh_ref.as_ref()).remove(&material_index) else {
warn!("FBX thumbnail: mesh label {mesh_label} has no material group");
return false;
};
if indices.is_empty() {
return false;
}
let mesh = meshes.add(build_mesh(mesh_ref.as_ref(), &indices));
let material = materials.add(StandardMaterial {
base_color: Color::srgb(0.72, 0.72, 0.75),
perceptual_roughness: 0.65,
..default()
});
let transform = Transform::from_matrix(convert_matrix(&node.geometry_to_world));
commands.entity(root).with_children(|parent| {
parent.spawn((
RenderLayers::layer(THUMBNAIL_LAYER),
Mesh3d(mesh),
MeshMaterial3d(material),
transform,
));
});
true
}
fn build_mesh(ufbx_mesh: &ufbx::Mesh, indices: &[u32]) -> Mesh {
let mut mesh = Mesh::new(
PrimitiveTopology::TriangleList,
@@ -3,6 +3,7 @@
mod fbx;
pub(crate) mod gltf;
pub(crate) use fbx::spawn_fbx_mesh_subasset_preview;
pub use fbx::FbxThumbnailSource;
pub use gltf::{gltf_skinned_primitive_labels, GltfThumbnailSource};
+117 -14
View File
@@ -15,14 +15,19 @@ use shared::{material_from_desc, standard_material_asset_path, ModelRef};
use super::cache::AssetThumbnailCache;
use super::job::{ThumbnailJob, ThumbnailJobSource};
use super::sources::{source_for_extension, uses_scene_root};
use super::sources::{source_for_extension, spawn_fbx_mesh_subasset_preview, uses_scene_root};
use crate::assets::asset_server_path;
use crate::infra::EditorOnly;
pub(crate) const THUMB_SIZE: u32 = 128;
pub(crate) const THUMBNAIL_LAYER: usize = 31;
const THUMBNAIL_VERTICAL_FOV: f32 = 40.0_f32.to_radians();
const THUMBNAIL_HALF_VERTICAL_FOV: f32 = THUMBNAIL_VERTICAL_FOV * 0.5;
const SCENE_FRAME_PADDING: f32 = 1.35;
const MATERIAL_SPHERE_FRAME_PADDING: f32 = 1.28;
const MESH_WARMUP_FRAMES: u8 = 12;
const POST_ATTACH_FRAMES: u8 = 8;
const FIRST_RENDER_WARMUP_FRAMES: u8 = 120;
const RENDER_FRAMES: u8 = 3;
const COOLDOWN_FRAMES: u8 = 2;
const LOAD_TIMEOUT_FRAMES: u32 = 240;
@@ -47,6 +52,7 @@ pub struct ThumbnailStudio {
queue: VecDeque<ThumbnailJob>,
active: Option<ActiveModelThumbnail>,
cooldown_frames: u8,
render_pipeline_warmed: bool,
}
struct ActiveModelThumbnail {
@@ -61,6 +67,25 @@ struct ActiveModelThumbnail {
framed: bool,
frames_remaining: u8,
wait_frames: u32,
framing: ThumbnailFraming,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
enum ThumbnailFraming {
SceneBounds,
MaterialSphere,
}
impl ThumbnailFraming {
fn for_source(source: &ThumbnailJobSource) -> Self {
match source {
ThumbnailJobSource::SourceMaterial { .. }
| ThumbnailJobSource::MaterialAsset { .. } => Self::MaterialSphere,
ThumbnailJobSource::Model { .. } | ThumbnailJobSource::MeshSubAsset { .. } => {
Self::SceneBounds
}
}
}
}
pub struct ThumbnailStudioPlugin;
@@ -143,7 +168,7 @@ fn setup_thumbnail_studio(mut commands: Commands, mut images: ResMut<Assets<Imag
RenderTarget::Image(render_image.clone().into()),
Transform::from_xyz(2.0, 1.4, 2.0).looking_at(Vec3::new(0.0, 0.5, 0.0), Vec3::Y),
Projection::Perspective(PerspectiveProjection {
fov: 40.0_f32.to_radians(),
fov: THUMBNAIL_VERTICAL_FOV,
..default()
}),
))
@@ -186,6 +211,7 @@ fn setup_thumbnail_studio(mut commands: Commands, mut images: ResMut<Assets<Imag
queue: VecDeque::new(),
active: None,
cooldown_frames: 0,
render_pipeline_warmed: false,
});
}
@@ -229,6 +255,7 @@ fn process_thumbnail_studio(
&mesh3d,
&mesh_storage,
&mut camera_transforms,
active.framing,
) {
active.framed = true;
active.post_attach_frames = 0;
@@ -264,7 +291,7 @@ fn process_thumbnail_studio(
camera.is_active = true;
}
active.camera_active = true;
active.frames_remaining = RENDER_FRAMES;
active.frames_remaining = capture_frames(studio.render_pipeline_warmed);
}
studio.active = Some(active);
return;
@@ -275,6 +302,7 @@ fn process_thumbnail_studio(
active.frames_remaining -= 1;
studio.active = Some(active);
} else {
studio.render_pipeline_warmed = true;
cache.complete_studio_thumbnail(
&active.cache_key,
active.render_image.clone(),
@@ -322,6 +350,7 @@ fn process_thumbnail_studio(
.id();
let label = job.source.label().to_string();
let framing = ThumbnailFraming::for_source(&job.source);
let content_spawned = spawn_thumbnail_job_content(
&mut commands,
&mut mesh_storage,
@@ -350,6 +379,7 @@ fn process_thumbnail_studio(
framed: false,
frames_remaining: 0,
wait_frames: 0,
framing,
},
"no renderable meshes",
true,
@@ -369,6 +399,7 @@ fn process_thumbnail_studio(
framed: false,
frames_remaining: 0,
wait_frames: 0,
framing,
});
}
@@ -399,12 +430,15 @@ fn spawn_thumbnail_job_content(
material_label,
} => spawn_mesh_subasset_preview(
commands,
mesh_storage,
materials,
asset_server,
root,
model_path,
mesh_label,
material_label.as_deref(),
MeshSubassetPreviewSpec {
model_path,
mesh_label,
material_label: material_label.as_deref(),
},
),
ThumbnailJobSource::SourceMaterial {
model_path,
@@ -425,18 +459,38 @@ fn spawn_thumbnail_job_content(
}
}
struct MeshSubassetPreviewSpec<'a> {
model_path: &'a str,
mesh_label: &'a str,
material_label: Option<&'a str>,
}
fn spawn_mesh_subasset_preview(
commands: &mut Commands,
mesh_storage: &mut Assets<Mesh>,
materials: &mut Assets<StandardMaterial>,
asset_server: &AssetServer,
root: Entity,
model_path: &str,
mesh_label: &str,
material_label: Option<&str>,
preview: MeshSubassetPreviewSpec<'_>,
) -> bool {
let source_path = asset_server_path(model_path);
let mesh: Handle<Mesh> = asset_server.load(labeled_asset_path(&source_path, mesh_label));
let material = if let Some(material_label) = material_label {
if preview
.model_path
.rsplit_once('.')
.is_some_and(|(_, extension)| extension.eq_ignore_ascii_case("fbx"))
{
return spawn_fbx_mesh_subasset_preview(
commands,
mesh_storage,
materials,
root,
preview.model_path,
preview.mesh_label,
);
}
let source_path = asset_server_path(preview.model_path);
let mesh: Handle<Mesh> =
asset_server.load(labeled_asset_path(&source_path, preview.mesh_label));
let material = if let Some(material_label) = preview.material_label {
asset_server.load(standard_material_asset_path(&source_path, material_label))
} else {
materials.add(StandardMaterial {
@@ -482,6 +536,14 @@ fn studio_render_image() -> Image {
Image::new_target_texture(THUMB_SIZE, THUMB_SIZE, TextureFormat::Rgba16Float, None)
}
fn capture_frames(render_pipeline_warmed: bool) -> u8 {
if render_pipeline_warmed {
RENDER_FRAMES
} else {
FIRST_RENDER_WARMUP_FRAMES
}
}
fn finish_active_thumbnail(
commands: &mut Commands,
studio: &mut ThumbnailStudio,
@@ -588,6 +650,7 @@ fn frame_thumbnail_scene(
meshes: &Query<&Mesh3d>,
mesh_assets: &Assets<Mesh>,
camera_transforms: &mut Query<&mut Transform, With<ThumbnailStudioCamera>>,
framing: ThumbnailFraming,
) -> bool {
let mut entities = Vec::new();
collect_descendants(root, children, &mut entities);
@@ -633,8 +696,7 @@ fn frame_thumbnail_scene(
}
let center = (min + max) * 0.5;
let radius = (max - min).length().max(0.25) * 0.5;
let distance = radius / (20.0_f32.to_radians()).tan() * 1.35;
let distance = thumbnail_camera_distance(min, max, framing);
let eye = center + Vec3::new(1.0, 0.75, 1.0).normalize() * distance;
if let Ok(mut transform) = camera_transforms.single_mut() {
@@ -644,6 +706,20 @@ fn frame_thumbnail_scene(
true
}
fn thumbnail_camera_distance(min: Vec3, max: Vec3, framing: ThumbnailFraming) -> f32 {
let bounds_size = max - min;
let (radius, padding) = match framing {
ThumbnailFraming::SceneBounds => {
(bounds_size.length().max(0.25) * 0.5, SCENE_FRAME_PADDING)
}
ThumbnailFraming::MaterialSphere => (
bounds_size.max_element().max(0.5) * 0.5,
MATERIAL_SPHERE_FRAME_PADDING,
),
};
radius / THUMBNAIL_HALF_VERTICAL_FOV.tan() * padding
}
fn collect_descendants(entity: Entity, children: &Query<&Children>, out: &mut Vec<Entity>) {
out.push(entity);
let Ok(child_list) = children.get(entity) else {
@@ -673,3 +749,30 @@ fn aabb_corners(aabb: &Aabb3d) -> [Vec3; 8] {
pub fn model_file_exists(catalog_path: &str) -> bool {
Path::new(catalog_path).is_file()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn material_sphere_framing_fills_more_of_the_thumbnail_with_padding() {
let sphere_radius = 0.65;
let min = Vec3::splat(-sphere_radius);
let max = Vec3::splat(sphere_radius);
let scene_distance = thumbnail_camera_distance(min, max, ThumbnailFraming::SceneBounds);
let material_distance =
thumbnail_camera_distance(min, max, ThumbnailFraming::MaterialSphere);
let projected_radius_fraction =
sphere_radius / (material_distance * THUMBNAIL_HALF_VERTICAL_FOV.tan());
assert!(material_distance < scene_distance * 0.6);
assert!((0.75..0.82).contains(&projected_radius_fraction));
}
#[test]
fn first_capture_keeps_camera_active_for_render_pipeline_warmup() {
assert_eq!(capture_frames(true), RENDER_FRAMES);
assert!(capture_frames(false) > capture_frames(true));
}
}
+340 -41
View File
@@ -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,17 +70,20 @@ 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))
}
}
/// Custom inspector body for level objects (game crates register via [`register_actor_inspector_section`]).
/// Custom inspector body for level objects (game crates register via
/// [`register_actor_inspector_section`]). Synchronous [`Self::ui`] callbacks run while
/// [`UiState`] is scoped out of `World`; implementations must not request that resource. Keep
/// extension-owned transient state in independently registered resources, use
/// [`crate::ui::request_ui_selection`] and [`crate::ui::request_editor_tab`] for host UI changes,
/// or defer other cross-panel work through extension-owned commands or events.
pub trait ActorInspectorSection: Send + Sync {
fn id(&self) -> &str;
fn title(&self) -> &str;
@@ -191,6 +194,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 +242,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 +251,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 +272,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 +294,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 +316,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 +337,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 +354,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 +385,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 +402,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 +424,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 +445,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 +466,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 +487,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 +504,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 +521,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 +539,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 +568,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 +617,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 +643,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 +699,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 +772,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);
}
}
+67 -3
View File
@@ -3,9 +3,10 @@ use std::path::PathBuf;
use bevy::prelude::*;
use shared::{
ActorId, ActorKind, ActorName, AnimationControllerDesc, AudioListenerDesc, AudioSourceDesc,
BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder, LightDesc, MaterialDesc,
MaterialOverride, ModelRef, ObjectiveMarker, PhysicsBody, PostProcessVolumeDesc,
PrefabInstance, PrefabRef, Primitive, RigidBodyDesc, SceneComposition, StaticMeshRenderer,
AuthoringComponentStates, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder, LightDesc,
MaterialDesc, MaterialOverride, ModelRef, NavigationArea, NavigationBounds, NavigationLink,
NavigationObstacle, ObjectiveMarker, PhysicsBody, PostProcessVolumeDesc, PrefabInstance,
PrefabRef, Primitive, RigidBodyDesc, SceneComposition, SkinnedMeshRenderer, StaticMeshRenderer,
TeamSpawn, TriggerVolume, WeaponSpawn,
};
#[derive(Debug, Clone)]
@@ -18,6 +19,7 @@ pub struct EditorEntitySnapshot {
pub primitive: Option<Primitive>,
pub brush: Option<BrushDesc>,
pub static_mesh_renderer: Option<StaticMeshRenderer>,
pub skinned_mesh_renderer: Option<SkinnedMeshRenderer>,
pub material: Option<MaterialDesc>,
pub material_override: Option<MaterialOverride>,
pub rigid_body: Option<RigidBodyDesc>,
@@ -36,11 +38,52 @@ pub struct EditorEntitySnapshot {
pub post_process_volume: Option<PostProcessVolumeDesc>,
pub team_spawn: Option<TeamSpawn>,
pub objective: Option<ObjectiveMarker>,
pub navigation_bounds: Option<NavigationBounds>,
pub navigation_obstacle: Option<NavigationObstacle>,
pub navigation_area: Option<NavigationArea>,
pub navigation_link: Option<NavigationLink>,
pub hierarchy_sibling_index: i32,
pub editor_visibility: EditorVisibility,
pub inspector_order: Option<InspectorOrder>,
pub component_states: Option<AuthoringComponentStates>,
pub children: Vec<EditorEntitySnapshot>,
}
/// One reflected component value used by registry-driven editor transactions.
/// `component_id` is stable; `type_path` is retained only to resolve Bevy's
/// reflection adapter for this build.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ReflectedComponentValue {
pub component_id: String,
pub type_path: String,
pub ron: String,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ComponentDelta {
pub component_id: String,
pub type_path: String,
pub before: Option<ReflectedComponentValue>,
pub after: Option<ReflectedComponentValue>,
}
/// An atomic add/remove/reset/paste operation. Requirements, dependent removals,
/// and the derived ActorKind hint can be represented as additional deltas.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ComponentTransaction {
pub entity: Entity,
pub label: &'static str,
pub deltas: Vec<ComponentDelta>,
}
#[derive(Debug, Clone, Default, PartialEq)]
pub struct NavigationComponentState {
pub bounds: Option<NavigationBounds>,
pub obstacle: Option<NavigationObstacle>,
pub area: Option<NavigationArea>,
pub link: Option<NavigationLink>,
}
#[derive(Debug, Clone)]
pub struct SiblingChange {
pub entity: Entity,
@@ -63,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>,
@@ -109,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>,
@@ -174,6 +228,11 @@ pub enum EditorCommand {
old: Option<PostProcessVolumeDesc>,
new: PostProcessVolumeDesc,
},
SetNavigation {
entity: Entity,
old: NavigationComponentState,
new: NavigationComponentState,
},
SetTransformGroup {
entities: Vec<Entity>,
olds: Vec<Transform>,
@@ -239,11 +298,13 @@ pub enum EditorCommand {
entity: Entity,
snapshot: EditorEntitySnapshot,
},
ComponentTransaction(ComponentTransaction),
}
impl EditorCommand {
pub fn label(&self) -> &'static str {
match self {
EditorCommand::GroupSelection { .. } => "Group Selection",
EditorCommand::Spawn { .. } => "Spawn",
EditorCommand::SpawnMany { .. } => "Spawn Brushes",
EditorCommand::Despawn { .. } => "Delete",
@@ -254,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",
@@ -266,6 +328,7 @@ impl EditorCommand {
EditorCommand::ApplyBrushCsg { .. } => "Brush CSG",
EditorCommand::SetStaticMeshRenderer { .. } => "Set Static Mesh Renderer",
EditorCommand::SetPostProcessVolume { .. } => "Set Post Process Volume",
EditorCommand::SetNavigation { .. } => "Set Navigation",
EditorCommand::SetTransformGroup { .. } => "Move Selection",
EditorCommand::Reparent { .. } => "Reparent",
EditorCommand::SetActorKind { .. } => "Set Actor Kind",
@@ -283,6 +346,7 @@ impl EditorCommand {
} => "Unpack Prefab Layer",
EditorCommand::AddComponent { .. } => "Add Component",
EditorCommand::RemoveComponent { .. } => "Remove Component",
EditorCommand::ComponentTransaction(transaction) => transaction.label,
}
}
}
File diff suppressed because it is too large. Load diff
+25 -1
View File
@@ -22,11 +22,15 @@ pub use ext::extensibility;
pub use ext::hot_reload;
pub use play::net_editor;
pub use play::state;
pub use project::collaboration;
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 project::shutdown;
pub use scene::scene_io;
pub use scene::scene_schema;
pub use scene::scene_view;
@@ -36,10 +40,14 @@ pub use viewport::brush_edit;
pub use viewport::brush_tool;
pub use viewport::camera;
pub use viewport::gizmos;
pub use viewport::material_drop;
pub use viewport::physics_placement;
pub use viewport::render_view;
pub use viewport::rendering_diagnostics;
pub use viewport::selection;
pub use viewport::selection_outline;
pub use viewport::terrain_paint;
pub use viewport::terrain_sculpt;
pub use viewport::visualizers;
use bevy::app::PluginGroupBuilder;
@@ -61,9 +69,15 @@ use extensibility::ExtensibilityPlugin;
use gizmos::EditorGizmoPlugin;
use history::EditorHistoryPlugin;
use infra::EditorInfraPlugin;
use material_drop::MaterialDropPlugin;
use operators::OperatorPlugin;
use physics_placement::PhysicsPlacementPlugin;
use play::audio_preview::AudioPreviewPlugin;
use play::PlaySessionPlugin;
use project::collaboration::CollaborationPlugin;
use project::native_dialog::NativeDialogPlugin;
use project::samples::SampleCatalogPlugin;
use project::shutdown::ShutdownPlugin;
use project_io::ProjectIoPlugin;
use render_view::RenderViewPlugin;
use scene_io::SceneIoPlugin;
@@ -73,6 +87,8 @@ use selection_outline::SelectionOutlinePlugin;
use session::EditorSessionPlugin;
use settings_ui::SettingsUiPlugin;
use state::EditorStatePlugin;
use terrain_paint::TerrainPaintPlugin;
use terrain_sculpt::TerrainSculptPlugin;
use ui::EditorUiPlugin;
use viewport::ViewportPlugin;
use visualizers::EditorVisualizersPlugin;
@@ -86,6 +102,9 @@ impl PluginGroup for EditorPluginGroup {
let group = PluginGroupBuilder::start::<Self>()
.add(EditorInfraPlugin)
.add(ProjectIoPlugin)
.add(SampleCatalogPlugin)
.add(NativeDialogPlugin)
.add(ShutdownPlugin)
.add(scene_schema::SceneSchemaPlugin)
.add(net_editor::NetEditorPlugin)
.add(AssetDbPlugin)
@@ -102,15 +121,20 @@ impl PluginGroup for EditorPluginGroup {
.add(BrushCsgPlugin)
.add(BrushEditPlugin)
.add(BrushToolPlugin)
.add(TerrainSculptPlugin)
.add(TerrainPaintPlugin)
.add(EditorCameraPlugin)
.add(AudioPreviewPlugin)
.add(ActorIconsPlugin)
.add(MaterialDropPlugin)
.add(PhysicsPlacementPlugin)
.add(EditorSelectionPlugin)
.add(SelectionOutlinePlugin)
.add(EditorGizmoPlugin)
.add(EditorVisualizersPlugin)
.add(EditorHistoryPlugin)
.add(SceneIoPlugin)
.add(CollaborationPlugin)
.add(EditorUiPlugin)
.add(EditorSessionPlugin)
.add(brp::BrpPlugin);
@@ -122,7 +146,7 @@ impl PluginGroup for EditorPluginGroup {
/// Shared Bevy app wiring for the in-process editor (game sim + egui shell).
pub fn configure_editor_app(app: &mut App) {
app.add_plugins(launch::default_plugins("Bevy FPS Editor"))
app.add_plugins(launch::editor_plugins("Bevy FPS Editor"))
.insert_resource(GameInputEnabled(false))
.insert_resource(GameInputFocused(false))
.insert_resource(SimEnabled(false))
+97
View File
@@ -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>()
+13 -4
View File
@@ -6,7 +6,10 @@ use bevy::window::WindowRef;
use game::player::PlayerCamera;
use protocol::PlayerInputIntent;
use settings::SimTuning;
use shared::{inspector_component_active, InspectorOrder, PlayerSpawn, COMPONENT_PLAYER_SPAWN};
use shared::{
authoring_component_active, AuthoringComponentStates, InspectorOrder, PlayerSpawn,
COMPONENT_PLAYER_SPAWN,
};
use sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
use crate::render_target::ViewportRenderTarget;
@@ -66,10 +69,16 @@ fn bootstrap_player_on_play(world: &mut World) {
.unwrap_or_else(|| SimTuning::from_physics(&settings::PhysicsSettings::default()));
let spawn = world
.query_filtered::<(&Transform, Option<&InspectorOrder>), With<PlayerSpawn>>()
.query_filtered::<(
&Transform,
Option<&AuthoringComponentStates>,
Option<&InspectorOrder>,
), With<PlayerSpawn>>()
.iter(world)
.filter(|(_, order)| inspector_component_active(*order, COMPONENT_PLAYER_SPAWN))
.map(|(transform, _)| transform)
.filter(|(_, states, legacy_order)| {
authoring_component_active(*states, *legacy_order, COMPONENT_PLAYER_SPAWN)
})
.map(|(transform, _, _)| transform)
.next()
.copied()
.unwrap_or_else(default_player_spawn);
+51 -3
View File
@@ -1,9 +1,12 @@
use std::time::Duration;
use avian3d::prelude::{Physics, PhysicsTime};
use bevy::prelude::*;
use bevy::window::{CursorGrabMode, CursorOptions, PrimaryWindow};
use bevy_egui::PrimaryEguiContext;
use game::player::PlayerCamera;
use game::{GameInputEnabled, GameInputFocused, SimEnabled};
use protocol::PlayerInputIntent;
use protocol::{PlayerInputIntent, SIM_TICK_RATE_HZ};
use sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
use crate::camera::EditorCamera;
@@ -195,6 +198,7 @@ pub(crate) fn sync_mode_resources_and_cameras(
mut step: ResMut<PlayStepOnce>,
mut input_enabled: ResMut<GameInputEnabled>,
mut sim_enabled: ResMut<SimEnabled>,
mut physics_time: ResMut<Time<Physics>>,
mut editor_cameras: Query<&mut Camera, With<EditorCamera>>,
mut player_cameras: Query<&mut Camera, (With<PlayerCamera>, Without<EditorCamera>)>,
mut egui_cameras: Query<
@@ -212,9 +216,11 @@ pub(crate) fn sync_mode_resources_and_cameras(
let ejected = playing && *possession == PlayPossession::Ejected;
let possessed = playing && *possession == PlayPossession::Possessed;
sim_enabled.0 = playing && (!paused.0 || step.0);
let stepping = step.0;
sim_enabled.0 = playing && (!paused.0 || stepping);
input_enabled.0 = possessed && !paused.0;
if step.0 {
sync_editor_physics_clock(&mut physics_time, playing, paused.0, stepping);
if stepping {
step.0 = false;
}
@@ -240,6 +246,22 @@ pub(crate) fn sync_mode_resources_and_cameras(
}
}
fn sync_editor_physics_clock(
physics_time: &mut Time<Physics>,
playing: bool,
paused: bool,
stepping: bool,
) {
if playing && !paused {
physics_time.unpause();
return;
}
physics_time.pause();
if playing && stepping {
physics_time.advance_by(Duration::from_secs_f64(1.0 / SIM_TICK_RATE_HZ as f64));
}
}
fn sync_play_input_focus(
mode: Res<State<EditorMode>>,
possession: Res<PlayPossession>,
@@ -414,3 +436,29 @@ pub fn toggle_play_possession_world(world: &mut World) {
}
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn editor_physics_clock_tracks_edit_play_pause_and_single_step() {
let mut time = Time::<Physics>::default();
sync_editor_physics_clock(&mut time, false, false, false);
assert!(time.is_paused());
sync_editor_physics_clock(&mut time, true, false, false);
assert!(!time.is_paused());
sync_editor_physics_clock(&mut time, true, true, false);
assert!(time.is_paused());
sync_editor_physics_clock(&mut time, true, true, true);
assert!(time.is_paused());
assert_eq!(
time.delta(),
Duration::from_secs_f64(1.0 / SIM_TICK_RATE_HZ as f64)
);
}
}
File diff suppressed because it is too large. Load diff
+37 -5
View File
@@ -13,6 +13,7 @@ use settings::{
PROJECT_TEMPLATE_VERSION,
};
use crate::native_dialog::{NativeDialogBroker, NativeDialogPlugin};
use crate::project_io::UserPreferences;
use crate::scene::recovery::atomic_write;
use crate::ui::theme::{
@@ -91,6 +92,7 @@ pub fn run_project_launcher() {
..default()
}))
.add_plugins(EguiPlugin::default())
.add_plugins(NativeDialogPlugin)
.init_resource::<ProjectLauncherUi>()
.add_systems(Startup, spawn_project_launcher_camera)
.add_systems(EguiPrimaryContextPass, project_launcher_ui_system);
@@ -208,9 +210,24 @@ fn launcher_actions(world: &mut World, ui: &mut egui::Ui, state: &mut ProjectLau
egui::RichText::new("Select a root containing assets/project.ron").color(TEXT_DIM),
);
ui.add_space(8.0);
if ui.button("Browse Existing...").clicked() {
if let Some(root) = rfd::FileDialog::new().pick_folder() {
open_project_from_launcher(world, state, root);
let dialog_pending = world.resource::<NativeDialogBroker>().is_pending();
if ui
.add_enabled(!dialog_pending, egui::Button::new("Browse Existing..."))
.clicked()
{
let result = world.resource::<NativeDialogBroker>().request(
|| rfd::FileDialog::new().pick_folder(),
|world, root| {
let Some(root) = root else {
return;
};
world.resource_scope(|world, mut state: Mut<ProjectLauncherUi>| {
open_project_from_launcher(world, &mut state, root);
});
},
);
if let Err(error) = result {
state.status = Some(format!("Project browser unavailable: {error}"));
}
}
@@ -239,8 +256,23 @@ fn launcher_actions(world: &mut World, ui: &mut egui::Ui, state: &mut ProjectLau
)
.truncate(),
);
if ui.button("Choose Empty Folder...").clicked() {
state.sandbox_destination = rfd::FileDialog::new().pick_folder();
if ui
.add_enabled(!dialog_pending, egui::Button::new("Choose Empty Folder..."))
.clicked()
{
let result = world.resource::<NativeDialogBroker>().request(
|| rfd::FileDialog::new().pick_folder(),
|world, destination| {
if let Some(destination) = destination {
world
.resource_mut::<ProjectLauncherUi>()
.sandbox_destination = Some(destination);
}
},
);
if let Err(error) = result {
state.status = Some(format!("Folder browser unavailable: {error}"));
}
}
let can_create =
state.sandbox_destination.is_some() && !state.sandbox_name.trim().is_empty();
+4
View File
@@ -1,7 +1,11 @@
//! Project workspace I/O, settings UI, and recent-level sync.
pub mod collaboration;
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;
pub mod shutdown;
+171
View File
@@ -0,0 +1,171 @@
//! Non-blocking bridge between native dialogs and main-thread editor workflows.
use std::sync::mpsc::{self, Receiver, Sender};
use std::sync::{
atomic::{AtomicUsize, Ordering},
Arc, Mutex,
};
use bevy::prelude::*;
type MainThreadCompletion = Box<dyn FnOnce(&mut World) + Send + 'static>;
#[derive(Resource)]
pub struct NativeDialogBroker {
sender: Sender<MainThreadCompletion>,
receiver: Mutex<Receiver<MainThreadCompletion>>,
pending: Arc<AtomicUsize>,
}
impl Default for NativeDialogBroker {
fn default() -> Self {
let (sender, receiver) = mpsc::channel();
Self {
sender,
receiver: Mutex::new(receiver),
pending: Arc::new(AtomicUsize::new(0)),
}
}
}
impl NativeDialogBroker {
pub fn is_pending(&self) -> bool {
self.pending.load(Ordering::Acquire) > 0
}
pub fn request<T, D, C>(&self, dialog: D, completion: C) -> Result<(), &'static str>
where
T: Send + 'static,
D: FnOnce() -> T + Send + 'static,
C: FnOnce(&mut World, T) + Send + 'static,
{
if self
.pending
.compare_exchange(0, 1, Ordering::AcqRel, Ordering::Acquire)
.is_err()
{
return Err("another native dialog is already open");
}
let sender = self.sender.clone();
let pending = Arc::clone(&self.pending);
std::thread::spawn(move || {
let result = dialog();
let callback: MainThreadCompletion = Box::new(move |world| completion(world, result));
if sender.send(callback).is_err() {
pending.store(0, Ordering::Release);
}
});
Ok(())
}
}
pub struct NativeDialogPlugin;
impl Plugin for NativeDialogPlugin {
fn build(&self, app: &mut App) {
app.init_resource::<NativeDialogBroker>()
.add_systems(Update, drain_native_dialog_results);
}
}
fn drain_native_dialog_results(world: &mut World) {
let callbacks: Vec<_> = {
let broker = world.resource::<NativeDialogBroker>();
broker
.receiver
.lock()
.expect("native dialog receiver poisoned")
.try_iter()
.collect()
};
for callback in callbacks {
world
.resource::<NativeDialogBroker>()
.pending
.store(0, Ordering::Release);
callback(world);
}
}
#[cfg(test)]
mod tests {
use super::*;
#[derive(Resource, Default)]
struct ResultValue(Option<u32>);
#[derive(Resource, Default)]
struct FrameCount(u32);
#[test]
fn request_is_exclusive_and_completion_runs_once() {
let mut app = App::new();
app.add_plugins(NativeDialogPlugin)
.init_resource::<ResultValue>();
app.world()
.resource::<NativeDialogBroker>()
.request(
|| 42,
|world, value| world.resource_mut::<ResultValue>().0 = Some(value),
)
.unwrap();
assert!(app
.world()
.resource::<NativeDialogBroker>()
.request(|| 7, |_, _| {})
.is_err());
for _ in 0..100 {
app.update();
if app.world().resource::<ResultValue>().0.is_some() {
break;
}
std::thread::yield_now();
}
assert_eq!(app.world().resource::<ResultValue>().0, Some(42));
app.update();
assert_eq!(app.world().resource::<ResultValue>().0, Some(42));
assert!(!app.world().resource::<NativeDialogBroker>().is_pending());
}
#[test]
fn blocked_dialog_worker_does_not_block_app_frames() {
let mut app = App::new();
app.add_plugins(NativeDialogPlugin)
.init_resource::<ResultValue>()
.init_resource::<FrameCount>()
.add_systems(Update, |mut frames: ResMut<FrameCount>| frames.0 += 1);
let (release_sender, release_receiver) = mpsc::channel();
app.world()
.resource::<NativeDialogBroker>()
.request(
move || {
release_receiver
.recv()
.expect("test release sender dropped")
},
|world, value| world.resource_mut::<ResultValue>().0 = Some(value),
)
.unwrap();
for _ in 0..8 {
app.update();
}
assert_eq!(app.world().resource::<FrameCount>().0, 8);
assert_eq!(app.world().resource::<ResultValue>().0, None);
assert!(app.world().resource::<NativeDialogBroker>().is_pending());
release_sender.send(73).unwrap();
for _ in 0..100 {
app.update();
if app.world().resource::<ResultValue>().0.is_some() {
break;
}
std::thread::yield_now();
}
assert_eq!(app.world().resource::<ResultValue>().0, Some(73));
assert!(app.world().resource::<FrameCount>().0 > 8);
assert!(!app.world().resource::<NativeDialogBroker>().is_pending());
}
}
+208
View File
@@ -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();
}
}
+8 -2
View File
@@ -11,6 +11,7 @@ use crate::project_io::{ProjectWorkspace, UserPreferences};
use crate::scene::recovery::{atomic_write, default_state_root};
use crate::scene_io::{SceneIo, SceneIoRequest};
use crate::settings_ui::ProjectSettingsPanel;
use crate::shutdown::ShutdownCoordinator;
use crate::ui::{BrushDiagnosticsPanel, DiagnosticsPanel};
use crate::viewport::rendering_diagnostics::RenderingDiagnosticsPanel;
use crate::viewport::CameraBookmarks;
@@ -109,8 +110,8 @@ impl Plugin for EditorSessionPlugin {
.add_systems(Startup, initialize_session)
.add_systems(Update, persist_running_session)
.add_systems(
Last,
persist_clean_session_on_exit.after(bevy::window::ExitSystems),
crate::shutdown::EditorShutdownFinalize,
persist_clean_session_on_exit.after(crate::shutdown::finalize_authorized_shutdown),
);
}
}
@@ -311,6 +312,7 @@ fn persist_running_session(world: &mut World) {
#[allow(clippy::too_many_arguments)]
fn persist_clean_session_on_exit(
mut exits: MessageReader<AppExit>,
shutdown: Option<Res<ShutdownCoordinator>>,
scene_io: Res<SceneIo>,
workspace: Res<ProjectWorkspace>,
prefs: Res<UserPreferences>,
@@ -323,6 +325,10 @@ fn persist_clean_session_on_exit(
if exits.read().next().is_none() {
return;
}
if !shutdown.is_some_and(|shutdown| shutdown.authorized_exit_sent()) {
warn!("Ignoring an unauthorized AppExit for clean-session persistence");
return;
}
let Some(path) = session_path() else {
return;
};
+193 -14
View File
@@ -1,18 +1,28 @@
//! Editor-only Project Settings panel (egui). Data lives in the `settings` crate.
use std::path::Path;
use bevy::prelude::*;
use bevy_egui::egui;
use game_hot::sync_project_sun_from_settings;
use settings::{
load_project_settings_from_path, save_project_settings, sync_sim_tuning, ExposureMode,
ProjectSettings, ProjectSettingsChanged, ProjectSettingsIo,
save_project_settings_to_string, sync_sim_tuning, ExposureMode, ProjectSettings,
ProjectSettingsChanged, ProjectSettingsIo,
};
use crate::project::collaboration::{
file_status_indicator_ui, publish_authored_file, CollaborationState, FileSnapshot,
FileWriteIntent,
};
use crate::scene_io::SceneIo;
/// Whether the Project Settings window is visible (editor UI state only).
#[derive(Resource, Debug, Default)]
pub struct ProjectSettingsPanel {
pub open: bool,
pub draft: Option<ProjectSettings>,
disk_snapshot: Option<FileSnapshot>,
save_error: Option<String>,
}
pub struct SettingsUiPlugin;
@@ -39,11 +49,23 @@ pub fn project_settings_window(
) {
if !panel.open {
panel.draft = None;
panel.disk_snapshot = None;
panel.save_error = None;
return;
}
if panel.draft.is_none() {
panel.draft = Some(world.resource::<ProjectSettings>().clone());
let io = world.resource::<ProjectSettingsIo>();
panel.disk_snapshot = Some(
io.loaded_source
.as_deref()
.map(|source| {
FileSnapshot::from_loaded_bytes(Path::new(&io.path), source.as_bytes())
})
.unwrap_or_else(FileSnapshot::missing),
);
panel.save_error = None;
}
let mut open = panel.open;
@@ -51,17 +73,33 @@ pub fn project_settings_window(
.open(&mut open)
.default_width(420.0)
.show(ctx, |ui| {
let Some(draft) = panel.draft.as_mut() else {
let ProjectSettingsPanel {
draft: Some(draft),
disk_snapshot,
save_error,
..
} = panel
else {
return;
};
let io_path = world.resource::<ProjectSettingsIo>().path.clone();
let mut io_dirty = world.resource::<ProjectSettingsIo>().dirty;
draw_project_settings_form(world, ui, draft, &io_path, &mut io_dirty);
draw_project_settings_form(
world,
ui,
draft,
&io_path,
&mut io_dirty,
disk_snapshot,
save_error,
);
world.resource_mut::<ProjectSettingsIo>().dirty = io_dirty;
});
panel.open = open;
if !open {
panel.draft = None;
panel.disk_snapshot = None;
panel.save_error = None;
}
}
@@ -71,12 +109,26 @@ fn draw_project_settings_form(
draft: &mut ProjectSettings,
io_path: &str,
io_dirty: &mut bool,
disk_snapshot: &mut Option<FileSnapshot>,
save_error: &mut Option<String>,
) {
let caps = world
.get_resource::<settings::RenderingCapabilities>()
.cloned()
.unwrap_or_default();
ui.horizontal_wrapped(|ui| {
ui.small(egui::RichText::new(io_path).monospace());
if let Some(state) = world.get_resource::<CollaborationState>() {
let status = state.file_status(Path::new(io_path));
let _ = file_status_indicator_ui(ui, &status, Path::new(io_path));
}
});
if let Some(error) = save_error.as_deref() {
ui.colored_label(crate::ui::theme::ERROR, error);
}
ui.separator();
ui.collapsing("Global Illumination", |ui| {
egui::ComboBox::from_label("GiMode")
.selected_text(format!("{:?}", draft.rendering.gi_mode))
@@ -335,25 +387,116 @@ fn draw_project_settings_form(
.clicked()
{
commit_project_settings(world, draft);
*io_dirty = true;
let settings = world.resource::<ProjectSettings>().clone();
let mut io = world.resource_mut::<ProjectSettingsIo>();
if let Err(error) = save_project_settings(&settings, &mut io) {
warn!("Save project settings failed: {error}");
} else {
*io_dirty = false;
let Some(expected) = disk_snapshot.clone() else {
let error = "Project settings disk baseline is unavailable; reload before saving";
*save_error = Some(error.into());
world.resource_mut::<SceneIo>().set_status(error);
return;
};
match persist_project_settings(world, &settings, &expected) {
Ok((snapshot, source)) => {
let mut io = world.resource_mut::<ProjectSettingsIo>();
io.dirty = false;
io.loaded_source = Some(source);
*disk_snapshot = Some(snapshot);
*save_error = None;
*io_dirty = false;
world
.resource_mut::<SceneIo>()
.set_status(format!("Saved project settings to {io_path}"));
}
Err(error) => {
warn!("Save project settings failed: {error}");
*save_error = Some(error.clone());
world
.resource_mut::<SceneIo>()
.set_status(format!("Save project settings failed: {error}"));
}
}
}
if ui.button("Revert from disk").clicked() {
*draft = load_project_settings_from_path(io_path);
commit_project_settings(world, draft);
world.resource_mut::<ProjectSettingsIo>().dirty = false;
*io_dirty = false;
match read_project_settings_document(Path::new(io_path)) {
Ok((settings, source, snapshot)) => {
*draft = settings;
commit_project_settings(world, draft);
let mut io = world.resource_mut::<ProjectSettingsIo>();
io.dirty = false;
io.loaded_source = Some(source);
*disk_snapshot = Some(snapshot);
*save_error = None;
*io_dirty = false;
}
Err(error) => {
*save_error = Some(error.clone());
world
.resource_mut::<SceneIo>()
.set_status(format!("Revert project settings failed: {error}"));
}
}
}
if *io_dirty {
ui.label(egui::RichText::new("Unsaved changes").color(egui::Color32::YELLOW));
}
}
fn persist_project_settings(
world: &mut World,
settings: &ProjectSettings,
expected: &FileSnapshot,
) -> Result<(FileSnapshot, String), String> {
let path = world.resource::<ProjectSettingsIo>().path.clone();
let source = save_project_settings_to_string(settings).map_err(|error| error.to_string())?;
let snapshot = publish_authored_file(
world,
Path::new(&path),
source.as_bytes(),
expected,
FileWriteIntent::ProjectSettings,
)?;
Ok((snapshot, source))
}
fn read_project_settings_document(
path: &Path,
) -> Result<(ProjectSettings, String, FileSnapshot), String> {
let source = std::fs::read_to_string(path)
.map_err(|error| format!("could not read {}: {error}", path.display()))?;
let settings: ProjectSettings = ron::from_str(&source)
.map_err(|error| format!("invalid project settings in {}: {error}", path.display()))?;
let snapshot = FileSnapshot::from_loaded_bytes(path, source.as_bytes());
Ok((settings, source, snapshot))
}
pub(crate) fn reload_project_settings_after_file_conflict(
world: &mut World,
path: &Path,
) -> Result<String, String> {
let active_path = world.resource::<ProjectSettingsIo>().path.clone();
if Path::new(&active_path) != path {
return Err("the project settings conflict no longer matches the active manifest".into());
}
let (settings, source, snapshot) = read_project_settings_document(path)?;
commit_project_settings(world, &settings);
{
let mut io = world.resource_mut::<ProjectSettingsIo>();
io.dirty = false;
io.loaded_source = Some(source);
}
{
let mut panel = world.resource_mut::<ProjectSettingsPanel>();
panel.draft = Some(settings);
panel.disk_snapshot = Some(snapshot);
panel.save_error = None;
}
Ok(format!("Reloaded project settings from {}", path.display()))
}
pub(crate) fn project_settings_conflict_copy_saved(world: &mut World) {
world.resource_mut::<ProjectSettingsPanel>().save_error = None;
}
fn commit_project_settings(world: &mut World, draft: &ProjectSettings) {
let previous = world.resource::<ProjectSettings>().rendering.gi_mode;
*world.resource_mut::<ProjectSettings>() = draft.clone();
@@ -377,7 +520,11 @@ fn apply_project_settings_changes(
settings: Res<ProjectSettings>,
tuning: ResMut<settings::SimTuning>,
scene_suns: Query<
(&shared::LightDesc, Option<&shared::InspectorOrder>),
(
&shared::LightDesc,
Option<&shared::AuthoringComponentStates>,
Option<&shared::InspectorOrder>,
),
With<shared::LevelObject>,
>,
project_suns: Query<(&mut DirectionalLight, &mut Visibility), With<shared::ProjectSun>>,
@@ -402,3 +549,35 @@ fn apply_project_settings_changes(
// Full stack refresh runs next frame via `render_view::sync_project_render_view`
// when `ProjectSettings` changes.
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn project_settings_save_refuses_an_external_revision() {
let root = std::env::temp_dir().join(format!(
"blacksite-project-settings-external-write-{}",
uuid::Uuid::new_v4()
));
let path = root.join("assets/project.ron");
std::fs::create_dir_all(path.parent().unwrap()).unwrap();
let loaded = save_project_settings_to_string(&ProjectSettings::default()).unwrap();
std::fs::write(&path, &loaded).unwrap();
let expected = FileSnapshot::from_loaded_bytes(&path, loaded.as_bytes());
let mut world = World::new();
world.insert_resource(ProjectSettingsIo {
path: path.to_string_lossy().into_owned(),
loaded_source: Some(loaded),
..Default::default()
});
world.insert_resource(SceneIo::default());
std::fs::write(&path, b"external").unwrap();
let result = persist_project_settings(&mut world, &ProjectSettings::default(), &expected);
assert!(result.unwrap_err().contains("changed outside Blacksite"));
assert_eq!(std::fs::read(&path).unwrap(), b"external");
std::fs::remove_dir_all(root).unwrap();
}
}
+752
View File
@@ -0,0 +1,752 @@
//! Guarded editor shutdown and the handoff to scene persistence.
use bevy::app::{AppExit, MainScheduleOrder};
use bevy::ecs::schedule::ScheduleLabel;
use bevy::prelude::*;
use bevy::window::{PrimaryWindow, WindowCloseRequested};
use crate::native_dialog::NativeDialogBroker;
use crate::scene_io::SceneIo;
const SAVE_ALL_LABEL: &str = "Save All";
const DISCARD_LABEL: &str = "Discard";
const CANCEL_LABEL: &str = "Cancel";
/// The user or editor surface that initiated a guarded shutdown.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ShutdownSource {
NativeWindow,
FileMenu,
Programmatic,
SwitchProject,
}
/// Observable state of the single editor shutdown flow.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub enum ShutdownIntent {
#[default]
Idle,
WaitingForBroker {
source: ShutdownSource,
},
Confirming {
source: ShutdownSource,
},
Saving {
source: ShutdownSource,
},
Authorized {
source: ShutdownSource,
require_clean_scenes: bool,
},
ExitSent {
source: ShutdownSource,
},
}
impl ShutdownIntent {
pub fn source(self) -> Option<ShutdownSource> {
match self {
Self::Idle => None,
Self::WaitingForBroker { source }
| Self::Confirming { source }
| Self::Saving { source }
| Self::Authorized { source, .. }
| Self::ExitSent { source } => Some(source),
}
}
}
/// Coordinates all editor exit requests so only an authorized flow emits [`AppExit`].
#[derive(Resource, Debug, Default)]
pub struct ShutdownCoordinator {
intent: ShutdownIntent,
coalesced_requests: u32,
last_blocker: Option<String>,
}
impl ShutdownCoordinator {
pub fn intent(&self) -> ShutdownIntent {
self.intent
}
pub fn coalesced_requests(&self) -> u32 {
self.coalesced_requests
}
pub fn last_blocker(&self) -> Option<&str> {
self.last_blocker.as_deref()
}
pub fn authorized_exit_sent(&self) -> bool {
matches!(self.intent, ShutdownIntent::ExitSent { .. })
}
/// Queue a shutdown if no shutdown flow is already active.
///
/// Repeated window, menu, or programmatic requests are coalesced until the
/// current flow is cancelled, fails to save, or sends the authorized exit.
pub fn request(&mut self, source: ShutdownSource) -> bool {
if self.intent != ShutdownIntent::Idle {
self.coalesced_requests = self.coalesced_requests.saturating_add(1);
return false;
}
self.intent = ShutdownIntent::WaitingForBroker { source };
self.coalesced_requests = 0;
self.last_blocker = None;
true
}
#[cfg(test)]
pub(crate) fn set_intent_for_test(&mut self, intent: ShutdownIntent) {
self.intent = intent;
}
}
/// Emitted once when the guarded dialog chooses `Save All`.
///
/// Scene persistence owns the actual save sequence and must finish it with
/// [`complete_shutdown_save`].
#[derive(Message, Debug, Clone, Copy, PartialEq, Eq)]
pub struct ShutdownSaveAllRequested {
pub source: ShutdownSource,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum ShutdownSaveOutcome {
Saved,
Cancelled,
Failed(String),
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ShutdownDecision {
SaveAll,
Discard,
Cancel,
}
/// Runs after Bevy's `Last` schedule so no editor authoring system can mutate
/// a document after the final dirty-state check in the same frame.
#[derive(ScheduleLabel, Debug, Clone, PartialEq, Eq, Hash)]
pub struct EditorShutdownFinalize;
/// Queue a guarded shutdown from an exclusive-world UI or workflow callback.
pub fn request_editor_shutdown(world: &mut World, source: ShutdownSource) -> bool {
world
.get_resource_mut::<ShutdownCoordinator>()
.is_some_and(|mut coordinator| coordinator.request(source))
}
/// Queue a project-browser handoff through the same dirty-document guard as editor exit.
pub fn request_project_switch(world: &mut World) -> bool {
request_editor_shutdown(world, ShutdownSource::SwitchProject)
}
/// Resolve the dirty-scene confirmation through the shared coordinator.
pub fn resolve_shutdown_decision(world: &mut World, decision: ShutdownDecision) -> bool {
let (save_request, status) = {
let Some(mut coordinator) = world.get_resource_mut::<ShutdownCoordinator>() else {
return false;
};
let ShutdownIntent::Confirming { source } = coordinator.intent else {
return false;
};
match decision {
ShutdownDecision::SaveAll => {
coordinator.intent = ShutdownIntent::Saving { source };
(
Some(source),
Some("Saving all modified scene tabs before shutdown"),
)
}
ShutdownDecision::Discard => {
coordinator.intent = ShutdownIntent::Authorized {
source,
require_clean_scenes: false,
};
(None, None)
}
ShutdownDecision::Cancel => {
coordinator.intent = ShutdownIntent::Idle;
(
None,
Some("Shutdown cancelled; unsaved scene tabs retained"),
)
}
}
};
if let Some(status) = status {
if let Some(mut scene_io) = world.get_resource_mut::<SceneIo>() {
scene_io.set_status(status);
}
}
if let Some(source) = save_request {
world.write_message(ShutdownSaveAllRequested { source });
}
true
}
/// Finish the save-all handoff. A reported success is authorized only after
/// every scene tab is observably clean.
pub fn complete_shutdown_save(world: &mut World, outcome: ShutdownSaveOutcome) -> bool {
let scenes_are_clean = !scene_has_unsaved_changes(world);
let Some(mut coordinator) = world.get_resource_mut::<ShutdownCoordinator>() else {
return false;
};
let ShutdownIntent::Saving { source } = coordinator.intent else {
return false;
};
match outcome {
ShutdownSaveOutcome::Saved if scenes_are_clean => {
coordinator.intent = ShutdownIntent::Authorized {
source,
require_clean_scenes: true,
};
coordinator.last_blocker = None;
true
}
ShutdownSaveOutcome::Saved => {
coordinator.intent = ShutdownIntent::Idle;
coordinator.last_blocker =
Some("Save All completed while unsaved scene tabs remain".into());
false
}
ShutdownSaveOutcome::Cancelled => {
coordinator.intent = ShutdownIntent::Idle;
coordinator.last_blocker = None;
false
}
ShutdownSaveOutcome::Failed(error) => {
coordinator.intent = ShutdownIntent::Idle;
coordinator.last_blocker = Some(error);
false
}
}
}
pub struct ShutdownPlugin;
impl Plugin for ShutdownPlugin {
fn build(&self, app: &mut App) {
app.init_schedule(EditorShutdownFinalize);
app.world_mut()
.resource_mut::<MainScheduleOrder>()
.insert_after(Last, EditorShutdownFinalize);
app.init_resource::<ShutdownCoordinator>()
.add_message::<ShutdownSaveAllRequested>()
.add_systems(
Update,
(capture_native_close_requests, drive_shutdown).chain(),
)
.add_systems(EditorShutdownFinalize, finalize_authorized_shutdown);
}
}
fn capture_native_close_requests(
mut commands: Commands,
mut close_requests: MessageReader<WindowCloseRequested>,
primary_window: Query<Entity, With<PrimaryWindow>>,
mut coordinator: ResMut<ShutdownCoordinator>,
) {
let Ok(primary_window) = primary_window.single() else {
return;
};
for request in close_requests.read() {
if request.window == primary_window {
coordinator.request(ShutdownSource::NativeWindow);
} else {
commands.entity(request.window).despawn();
}
}
}
fn drive_shutdown(world: &mut World) {
let intent = world.resource::<ShutdownCoordinator>().intent;
match intent {
ShutdownIntent::Idle
| ShutdownIntent::Confirming { .. }
| ShutdownIntent::Saving { .. }
| ShutdownIntent::ExitSent { .. } => {}
ShutdownIntent::WaitingForBroker { source } => {
let unsaved_count = unsaved_scene_count(world);
if unsaved_count == 0 {
world.resource_mut::<ShutdownCoordinator>().intent = ShutdownIntent::Authorized {
source,
require_clean_scenes: true,
};
return;
}
if world.resource::<NativeDialogBroker>().is_pending() {
return;
}
let action = if source == ShutdownSource::SwitchProject {
"switching projects"
} else {
"quitting"
};
let description = if unsaved_count == 1 {
format!("One scene tab has unsaved changes. Save it before {action}?")
} else {
format!(
"{unsaved_count} scene tabs have unsaved changes. Save all before {action}?"
)
};
let title = if source == ShutdownSource::SwitchProject {
"Switch Project"
} else {
"Quit Blacksite Editor"
};
let request = world.resource::<NativeDialogBroker>().request(
move || {
rfd::MessageDialog::new()
.set_title(title)
.set_description(description)
.set_level(rfd::MessageLevel::Warning)
.set_buttons(rfd::MessageButtons::YesNoCancelCustom(
SAVE_ALL_LABEL.into(),
DISCARD_LABEL.into(),
CANCEL_LABEL.into(),
))
.show()
},
|world, result| {
resolve_shutdown_decision(world, decision_from_dialog(result));
},
);
if request.is_ok() {
world.resource_mut::<ShutdownCoordinator>().intent =
ShutdownIntent::Confirming { source };
}
}
ShutdownIntent::Authorized { .. } => {}
}
}
/// Final dirty-state recheck after editor UI and authoring schedules have completed.
pub(crate) fn finalize_authorized_shutdown(world: &mut World) {
let (source, require_clean_scenes) = {
let coordinator = world.resource::<ShutdownCoordinator>();
let ShutdownIntent::Authorized {
source,
require_clean_scenes,
} = coordinator.intent
else {
return;
};
(source, require_clean_scenes)
};
if require_clean_scenes && scene_has_unsaved_changes(world) {
world.resource_mut::<ShutdownCoordinator>().intent =
ShutdownIntent::WaitingForBroker { source };
return;
}
if source == ShutdownSource::SwitchProject {
if let Err(error) = crate::launcher::spawn_project_launcher_process() {
let message = format!("Switch project failed: {error}");
{
let mut coordinator = world.resource_mut::<ShutdownCoordinator>();
coordinator.intent = ShutdownIntent::Idle;
coordinator.last_blocker = Some(message.clone());
}
if let Some(mut scene_io) = world.get_resource_mut::<SceneIo>() {
scene_io.set_status(message);
}
return;
}
}
world.resource_mut::<ShutdownCoordinator>().intent = ShutdownIntent::ExitSent { source };
debug!(?source, "Editor shutdown authorized");
world.write_message(AppExit::Success);
}
fn scene_has_unsaved_changes(world: &World) -> bool {
world
.get_resource::<SceneIo>()
.is_some_and(SceneIo::has_unsaved_tabs)
}
fn unsaved_scene_count(world: &World) -> usize {
let Some(scene_io) = world.get_resource::<SceneIo>() else {
return 0;
};
let tab_count = scene_io.tabs.iter().filter(|tab| tab.dirty).count();
if scene_io.dirty
&& scene_io
.tabs
.get(scene_io.active_tab)
.is_none_or(|tab| !tab.dirty)
{
tab_count + 1
} else {
tab_count
}
}
fn decision_from_dialog(result: rfd::MessageDialogResult) -> ShutdownDecision {
match result {
rfd::MessageDialogResult::Custom(label) if label == SAVE_ALL_LABEL => {
ShutdownDecision::SaveAll
}
rfd::MessageDialogResult::Custom(label) if label == DISCARD_LABEL => {
ShutdownDecision::Discard
}
rfd::MessageDialogResult::Yes => ShutdownDecision::SaveAll,
rfd::MessageDialogResult::No => ShutdownDecision::Discard,
_ => ShutdownDecision::Cancel,
}
}
#[cfg(test)]
mod tests {
use std::sync::mpsc;
use bevy::ecs::message::MessageCursor;
use super::*;
use crate::native_dialog::NativeDialogPlugin;
fn confirming_world() -> World {
let mut world = World::new();
world.init_resource::<Messages<ShutdownSaveAllRequested>>();
world.insert_resource(ShutdownCoordinator {
intent: ShutdownIntent::Confirming {
source: ShutdownSource::FileMenu,
},
..default()
});
world
}
#[test]
fn repeated_requests_are_coalesced_behind_the_first_source() {
let mut coordinator = ShutdownCoordinator::default();
assert!(coordinator.request(ShutdownSource::NativeWindow));
assert!(!coordinator.request(ShutdownSource::FileMenu));
assert_eq!(coordinator.coalesced_requests(), 1);
assert_eq!(
coordinator.intent(),
ShutdownIntent::WaitingForBroker {
source: ShutdownSource::NativeWindow
}
);
}
#[test]
fn cancel_returns_to_idle_and_discard_authorizes_exit() {
let mut cancel_world = confirming_world();
assert!(resolve_shutdown_decision(
&mut cancel_world,
ShutdownDecision::Cancel
));
assert_eq!(
cancel_world.resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::Idle
);
let mut discard_world = confirming_world();
assert!(resolve_shutdown_decision(
&mut discard_world,
ShutdownDecision::Discard
));
assert_eq!(
discard_world.resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::Authorized {
source: ShutdownSource::FileMenu,
require_clean_scenes: false,
}
);
}
#[test]
fn dirty_cancel_preserves_the_session_and_discard_emits_one_exit() {
let mut app = App::new();
app.add_message::<AppExit>()
.init_resource::<SceneIo>()
.init_resource::<ShutdownCoordinator>();
app.world_mut().resource_mut::<SceneIo>().mark_dirty();
app.world_mut()
.resource_mut::<ShutdownCoordinator>()
.set_intent_for_test(ShutdownIntent::Confirming {
source: ShutdownSource::Programmatic,
});
assert!(resolve_shutdown_decision(
app.world_mut(),
ShutdownDecision::Cancel
));
drive_shutdown(app.world_mut());
finalize_authorized_shutdown(app.world_mut());
assert_eq!(app.should_exit(), None);
assert!(app.world().resource::<SceneIo>().has_unsaved_tabs());
app.world_mut()
.resource_mut::<ShutdownCoordinator>()
.set_intent_for_test(ShutdownIntent::Confirming {
source: ShutdownSource::Programmatic,
});
assert!(resolve_shutdown_decision(
app.world_mut(),
ShutdownDecision::Discard
));
drive_shutdown(app.world_mut());
finalize_authorized_shutdown(app.world_mut());
assert_eq!(app.should_exit(), Some(AppExit::Success));
assert!(app.world().resource::<SceneIo>().has_unsaved_tabs());
assert!(app
.world()
.resource::<ShutdownCoordinator>()
.authorized_exit_sent());
}
#[test]
fn file_menu_and_programmatic_clean_exit_use_the_same_coordinator_path() {
for source in [ShutdownSource::FileMenu, ShutdownSource::Programmatic] {
let mut app = App::new();
app.add_message::<AppExit>()
.init_resource::<SceneIo>()
.init_resource::<ShutdownCoordinator>()
.init_resource::<NativeDialogBroker>();
assert!(request_editor_shutdown(app.world_mut(), source));
drive_shutdown(app.world_mut());
finalize_authorized_shutdown(app.world_mut());
assert_eq!(app.should_exit(), Some(AppExit::Success));
assert_eq!(
app.world().resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::ExitSent { source }
);
}
}
#[test]
fn save_all_emits_one_persistence_handoff() {
let mut world = confirming_world();
let mut cursor = MessageCursor::<ShutdownSaveAllRequested>::default();
assert!(resolve_shutdown_decision(
&mut world,
ShutdownDecision::SaveAll
));
assert!(!resolve_shutdown_decision(
&mut world,
ShutdownDecision::SaveAll
));
let messages = world.resource::<Messages<ShutdownSaveAllRequested>>();
let requests: Vec<_> = cursor.read(messages).copied().collect();
assert_eq!(
requests,
vec![ShutdownSaveAllRequested {
source: ShutdownSource::FileMenu
}]
);
}
#[test]
fn clean_native_close_emits_the_authorized_exit() {
let mut app = App::new();
app.add_message::<WindowCloseRequested>()
.add_plugins((NativeDialogPlugin, ShutdownPlugin))
.init_resource::<SceneIo>();
let window = app.world_mut().spawn(PrimaryWindow).id();
app.world_mut()
.write_message(WindowCloseRequested { window });
app.update();
assert_eq!(app.should_exit(), Some(AppExit::Success));
assert_eq!(
app.world().resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::ExitSent {
source: ShutdownSource::NativeWindow
}
);
}
#[test]
fn secondary_window_close_does_not_request_editor_shutdown() {
let mut app = App::new();
app.add_message::<WindowCloseRequested>()
.add_plugins((NativeDialogPlugin, ShutdownPlugin))
.init_resource::<SceneIo>();
app.world_mut().spawn(PrimaryWindow);
let secondary = app.world_mut().spawn_empty().id();
app.world_mut()
.write_message(WindowCloseRequested { window: secondary });
app.update();
assert_eq!(app.should_exit(), None);
assert_eq!(
app.world().resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::Idle
);
assert!(app.world().get_entity(secondary).is_err());
}
#[test]
fn occupied_dialog_broker_keeps_shutdown_waiting() {
let mut app = App::new();
app.add_message::<WindowCloseRequested>()
.add_plugins((NativeDialogPlugin, ShutdownPlugin))
.init_resource::<SceneIo>();
app.world_mut().resource_mut::<SceneIo>().mark_dirty();
let (release_sender, release_receiver) = mpsc::channel();
app.world()
.resource::<NativeDialogBroker>()
.request(
move || release_receiver.recv().expect("release sender dropped"),
|_, _: ()| {},
)
.unwrap();
assert!(request_editor_shutdown(
app.world_mut(),
ShutdownSource::Programmatic
));
app.update();
assert_eq!(
app.world().resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::WaitingForBroker {
source: ShutdownSource::Programmatic
}
);
release_sender.send(()).unwrap();
}
#[test]
fn successful_save_requires_every_scene_tab_to_be_clean() {
let mut world = World::new();
world.init_resource::<SceneIo>();
world.insert_resource(ShutdownCoordinator {
intent: ShutdownIntent::Saving {
source: ShutdownSource::Programmatic,
},
..default()
});
assert!(complete_shutdown_save(
&mut world,
ShutdownSaveOutcome::Saved
));
assert_eq!(
world.resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::Authorized {
source: ShutdownSource::Programmatic,
require_clean_scenes: true,
}
);
world.resource_mut::<SceneIo>().mark_dirty();
world.resource_mut::<ShutdownCoordinator>().intent = ShutdownIntent::Saving {
source: ShutdownSource::Programmatic,
};
assert!(!complete_shutdown_save(
&mut world,
ShutdownSaveOutcome::Saved
));
assert_eq!(
world.resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::Idle
);
assert!(world
.resource::<ShutdownCoordinator>()
.last_blocker()
.is_some());
}
#[test]
fn a_new_edit_after_save_reopens_the_guard_instead_of_exiting() {
let mut world = World::new();
world.init_resource::<Messages<AppExit>>();
world.init_resource::<SceneIo>();
world.insert_resource(ShutdownCoordinator {
intent: ShutdownIntent::Authorized {
source: ShutdownSource::Programmatic,
require_clean_scenes: true,
},
..default()
});
world.resource_mut::<SceneIo>().mark_dirty();
finalize_authorized_shutdown(&mut world);
assert_eq!(
world.resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::WaitingForBroker {
source: ShutdownSource::Programmatic
}
);
let messages = world.resource::<Messages<AppExit>>();
assert_eq!(
MessageCursor::<AppExit>::default().read(messages).count(),
0
);
}
#[test]
fn last_schedule_edit_is_seen_before_final_exit_authorization() {
let mut app = App::new();
app.add_message::<WindowCloseRequested>()
.add_plugins((NativeDialogPlugin, ShutdownPlugin))
.init_resource::<SceneIo>()
.add_systems(Last, |mut scene_io: ResMut<SceneIo>| {
scene_io.mark_dirty();
});
assert!(request_editor_shutdown(
app.world_mut(),
ShutdownSource::Programmatic
));
app.update();
assert_eq!(app.should_exit(), None);
assert!(app.world().resource::<SceneIo>().has_unsaved_tabs());
assert_eq!(
app.world().resource::<ShutdownCoordinator>().intent(),
ShutdownIntent::WaitingForBroker {
source: ShutdownSource::Programmatic
}
);
}
#[test]
fn custom_dialog_labels_map_to_shutdown_decisions() {
assert_eq!(
decision_from_dialog(rfd::MessageDialogResult::Custom(SAVE_ALL_LABEL.into())),
ShutdownDecision::SaveAll
);
assert_eq!(
decision_from_dialog(rfd::MessageDialogResult::Custom(DISCARD_LABEL.into())),
ShutdownDecision::Discard
);
assert_eq!(
decision_from_dialog(rfd::MessageDialogResult::Custom(CANCEL_LABEL.into())),
ShutdownDecision::Cancel
);
}
#[test]
fn only_the_final_coordinator_state_authorizes_clean_session_persistence() {
let mut coordinator = ShutdownCoordinator::default();
assert!(!coordinator.authorized_exit_sent());
coordinator.intent = ShutdownIntent::Authorized {
source: ShutdownSource::Programmatic,
require_clean_scenes: true,
};
assert!(!coordinator.authorized_exit_sent());
coordinator.intent = ShutdownIntent::ExitSent {
source: ShutdownSource::Programmatic,
};
assert!(coordinator.authorized_exit_sent());
}
}
+16 -10
View File
@@ -13,17 +13,20 @@ pub(crate) fn atomic_write(path: &Path, bytes: &[u8]) -> Result<(), String> {
atomic_write_with_pre_rename(path, bytes, || Ok(()))
}
fn atomic_write_with_pre_rename(
pub(crate) fn atomic_write_with_pre_rename<E>(
path: &Path,
bytes: &[u8],
before_rename: impl FnOnce() -> Result<(), String>,
) -> Result<(), String> {
before_rename: impl FnOnce() -> Result<(), E>,
) -> Result<(), E>
where
E: From<String>,
{
let parent = path
.parent()
.filter(|parent| !parent.as_os_str().is_empty())
.unwrap_or_else(|| Path::new("."));
fs::create_dir_all(parent)
.map_err(|error| format!("could not create {}: {error}", parent.display()))?;
.map_err(|error| E::from(format!("could not create {}: {error}", parent.display())))?;
let file_name = path
.file_name()
@@ -40,18 +43,21 @@ fn atomic_write_with_pre_rename(
.create_new(true)
.write(true)
.open(&temporary)
.map_err(|error| format!("could not create {}: {error}", temporary.display()))?;
file.write_all(bytes)
.map_err(|error| format!("could not write {}: {error}", temporary.display()))?;
.map_err(|error| {
E::from(format!("could not create {}: {error}", temporary.display()))
})?;
file.write_all(bytes).map_err(|error| {
E::from(format!("could not write {}: {error}", temporary.display()))
})?;
file.sync_all()
.map_err(|error| format!("could not sync {}: {error}", temporary.display()))?;
.map_err(|error| E::from(format!("could not sync {}: {error}", temporary.display())))?;
before_rename()?;
fs::rename(&temporary, path).map_err(|error| {
format!(
E::from(format!(
"could not replace {} with {}: {error}",
path.display(),
temporary.display()
)
))
})?;
sync_parent_directory(parent);
Ok(())
File diff suppressed because it is too large. Load diff
+13 -6
View File
@@ -5,7 +5,7 @@ mod transform;
use bevy::prelude::*;
use bevy_egui::egui;
use egui_phosphor_icons::icons;
use shared::{ActorId, ActorKind, ActorName, HydratedPrefabMember, LevelObject};
use shared::{infer_actor_kind, ActorId, ActorKind, ActorName, HydratedPrefabMember, LevelObject};
use crate::ext::extensibility::ActorInspectorSectionRegistry;
use crate::ui::inspector;
@@ -29,9 +29,8 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
return;
}
let kind = entity_ref
.get::<ActorKind>()
.copied()
let kind = infer_actor_kind(entity_ref)
.or_else(|| entity_ref.get::<ActorKind>().copied())
.unwrap_or(ActorKind::Empty);
egui::Frame::new()
@@ -111,7 +110,9 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
match kind {
ActorKind::StaticMesh
| ActorKind::SkinnedMesh
| ActorKind::Brush
| ActorKind::Terrain
| ActorKind::ImportedModel
| ActorKind::Light
| ActorKind::Empty
@@ -123,7 +124,8 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
| ActorKind::TeamSpawn
| ActorKind::Objective
| ActorKind::AudioSource
| ActorKind::AudioListener => {
| ActorKind::AudioListener
| ActorKind::Navigation => {
inspector::authoring_inspector_ui(world, ui, entity);
}
}
@@ -139,7 +141,11 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
match kind {
ActorKind::StaticMesh | ActorKind::Brush | ActorKind::ImportedModel => icons::CUBE,
ActorKind::StaticMesh
| ActorKind::SkinnedMesh
| ActorKind::Brush
| ActorKind::Terrain
| ActorKind::ImportedModel => icons::CUBE,
ActorKind::Light => icons::LIGHTBULB,
ActorKind::PrefabAnchor => icons::PACKAGE,
ActorKind::PlayerSpawn => icons::PERSON_SIMPLE_RUN,
@@ -149,6 +155,7 @@ fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
ActorKind::TeamSpawn | ActorKind::Objective => icons::FLAG,
ActorKind::AudioSource => icons::SPEAKER_HIGH,
ActorKind::AudioListener => icons::HEADPHONES,
ActorKind::Navigation => icons::PATH,
ActorKind::Empty => icons::CIRCLE,
}
}
+4 -4
View File
@@ -7,7 +7,7 @@ use bevy_egui::egui;
use egui_phosphor_icons::icons;
use shared::{
AnimationClipRecord, AnimationControllerDesc, AnimationManifest, AnimationSkeletonRecord,
AnimationStateDesc, EditorAssetRef, ModelRef, COMPONENT_ANIMATION_CONTROLLER_DESC,
AnimationStateDesc, EditorAssetRef, SkinnedMeshRenderer, COMPONENT_ANIMATION_CONTROLLER_DESC,
};
use crate::assets::animation::load_animation_manifest;
@@ -656,8 +656,8 @@ fn manifest_summary(ui: &mut egui::Ui, manifest: &Result<AnimationManifest, Stri
fn manifest_for_actor(world: &World, entity: Entity) -> Result<AnimationManifest, String> {
let model = world
.get::<ModelRef>(entity)
.ok_or_else(|| "actor has no ModelRef".to_string())?;
.get::<SkinnedMeshRenderer>(entity)
.ok_or_else(|| "actor has no SkinnedMeshRenderer".to_string())?;
let registry = world
.get_resource::<AssetRegistry>()
.ok_or_else(|| "asset registry is unavailable".to_string())?;
@@ -878,12 +878,12 @@ mod tests {
schema_version: 1,
asset_id: "model-id".into(),
label: "Robot".into(),
default_animation_clip_id: None,
source: AnimationManifestSource {
path: "assets/models/robot.glb".into(),
format: "glb".into(),
fingerprint: AnimationSourceFingerprint {
byte_len: 42,
modified_unix_secs: 1,
content_hash: "hash".into(),
},
dependencies: Vec::new(),
File diff suppressed because it is too large. Load diff
+13 -1
View File
@@ -3,10 +3,11 @@
use std::collections::HashSet;
use bevy::prelude::*;
use shared::MaterialAsset;
use shared::{MaterialAsset, MaterialInstanceAsset};
use crate::asset_db::ImportSettings;
use crate::assets::{AssetSelection, ASSETS_ROOT, BUILTINS_FOLDER};
use crate::project::collaboration::FileSnapshot;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub(crate) enum AssetBrowserView {
@@ -48,6 +49,7 @@ pub struct AssetBrowserUiState {
pub(crate) pending_delete: Option<AssetDeleteRequest>,
pub(crate) import_draft: Option<ImportSettingsDraft>,
pub(crate) material_draft: Option<MaterialAssetDraft>,
pub(crate) material_instance_draft: Option<MaterialInstanceAssetDraft>,
}
#[derive(Debug, Clone)]
@@ -68,6 +70,15 @@ pub(crate) struct ImportSettingsDraft {
pub(crate) struct MaterialAssetDraft {
pub(crate) path: String,
pub(crate) asset: MaterialAsset,
pub(crate) disk_snapshot: FileSnapshot,
pub(crate) error: Option<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct MaterialInstanceAssetDraft {
pub(crate) path: String,
pub(crate) asset: MaterialInstanceAsset,
pub(crate) disk_snapshot: FileSnapshot,
pub(crate) error: Option<String>,
}
@@ -89,6 +100,7 @@ impl Default for AssetBrowserUiState {
pending_delete: None,
import_draft: None,
material_draft: None,
material_instance_draft: None,
}
}
}
Loaded 100 of 300 files, more files were not shown because too many files have changed in this diff. Show more