Compare commits
14
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed21bcc52d | ||
|
|
577d8dcb27 | ||
|
|
ba59f57a5a | ||
|
|
d038cf3670 | ||
|
|
61be2440bd | ||
|
|
3794faa4aa | ||
|
|
02247f029a | ||
|
|
3931de1f0a | ||
|
|
f2ad88fd03 | ||
|
|
5a82a9ee29 | ||
|
|
b4aa61e394 | ||
|
|
0798aa5d57 | ||
|
|
0553a85220 | ||
|
|
cc1fa6ea3b |
No files matched your search
@@ -7,3 +7,6 @@ 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 --"
|
||||
bake-navigation = "run -p xtask --features validate-levels --bin bake-navigation --"
|
||||
package-project = "run -p xtask --features validate-levels --bin package-project --"
|
||||
upgrade-project = "run -p xtask --features validate-levels --bin upgrade-project --"
|
||||
@@ -0,0 +1,105 @@
|
||||
# Skeletal Animation Import, Preview, And Authoring
|
||||
|
||||
Working implementation plan for Gitea issue
|
||||
[`#46`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/46).
|
||||
This is the minimum production animation loop required by the M7 content-production milestone.
|
||||
|
||||
## Status
|
||||
|
||||
Implementation and production acceptance are complete. The persistent/runtime contract, generated
|
||||
manifest, stable model/clip identity, runtime adapter, browser drag workflow, typed inspector, and
|
||||
headless validation are implemented. Live acceptance covers import, placement, preview, scrub,
|
||||
save/reload hydration, PIE playback, source relocation, development packaging, and standalone
|
||||
runtime playback with the committed RobotExpressive fixture.
|
||||
|
||||
## Outcome
|
||||
|
||||
An author can import a supported skinned model, inspect its skeleton and clips, place an animated
|
||||
actor, preview and scrub a clip without dirtying the scene, save a small named state set, and drive
|
||||
the same state changes in PIE and a packaged game. Missing content and skeleton mismatches fail with
|
||||
owner-attributed repair guidance before packaging.
|
||||
|
||||
## Format Policy
|
||||
|
||||
- Animation authoring v1 supports glTF 2.0 (`.gltf` and `.glb`) through Bevy's native scene,
|
||||
skinning, and animation assets.
|
||||
- FBX remains supported for the existing static mesh import path. An FBX containing animation stacks
|
||||
or skin deformers is not a supported animated source and must produce a blocking, actionable
|
||||
diagnostic.
|
||||
- Animated FBX support cannot be enabled until the loader constructs the source hierarchy, Bevy
|
||||
skinned-mesh bindings, and `AnimationClip` assets. Metadata counts alone do not qualify as support.
|
||||
|
||||
## Architecture
|
||||
|
||||
- The asset registry UUID remains the parent model identity. A generated animation manifest under
|
||||
`assets/animations/generated/` records the source fingerprint, skeleton signatures, stable clip
|
||||
sub-asset IDs, clip metadata, and animation events.
|
||||
- `shared::AnimationControllerDesc` is reflected and serializable. It references imported skeletons
|
||||
and clips through stable `EditorAssetRef` values and owns one layer of named states, a default
|
||||
state, playback range/loop/speed, and default crossfade duration.
|
||||
- `game` owns the runtime adapter. It waits for the model `WorldAssetRoot` instance to become ready,
|
||||
attaches transient animation graph/player state, and exposes a request API for changing an actor's
|
||||
named state.
|
||||
- `editor` owns import presentation, clip/skeleton shelves, drag assignment/placement, inspector
|
||||
controls, and non-dirty preview/scrubbing. Preview uses the runtime adapter rather than a separate
|
||||
interpretation of the authored contract.
|
||||
- `scene` and package validation resolve the same manifests and stable references used by editor and
|
||||
runtime hydration.
|
||||
|
||||
## Authoritative Data
|
||||
|
||||
The generated manifest is keyed by the model's stable registry UUID and includes:
|
||||
|
||||
- schema version and source path/fingerprint;
|
||||
- scenes and exact skeleton signatures;
|
||||
- stable skeleton and clip sub-asset IDs;
|
||||
- clip label, source index, duration, target skeleton signature, and event markers;
|
||||
- import diagnostics, including unsupported animated FBX content.
|
||||
|
||||
An exact skeleton signature is a deterministic hash of normalized ordered joint target paths and
|
||||
bind-pose structure. Retargeting v1 accepts only an exact signature match. No implicit joint-name,
|
||||
humanoid, or proportional remapping is allowed.
|
||||
|
||||
## Implementation Sequence
|
||||
|
||||
1. Add the versioned animation manifest schema, stable sub-asset identity rules, glTF extraction,
|
||||
FBX blocking diagnostics, and focused importer tests.
|
||||
2. Add `AnimationControllerDesc`, named state/event types, registration, migration defaults,
|
||||
actor validation, history snapshots, scene round-trip coverage, and runtime-only strip policy.
|
||||
3. Replace broad imported-model child cleanup with a dedicated generated instance root, then hydrate
|
||||
the ready scene instance into a transient graph/player and implement the game state-request API.
|
||||
4. Extend Asset Browser model shelves with skeleton and clip rows, compatibility status, preview,
|
||||
scrub/range/loop controls, and clip drag placement or assignment.
|
||||
5. Add the typed Animation Controller inspector, undoable state edits, PIE pause/stop reconciliation,
|
||||
owner-attributed project validation, and package dependency collection.
|
||||
6. Commit a small redistributable animated GLB and sample scene, then run import, round-trip,
|
||||
headless, live editor/PIE, and packaged-runtime acceptance.
|
||||
|
||||
## Acceptance Gates
|
||||
|
||||
- A committed skinned GLB and its clips import, preview, save, hydrate, and play in PIE and a
|
||||
packaged runtime.
|
||||
- Moving or renaming the source inside the project preserves controller clip references through the
|
||||
registry UUID and stable sub-asset IDs.
|
||||
- Missing manifests/clips and mismatched skeleton signatures produce actor/property-attributed
|
||||
diagnostics with a concrete repair action.
|
||||
- Gameplay can request a valid named state through the public game API; invalid requests leave the
|
||||
current state intact and report a diagnostic.
|
||||
- Preview follows the authored loop/range/speed settings, stops cleanly, and never mutates the scene
|
||||
descriptor, history, or dirty state.
|
||||
- Generated graph/player/instance components never serialize into authored scenes, and model
|
||||
rehydration never deletes authored hierarchy children.
|
||||
- Animated or skinned FBX content blocks animation import with a diagnostic that explains the glTF
|
||||
v1 requirement.
|
||||
- Focused importer, validation, hydration, request-API, and editor operator tests pass alongside
|
||||
workspace tests, `cargo validate-levels`, package validation, and live smoke testing.
|
||||
|
||||
## Deliberate Boundaries
|
||||
|
||||
- V1 provides one animation layer with named states, one default state, and a default crossfade. It
|
||||
does not include a visual state graph, blend trees, transition-condition authoring, inverse
|
||||
kinematics, motion matching, or root-motion extraction.
|
||||
- Event markers are normalized data and runtime notifications; V1 has no timeline scripting system.
|
||||
- Retargeting is exact signature match only.
|
||||
- FBX static mesh import remains available, but animated FBX conversion is separate loader work and
|
||||
cannot silently fall back to bind-pose or metadata-only playback.
|
||||
@@ -0,0 +1,72 @@
|
||||
# Audio Authoring And Runtime Parity
|
||||
|
||||
Working implementation plan for Gitea issue
|
||||
[`#47`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/47).
|
||||
This is the minimum complete audio loop required by the M7 content-production milestone.
|
||||
|
||||
## Status
|
||||
|
||||
Completed and production-accepted in Gitea #47. Permanent behavior is documented in
|
||||
[ADR 0030](../../docs/adr/0030-audio-authoring-and-bus-schema.md) and
|
||||
[Audio Authoring](../../docs/editor/audio-authoring.md).
|
||||
|
||||
## Outcome
|
||||
|
||||
An author can import a supported audio clip, place or assign it as an authored source, tune playback
|
||||
and spatial behavior, audition it without dirtying the scene, save/reload it, and hear equivalent
|
||||
behavior in PIE and a packaged game. Projects expose stable Master, Music, and SFX buses with runtime
|
||||
gain/mute hooks and validation that also runs headlessly.
|
||||
|
||||
## Architecture
|
||||
|
||||
- `shared` owns reflected, serializable source/listener/attenuation descriptors and stable actor kinds.
|
||||
- `settings` owns versioned project bus definitions and validation; bus references use stable IDs.
|
||||
- `game` hydrates authoring descriptors into Bevy audio playback/listener components and applies bus
|
||||
controls. Hydrated components remain derived and are never scene source of truth.
|
||||
- `editor` owns asset discovery/import UX, inspector controls, drag/drop placement, visualizers, and
|
||||
transient audition state. Audition never mutates an authored descriptor or marks a scene dirty.
|
||||
- Scene and project validation share the same clip-reference, bus-reference, range, and listener rules
|
||||
used by packaging. Missing, excluded, unsupported, or Git LFS pointer clips block release validation.
|
||||
|
||||
## Supported Content
|
||||
|
||||
- Ogg Vorbis is the baseline runtime format.
|
||||
- WAV, MP3, and FLAC support is enabled explicitly in the workspace Bevy feature set.
|
||||
- Audio sources support gain, pitch, looping, autoplay, spatial blend, attenuation, and bus routing.
|
||||
- Listener authoring supports enabled state, priority, and ear gap; at runtime exactly one enabled
|
||||
listener is selected deterministically.
|
||||
- Default project buses are `master`, `music`, and `sfx`; Music and SFX route to Master.
|
||||
|
||||
## Implementation Sequence
|
||||
|
||||
1. Add shared descriptors, settings schema/defaults/validation, launcher scaffolding, and migrations.
|
||||
2. Add audio clip catalog classification, import target, search/filter/details, and drag payloads.
|
||||
3. Add runtime source/listener hydration, deterministic listener selection, and bus controls.
|
||||
4. Add inspector cards with undoable edits and scene save/validation allowlists.
|
||||
5. Add viewport icons/range visualizers and transient audition/stop using the editor camera listener.
|
||||
6. Add a small sample clip/scene, focused round-trip and PIE tests, live QA, permanent docs, and Gitea
|
||||
acceptance evidence.
|
||||
|
||||
## Acceptance Gates
|
||||
|
||||
- Dragging a clip into the viewport creates an audio source; dropping onto a compatible selected
|
||||
source assigns the clip through one undoable command.
|
||||
- Inspector edits survive save/reload and PIE hydration without generated playback state leaking into
|
||||
the authored scene.
|
||||
- Spatial preview follows the editor camera, stops on explicit Stop, mode/project changes, or source
|
||||
deletion, and never changes scene dirty state.
|
||||
- Bus definitions persist with stable IDs, invalid parent cycles/references are rejected, and runtime
|
||||
gain/mute hooks affect routed sources.
|
||||
- Headless validation reports missing/unpackageable clips, unsupported values, invalid buses, and
|
||||
ambiguous enabled listeners with actor/property context.
|
||||
- Focused unit/integration tests, `cargo validate-levels`, package validation, and live editor/game
|
||||
smoke tests passed for issue `#47` closure.
|
||||
|
||||
## Deliberate Boundaries
|
||||
|
||||
- This slice does not include DSP graphs, reverb zones, waveform editing, audio streaming banks,
|
||||
middleware integration, or platform-specific compression pipelines.
|
||||
- Continuous spatial blend is represented authoritatively and implemented without claiming Bevy
|
||||
supports a native blend control; the runtime adapter owns the mapping/mix behavior.
|
||||
- A future mixer UI may expose additional buses and sends, but it must preserve the stable bus IDs and
|
||||
parent graph established here.
|
||||
@@ -0,0 +1,115 @@
|
||||
# Blacksite Editor Production Readiness Program
|
||||
|
||||
Working milestone plan for the production expansion tracked by Gitea epic
|
||||
[`#1`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/1).
|
||||
The existing Jackdaw-inspired M0-M5 roadmap remains the authoring/tool foundation. This plan adds
|
||||
the reliability and shipping gates required for daily indie game production.
|
||||
|
||||
## Definition Of Production Ready
|
||||
|
||||
Blacksite is production ready only when the evidence matrix in Gitea
|
||||
[`#50`](https://git.spacetrainclubhouse.com/Falling-Metal-Interactive/Blacksite/issues/50)
|
||||
is signed off. Feature presence alone is insufficient. Recovery, validation, packaging,
|
||||
performance, soak, regression, and first-hour workflows must pass against a representative project.
|
||||
|
||||
## Immediate Sequence
|
||||
|
||||
1. Completed: hierarchy/prefab boundary hardening `#40`, transactional recovery `#39`, stable
|
||||
sessions/diagnostics `#41`, and Project Browser/startup boundaries `#3`.
|
||||
2. Completed: stable scene tabs and composed subscene ownership/validation in `#42`.
|
||||
3. Completed: nested prefabs, variants, and structural overrides passed production acceptance in
|
||||
`#43`; M6 implementation is complete.
|
||||
4. Completed: authoritative content validation `#45` and the validation-gated packaging/Build
|
||||
workflow `#44`.
|
||||
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
|
||||
|
||||
**Exit:** A normal or interrupted editor session cannot silently lose or corrupt authored work, and
|
||||
projects/scenes/prefabs have stable daily workflows.
|
||||
|
||||
| Issue | Capability | Priority |
|
||||
|-------|------------|----------|
|
||||
| #3 | Project launcher, templates, recent projects, resume | P0 |
|
||||
| #39 | Transactional saves, autosave, crash recovery | P0 |
|
||||
| #40 | Hierarchy, parenting, prefab structure hardening | P0 |
|
||||
| #41 | Session persistence and crash diagnostics | P0 |
|
||||
| #42 | Multi-scene tabs, subscenes, level composition | P1 |
|
||||
| #43 | Nested prefabs, variants, structural overrides | P1 |
|
||||
|
||||
## M7 - Content Production And Shipping
|
||||
|
||||
**Exit:** A clean checkout can validate, build, package, and run a representative project with the
|
||||
minimum animation, audio, and navigation authoring loops required by the game.
|
||||
|
||||
| Issue | Capability | Priority |
|
||||
|-------|------------|----------|
|
||||
| #44 | Build/package profiles and Build panel | P0 |
|
||||
| #45 | Dependency manifest and content release gate | P0 |
|
||||
| #46 | Skeletal animation import/preview/authoring | P1 |
|
||||
| #47 | Audio sources/listeners/buses/spatial preview | P1 |
|
||||
| #48 | Navigation authoring/bake/path preview | P1 |
|
||||
| #49 | Source-control status and collaborative file safety | P2 |
|
||||
| #50 | Production-readiness acceptance matrix | P0 |
|
||||
|
||||
## Cross-Cutting Gates
|
||||
|
||||
- Authored IDs, scene schema, hydration stripping, and extension boundaries remain authoritative.
|
||||
- Every mutation supports meaningful undo/redo; modal tools also support cancel without dirty state.
|
||||
- Editor-only helpers, recovery files, and caches never enter scenes or game packages.
|
||||
- Interactive and headless validation use the same rules and produce equivalent blocking results.
|
||||
- Large asset, terrain, navigation, and geometry work is debounced or dirty-region based.
|
||||
- Visible behavior updates root controls and `docs/editor/`; hard-to-reverse decisions get ADRs.
|
||||
- Production signoff requires a second-person first-hour QA pass and no open P0 blocker.
|
||||
|
||||
## Completed Slice - UI Identity And Structural Dragging
|
||||
|
||||
- Near-black Blacksite shell with compact tool identity rather than a Unity clone.
|
||||
- Pointer-following asset drag preview, viewport reticle, boundary, and corner brackets.
|
||||
- Full-width hierarchy attach targets plus explicit root/reorder/invalid feedback.
|
||||
- World-transform-preserving reparent/unparent with grouped history.
|
||||
- Cycle rejection, subtree-safe multi-drag, parent expansion, and focused regression coverage.
|
||||
|
||||
## Completed Slice - Multi-Scene Production Workflow
|
||||
|
||||
- Independent scene tabs integrated into the right end of the existing main toolbar.
|
||||
- Stable `SceneComposition` resources with project-relative references and no runtime entity IDs.
|
||||
- Recursive missing/cycle/duplicate/path-escape validation shared by editor and CI.
|
||||
- Runtime-only composed ownership, load/lock/focus controls, and owner-save exclusion.
|
||||
- Per-saved-tab recovery, composition undo/redo, PIE-active composition consistency, and fixtures.
|
||||
|
||||
## Completed Slice - Validation-Gated Build And Packaging
|
||||
|
||||
- Shared owner-attributed project validation and runtime-packageability policy in editor, CI, and
|
||||
packaging; unknown schemas, missing LFS objects, excluded references, and unsafe traversal block.
|
||||
- Versioned development/QA/release profiles with Cargo-reported artifacts, rendering/default-scene
|
||||
application, Windows QA symbols, supported-target enforcement, and deterministic metadata.
|
||||
- OS-locked authenticated staging, interrupted-build recovery, complete pre-publish hashing, safe
|
||||
replacement, and unchanged-output reuse.
|
||||
- Non-blocking editor Build/Run/Cancel/Reveal workflow with dirty-tab guard and process-tree cleanup.
|
||||
- Gitea #44 and #45 closed after headless, focused regression, repeated-build, and live packaged
|
||||
development-runtime acceptance.
|
||||
|
||||
## Completed Slice - Audio Authoring And Spatial Preview
|
||||
|
||||
The stable authoring/runtime contract is recorded in
|
||||
[ADR 0030](../../docs/adr/0030-audio-authoring-and-bus-schema.md), with controls, runtime behavior,
|
||||
validation, and the committed sample fixture documented in
|
||||
[Audio Authoring](../../docs/editor/audio-authoring.md). Gitea #47 closed after automated,
|
||||
headless, live editor/PIE, and packaged-runtime acceptance.
|
||||
@@ -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,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: the deformed Solari geometry
|
||||
boundary in `#51`, terrain `#22`-`#24`, physics placement/diagnostics `#25`-`#26`, and their
|
||||
regression fixtures. Collaborative safety `#49`, Material Library/targeted drops `#16`/`#18`,
|
||||
and native-dialog responsiveness `#52` are accepted and integrated.
|
||||
3. Complete the representative regression project, mutation-invariant coverage, performance budgets,
|
||||
and first-hour workflow tracked by `#32`-`#36`.
|
||||
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,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.
|
||||
@@ -41,34 +41,22 @@ jobs:
|
||||
run: rustup show
|
||||
|
||||
- name: Check formatting
|
||||
run: cargo fmt --check
|
||||
run: cargo fmt --all --check
|
||||
|
||||
- name: Check workspace
|
||||
run: cargo check --workspace
|
||||
run: cargo check --workspace --all-targets
|
||||
|
||||
- name: Clippy
|
||||
run: cargo clippy --workspace
|
||||
- name: Clippy workspace
|
||||
run: cargo clippy --workspace --all-targets -- -D warnings
|
||||
|
||||
- name: Clippy foundation crates
|
||||
run: cargo clippy -p game -p shared -- -D warnings
|
||||
|
||||
- name: Test foundation helpers
|
||||
run: cargo test -p game --lib
|
||||
|
||||
- name: Test shared hydration and actor validation
|
||||
run: cargo test -p shared
|
||||
|
||||
- name: Test sim crate
|
||||
run: cargo test -p sim
|
||||
- name: Test workspace
|
||||
run: cargo test --workspace
|
||||
|
||||
- name: Validate level scenes
|
||||
run: cargo validate-levels
|
||||
|
||||
- name: Test scene schema crate
|
||||
run: cargo test -p scene
|
||||
|
||||
- name: Check editor (dev)
|
||||
run: cargo check -p editor --features dev
|
||||
- name: Clippy launch feature matrix
|
||||
run: cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||
|
||||
- name: Build binaries
|
||||
run: |
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# Rust build output
|
||||
/target/
|
||||
/dist/
|
||||
|
||||
# Local automation and assistant state
|
||||
/.agents/
|
||||
@@ -13,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
|
||||
|
||||
Vendored
+238
-35
@@ -4,48 +4,251 @@
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug editor",
|
||||
"preLaunchTask": "build editor (dev fast-link)",
|
||||
"program": "${workspaceFolder}/target/debug/editor",
|
||||
"args": [],
|
||||
"env": {
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug game",
|
||||
"preLaunchTask": "build game (dev fast-link)",
|
||||
"program": "${workspaceFolder}/target/debug/game",
|
||||
"args": [],
|
||||
"env": {
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Run editor (release)",
|
||||
"name": "Editor: Debug",
|
||||
"cargo": {
|
||||
"args": ["build", "--release", "-p", "editor"],
|
||||
"filter": { "name": "editor", "kind": "bin" }
|
||||
"args": ["build", "-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Editor: GPU validation",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "1",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Editor: Hot reload",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"-p",
|
||||
"editor",
|
||||
"--bin",
|
||||
"editor",
|
||||
"--features",
|
||||
"dev,hot-reload"
|
||||
],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Editor: SDR fallback",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/release/deps:${env:LD_LIBRARY_PATH}"
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}"
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Editor: Release",
|
||||
"cargo": {
|
||||
"args": ["build", "--release", "-p", "editor", "--bin", "editor"],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": { "RUST_BACKTRACE": "1", "WGPU_VALIDATION": "0" },
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Editor: Project root...",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"filter": { "name": "editor", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": ["--project", "${input:blacksiteProjectRoot}"],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Game: Debug",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"filter": { "name": "game", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Game: GPU validation",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"filter": { "name": "game", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "1",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Game: Hot reload",
|
||||
"cargo": {
|
||||
"args": [
|
||||
"build",
|
||||
"-p",
|
||||
"game",
|
||||
"--bin",
|
||||
"game",
|
||||
"--features",
|
||||
"dev,hot-reload"
|
||||
],
|
||||
"filter": { "name": "game", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Game: SDR fallback",
|
||||
"cargo": {
|
||||
"args": ["build", "-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"filter": { "name": "game", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"LD_LIBRARY_PATH": "${workspaceFolder}/target/debug/deps:${env:LD_LIBRARY_PATH}"
|
||||
},
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
},
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Game: Release",
|
||||
"cargo": {
|
||||
"args": ["build", "--release", "-p", "game", "--bin", "game"],
|
||||
"filter": { "name": "game", "kind": "bin" },
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||
"problemMatcher": "$rustc"
|
||||
},
|
||||
"args": [],
|
||||
"env": { "RUST_BACKTRACE": "1", "WGPU_VALIDATION": "0" },
|
||||
"cwd": "${workspaceFolder}",
|
||||
"terminal": "integrated",
|
||||
"sourceLanguages": ["rust"],
|
||||
"gracefulShutdown": "SIGINT"
|
||||
}
|
||||
],
|
||||
"inputs": [
|
||||
{
|
||||
"id": "blacksiteProjectRoot",
|
||||
"type": "promptString",
|
||||
"description": "Absolute path to a Blacksite project root",
|
||||
"default": "${workspaceFolder}"
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+149
-58
@@ -2,42 +2,61 @@
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "cargo fmt (check)",
|
||||
"label": "cargo fmt (workspace check)",
|
||||
"type": "cargo",
|
||||
"command": "fmt",
|
||||
"args": ["--check"],
|
||||
"args": ["--all", "--check"],
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "cargo check (workspace)",
|
||||
"label": "cargo check (workspace all targets)",
|
||||
"type": "cargo",
|
||||
"command": "check",
|
||||
"args": ["--workspace"],
|
||||
"args": ["--workspace", "--all-targets"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "cargo clippy (workspace)",
|
||||
"label": "cargo clippy (workspace strict)",
|
||||
"type": "cargo",
|
||||
"command": "clippy",
|
||||
"args": ["--workspace"],
|
||||
"args": ["--workspace", "--all-targets", "--", "-D", "warnings"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "cargo clippy (foundation strict)",
|
||||
"type": "cargo",
|
||||
"command": "clippy",
|
||||
"args": ["-p", "game", "-p", "shared", "--", "-D", "warnings"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "cargo test (foundation)",
|
||||
"label": "cargo test (workspace)",
|
||||
"type": "cargo",
|
||||
"command": "test",
|
||||
"args": ["-p", "game", "--lib"],
|
||||
"args": ["--workspace"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "test"
|
||||
},
|
||||
{
|
||||
"label": "cargo clippy (launch feature matrix)",
|
||||
"type": "cargo",
|
||||
"command": "clippy",
|
||||
"args": [
|
||||
"-p",
|
||||
"editor",
|
||||
"-p",
|
||||
"game",
|
||||
"--bins",
|
||||
"--features",
|
||||
"dev,hot-reload",
|
||||
"--",
|
||||
"-D",
|
||||
"warnings"
|
||||
],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "validate level scenes",
|
||||
"type": "cargo",
|
||||
"command": "validate-levels",
|
||||
"args": [],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "test"
|
||||
},
|
||||
@@ -45,7 +64,7 @@
|
||||
"label": "build game (debug)",
|
||||
"type": "cargo",
|
||||
"command": "build",
|
||||
"args": ["-p", "game"],
|
||||
"args": ["-p", "game", "--bin", "game"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
@@ -53,47 +72,50 @@
|
||||
"label": "build editor (debug)",
|
||||
"type": "cargo",
|
||||
"command": "build",
|
||||
"args": ["-p", "editor"],
|
||||
"args": ["-p", "editor", "--bin", "editor"],
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": { "kind": "build", "isDefault": true }
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "build editor (dev fast-link)",
|
||||
"type": "cargo",
|
||||
"command": "build",
|
||||
"args": ["-p", "editor", "--features", "dev"],
|
||||
"args": ["-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"options": {
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
"group": { "kind": "build", "isDefault": true }
|
||||
},
|
||||
{
|
||||
"label": "build game (dev fast-link)",
|
||||
"type": "cargo",
|
||||
"command": "build",
|
||||
"args": ["-p", "game", "--features", "dev"],
|
||||
"args": ["-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"options": {
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "clean build editor (dev)",
|
||||
"type": "shell",
|
||||
"command": "cargo clean -p editor && cargo build -p editor --features dev",
|
||||
"label": "clean dev-link crates",
|
||||
"type": "cargo",
|
||||
"command": "clean",
|
||||
"args": ["-p", "editor", "-p", "game", "-p", "game_hot", "-p", "shared"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "clean build editor (dev)",
|
||||
"dependsOrder": "sequence",
|
||||
"dependsOn": ["clean dev-link crates", "build editor (dev fast-link)"],
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
@@ -102,9 +124,7 @@
|
||||
"command": "cargo clean-target",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
@@ -115,9 +135,7 @@
|
||||
"command": "cargo clean-target --apply",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
@@ -128,9 +146,7 @@
|
||||
"command": "cargo clean-target --include-artifacts --days 3 --apply",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
@@ -139,10 +155,11 @@
|
||||
"label": "run editor (dev fast-link)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": ["-p", "editor", "--features", "dev"],
|
||||
"args": ["-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
@@ -154,9 +171,83 @@
|
||||
"label": "run game (dev fast-link)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": ["-p", "game", "--features", "dev"],
|
||||
"args": ["-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "run editor (hot reload)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": [
|
||||
"-p",
|
||||
"editor",
|
||||
"--bin",
|
||||
"editor",
|
||||
"--features",
|
||||
"dev,hot-reload"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "run game (hot reload)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": ["-p", "game", "--bin", "game", "--features", "dev,hot-reload"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "run editor (SDR fallback)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": ["-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "run game (SDR fallback)",
|
||||
"type": "cargo",
|
||||
"command": "run",
|
||||
"args": ["-p", "game", "--bin", "game", "--features", "dev"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"RUST_BACKTRACE": "1",
|
||||
"BEVY_FPS_HDR": "0",
|
||||
"WGPU_VALIDATION": "0",
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
@@ -171,28 +262,28 @@
|
||||
"command": "cargo watch -w crates/game_hot -w crates/sim -x \"build -p game_hot --features dylib\"",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}",
|
||||
"env": {
|
||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||
}
|
||||
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||
},
|
||||
"problemMatcher": ["$rustc"],
|
||||
"group": "build",
|
||||
"isBackground": true
|
||||
"isBackground": true,
|
||||
"detail": "Requires cargo-watch: cargo install cargo-watch --locked"
|
||||
},
|
||||
{
|
||||
"label": "verify foundation",
|
||||
"label": "verify workspace",
|
||||
"dependsOrder": "sequence",
|
||||
"dependsOn": [
|
||||
"cargo fmt (check)",
|
||||
"cargo check (workspace)",
|
||||
"cargo clippy (workspace)",
|
||||
"cargo clippy (foundation strict)",
|
||||
"cargo test (foundation)",
|
||||
"cargo fmt (workspace check)",
|
||||
"cargo check (workspace all targets)",
|
||||
"cargo clippy (workspace strict)",
|
||||
"cargo test (workspace)",
|
||||
"cargo clippy (launch feature matrix)",
|
||||
"validate level scenes",
|
||||
"build game (debug)",
|
||||
"build editor (debug)"
|
||||
],
|
||||
"problemMatcher": [],
|
||||
"group": { "kind": "build", "isDefault": true }
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
Generated
+746
-189
File diff suppressed because it is too large.
Load diff
+33
-1
@@ -1,5 +1,6 @@
|
||||
[workspace]
|
||||
members = [
|
||||
"crates/blacksite_surface",
|
||||
"crates/game",
|
||||
"crates/game_hot",
|
||||
"crates/shared",
|
||||
@@ -26,9 +27,17 @@ avian3d = { version = "0.7", default-features = false, features = [
|
||||
"collider-from-mesh",
|
||||
"serialize",
|
||||
] }
|
||||
bevy = { version = "0.19", features = ["serialize", "jpeg"] }
|
||||
bevy = { version = "0.19", features = [
|
||||
"serialize",
|
||||
"jpeg",
|
||||
"vorbis",
|
||||
"wav",
|
||||
"mp3",
|
||||
"flac",
|
||||
] }
|
||||
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"
|
||||
@@ -36,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" }
|
||||
@@ -45,8 +57,12 @@ 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.
|
||||
ron-edit = { path = "third_party/ron-edit" }
|
||||
# Atmosphere-aware mesh view bind groups (WYSIWYG editor + transform gizmos).
|
||||
transform-gizmo-bevy = { path = "third_party/transform-gizmo-bevy" }
|
||||
|
||||
@@ -73,3 +89,19 @@ opt-level = 3
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
codegen-units = 1
|
||||
strip = "symbols"
|
||||
|
||||
# Export profiles keep runtime optimization and compact binaries without forcing
|
||||
# release LTO into normal editor iteration.
|
||||
[profile.package-dev]
|
||||
inherits = "release"
|
||||
lto = false
|
||||
codegen-units = 16
|
||||
strip = "symbols"
|
||||
|
||||
[profile.package-qa]
|
||||
inherits = "release"
|
||||
lto = false
|
||||
codegen-units = 8
|
||||
debug = "line-tables-only"
|
||||
strip = "none"
|
||||
@@ -21,12 +21,18 @@ native Bevy scene save/load, and BRP support for external tooling.
|
||||
|
||||
```bash
|
||||
# Check everything
|
||||
cargo fmt --check
|
||||
cargo check --workspace
|
||||
cargo clippy --workspace
|
||||
cargo clippy -p game -p shared -p protocol -p sim -- -D warnings
|
||||
cargo test -p game --lib
|
||||
cargo test -p sim
|
||||
cargo fmt --all --check
|
||||
cargo check --workspace --all-targets
|
||||
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 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
|
||||
|
||||
# Runtime game
|
||||
cargo run -p game
|
||||
@@ -37,6 +43,22 @@ cargo run -p editor
|
||||
cargo run -p editor --features dev
|
||||
```
|
||||
|
||||
The standalone `game` binary loads `default_level` from `assets/project.ron` as the initial authored
|
||||
scene. That entrypoint must be a regular `.scn.ron` file under `assets/levels/` so validation audits
|
||||
its complete runtime dependency graph. The in-process editor defers that bootstrap to its scene tabs
|
||||
and `SceneIo`, so opening the editor never creates a competing runtime scene root.
|
||||
|
||||
Open a different validated Blacksite project before engine startup:
|
||||
|
||||
```bash
|
||||
cargo run -p editor --features dev -- --project /path/to/project
|
||||
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.
|
||||
|
||||
### Hot reload (gameplay iteration)
|
||||
|
||||
`--features dev` turns on Bevy **dynamic linking** for faster rebuilds (recommended day-to-day).
|
||||
@@ -53,7 +75,7 @@ cargo watch -w crates/game_hot -w crates/sim -x "build -p game_hot --features dy
|
||||
cargo run -p editor --features dev,hot-reload
|
||||
```
|
||||
|
||||
Or use the VS Code task **watch game_hot (hot reload)** alongside **run editor (dev fast-link)** (enable the `hot-reload` feature on the editor run task when using dylib iteration).
|
||||
Or use the VS Code task **watch game_hot (hot reload)** alongside **run editor (hot reload)**, or choose **Editor: Hot reload** in Run and Debug. The watcher task requires `cargo-watch` (`cargo install cargo-watch --locked`).
|
||||
|
||||
| Input | Action |
|
||||
|-------|--------|
|
||||
@@ -82,7 +104,7 @@ rebuild caused by `cargo clean`. The workspace test profile keeps line tables bu
|
||||
debuginfo and incremental test caches, so routine test binaries stay materially smaller without
|
||||
reducing normal editor debugging fidelity. The cleanup binary deliberately excludes the scene/Bevy
|
||||
validation dependency; `cargo clean-target` therefore stays cheap even from a cold target. Use
|
||||
`cargo validate-levels` when scene validation is required. VS Code tasks expose dry-run, safe, and
|
||||
`cargo validate-levels` when level and prefab-graph validation is required. VS Code tasks expose dry-run, safe, and
|
||||
deep-stale variants.
|
||||
|
||||
### Launch Troubleshooting
|
||||
@@ -90,8 +112,8 @@ deep-stale variants.
|
||||
- The native game/editor windows force an opaque Wayland surface and opaque camera clears to avoid compositor alpha issues on mixed HDR/SDR desktops.
|
||||
- If the window maps but appears transparent on Hyprland or another Wayland compositor, launch with `BEVY_FPS_HDR=0` to force the SDR camera path while debugging monitor/compositor behavior.
|
||||
- Bevy 0.19 removed the prior local `bevy_render` swapchain-timeout patch; launch troubleshooting should start from current wgpu/driver/compositor logs.
|
||||
- Debug launch configs and run tasks set `WGPU_VALIDATION=0` to quiet the known wgpu/Vulkan validation-layer warning `VUID-StandaloneSpirv-MemorySemantics-10871`. This only disables the Vulkan validation layer for those launches; Rust panics and application errors still surface normally.
|
||||
- If **CodeLLDB / mold** fails with hundreds of `undefined symbol` linker errors, the incremental `target/` cache is stale. Run the VS Code task **clean build editor (dev)** or `cargo clean -p editor && cargo build -p editor --features dev`, then launch **Debug editor** again. Use `cargo run -p editor --features dev` from the terminal if you need `libbevy_dylib` on `LD_LIBRARY_PATH` automatically.
|
||||
- Normal Debug and run configurations preserve project HDR and set `WGPU_VALIDATION=0` to suppress known Bevy/Solari Vulkan memory-model VUID noise on this stack. Use **GPU validation** when actively debugging renderer work; it forces `WGPU_VALIDATION=1` and may report those known upstream/driver messages. Use **SDR fallback** for compositor/HDR mapping failures; it additionally sets `BEVY_FPS_HDR=0`.
|
||||
- If **CodeLLDB / mold** fails with hundreds of `undefined symbol` linker errors, the incremental `target/` cache is stale. Run the VS Code task **clean build editor (dev)** or `cargo clean -p editor -p game -p game_hot -p shared && cargo build -p editor --bin editor --features dev`, then launch **Editor: Debug** again. Use `cargo run -p editor --features dev` from the terminal if you need `libbevy_dylib` on `LD_LIBRARY_PATH` automatically.
|
||||
|
||||
## Editor Controls
|
||||
|
||||
@@ -115,27 +137,42 @@ deep-stale variants.
|
||||
| `Ctrl+D` | Duplicate selection |
|
||||
| `Ctrl+Z` / `Ctrl+Shift+Z` / `Ctrl+Y` | Undo / redo |
|
||||
| `F2` in Hierarchy | Rename selection |
|
||||
| `W` / `E` / `R` | Translate / rotate / scale gizmo |
|
||||
| `W` / `E` / `R` | Translate / rotate / scale gizmo; multi-selection uses one grouped gizmo and undo step |
|
||||
| `X` | Toggle world/local gizmo orientation |
|
||||
| `B` | Enter Draw Brush mode |
|
||||
| Draw Brush: LMB / `Enter` / mouse up-down / `Esc` / `Backspace` | Place floor points / enter height phase or create / set height / cancel / remove point or return to outline |
|
||||
| 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) |
|
||||
| Viewport eye/options | Toggle actor root icon categories, adjust icon/gizmo size, and control colliders, lights, spawns, prefab/model anchors, and runtime player/camera visualizers |
|
||||
| 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 |
|
||||
| Click Player visualizer in Edit mode | Select or create the authored `PlayerSpawn` (`Player Start`) |
|
||||
| Select Project Sun | Inspect project default lighting; create a scene sun override |
|
||||
| Asset Browser project/file views | Browse `assets/`, search/filter/sort, switch grid/list, expand model subassets with generated thumbnails, inspect staged import/material settings, drag assets/submeshes into the viewport |
|
||||
| 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 |
|
||||
| Hierarchy context | Reparent to other selection / Unparent |
|
||||
| File menu | New, Open, Save, Save As, Import Assets, Export Selection, Save Selection As Prefab, Recent Scenes |
|
||||
| Drag actor row onto another actor (Hierarchy) | Attach/reparent while preserving world placement; multi-selection keeps existing subtrees and commits one undo step |
|
||||
| Drag actor between rows / onto Scene Root (Hierarchy, Manual sort) | Reorder siblings / unparent to the root |
|
||||
| Hierarchy lock | Excludes the actor from selection, gizmos, multi-drag, structural drops, and mutating context actions |
|
||||
| Hierarchy context | Group selection, create authored local children below linked prefab roots, remove/reparent generated members through same-layer structural overrides, or unparent |
|
||||
| File menu | New, non-blocking native Open/Save As, recovery restore/keep-copy/discard when available, Import Assets, Export Selection, Save Selection As Prefab (including linked-root variants), Recent Scenes |
|
||||
| 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 |
|
||||
| Edit → Project Settings… | Edit `assets/project.ron` (rendering, physics, input) |
|
||||
| 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 |
|
||||
| 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 |
|
||||
|
||||
Viewport shortcut keys require the pointer to be in the viewport and are suspended while typing in egui text fields or actively using camera navigation. `Delete`, `Backspace`, duplicate, and undo/redo also defer to text-field focus.
|
||||
|
||||
@@ -175,7 +212,18 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
|
||||
## Scene Workflow
|
||||
|
||||
- Levels are saved as native Bevy dynamic scenes under `assets/levels/`.
|
||||
- Scene tabs live at the right end of the existing main toolbar. Open creates another tab; each tab
|
||||
retains its own path and dirty state, and close prompts only for that document.
|
||||
- The adjacent **Composition** menu adds validated project-relative subscenes, loads/unloads them,
|
||||
applies read-only hierarchy locks, and focuses their actors. Recursive validation rejects missing
|
||||
or cyclic references before replacing the active world. See
|
||||
[multi-scene-composition.md](docs/editor/multi-scene-composition.md).
|
||||
- Editable entities use reflectable authoring components from `crates/shared`.
|
||||
- Linked prefabs keep source-generated actors out of owner-scene serialization through runtime
|
||||
`HydratedPrefabMember` ownership. Generated actor properties/components and same-layer structural
|
||||
changes use stable nested override paths; authored local children and nested linked instances can
|
||||
live below an instance root. Saving that linked root and its local hierarchy as a prefab creates
|
||||
the current variant representation. See [prefab-authoring.md](docs/editor/prefab-authoring.md).
|
||||
- The editable player start is an authored `PlayerSpawn`; moving it with the transform gizmo changes
|
||||
where Play mode boots the runtime player.
|
||||
- Project settings provide default ambient/sun lighting. A scene-authored directional `LightDesc`
|
||||
@@ -189,9 +237,25 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
|
||||
artifacts in `assets/meshes/generated/`. Renderer slots reference imported content-browser mesh
|
||||
and material assets, while generated collision is stored separately in `ColliderDesc` plus
|
||||
`RigidBodyDesc`. Switch a model asset's placement mode to **Scene Instance** in Asset Browser
|
||||
details when you need full `WorldAssetRoot` loading for animation/skinning/scene data. Expanding a
|
||||
model in the Asset Browser exposes normalized mesh/material/texture subassets; dragging a mesh
|
||||
subasset places that part through the same static mesh renderer path.
|
||||
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 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
|
||||
@@ -203,6 +267,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
|
||||
@@ -229,7 +300,51 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
|
||||
|
||||
### Hierarchy scrolls during drag
|
||||
|
||||
Scroll-to-drag is disabled while dragging actors. Release the mouse to finish or cancel the drag.
|
||||
Scroll-to-drag is disabled while dragging actors. The pointer card reports the pending action:
|
||||
drop on a full actor row to attach, on the **Scene Root** zone to unparent, or between rows in
|
||||
**Manual** sort to reorder. Amber means attach, cyan means reorder/root, and red blocks a hierarchy
|
||||
cycle. Release away from a valid target to cancel.
|
||||
|
||||
### Scene recovery
|
||||
|
||||
Dirty saved scenes create a recovery snapshot every 120 seconds and retain the newest five
|
||||
generations under `$XDG_STATE_HOME/blacksite-editor/recovery` or
|
||||
`~/.local/state/blacksite-editor/recovery`. If a snapshot is newer than the authored scene, the
|
||||
status strip shows `[recovery]` and recovery actions become available in **File**. **Restore
|
||||
Recovery Snapshot** loads it into dirty editor state for inspection, **Save Recovery Copy As...**
|
||||
writes a separate transactional scene copy without changing the active scene, and **Discard
|
||||
Recovery Snapshot** retires all generations. Restore keeps the generation available until **Save**
|
||||
commits the active scene or discard explicitly retires it. The **Diagnostics** window retains the
|
||||
latest 32 scene I/O results, including exact recovery paths and failures, for the current session.
|
||||
Unsaved new scenes are not yet covered by automatic recovery.
|
||||
For recovery testing only, `BLACKSITE_RECOVERY_INTERVAL_SECS=<seconds>` overrides the interval for
|
||||
the current process without changing preferences.
|
||||
|
||||
### Session recovery
|
||||
|
||||
Clean editor exits restore the last authored scene, panel visibility, and viewport bookmarks from
|
||||
the versioned machine-local session document. After an abnormal exit, Blacksite opens the safe
|
||||
startup scene and asks whether to **Resume Last Scene** or **Continue Safe**; modal tools and dirty
|
||||
preview state are never restored. Session metadata lives under
|
||||
`$XDG_STATE_HOME/blacksite-editor/session.ron` or `~/.local/state/blacksite-editor/session.ron` and
|
||||
contains no scene contents or credentials. See [ADR 0024](docs/adr/0024-versioned-editor-session-state.md).
|
||||
|
||||
Open **Window → Diagnostics** and choose **Export Diagnostic Bundle** to write a transactional
|
||||
support report under `$XDG_STATE_HOME/blacksite-editor/diagnostics` or
|
||||
`~/.local/state/blacksite-editor/diagnostics`. The report includes build/platform and renderer
|
||||
identity, project and active-scene paths, dirty flags, aggregate validation counts, prior-crash
|
||||
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
|
||||
|
||||
@@ -238,8 +353,8 @@ The `.vscode/` folder is preconfigured:
|
||||
- `extensions.json` recommends rust-analyzer, Even Better TOML, CodeLLDB, crates, and Error Lens.
|
||||
- `settings.json` runs `clippy` on save, enables proc-macro/build-script support, formats on save,
|
||||
and excludes `target/` from search/watch.
|
||||
- `tasks.json` provides workspace check/clippy plus game/editor build/run tasks.
|
||||
- `launch.json` provides CodeLLDB launch configs for the editor and game.
|
||||
- `tasks.json` mirrors the full workspace formatting, all-target check, strict Clippy, test, level-validation, build/run, hot-reload, and target-cleanup workflows. **build editor (dev fast-link)** is the default build task.
|
||||
- `launch.json` uses CodeLLDB Cargo artifact filtering for editor/game Debug, GPU-validation, hot-reload, SDR fallback, and Release configurations. Normal launches keep HDR enabled while quieting known Vulkan validation noise; dynamic-link launches set the required `LD_LIBRARY_PATH` automatically.
|
||||
- `.github/workflows/ci.yml` mirrors local formatting, check, clippy, test, and binary build verification.
|
||||
|
||||
## Architecture Decisions
|
||||
@@ -253,6 +368,8 @@ 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)
|
||||
|
||||
## Project Layout
|
||||
|
||||
@@ -282,6 +399,8 @@ 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] 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] 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
|
||||
@@ -292,30 +411,46 @@ crates/
|
||||
- [x] CI workflow for format, check, clippy, tests, and binary builds
|
||||
- [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] Verify: `cargo fmt --check` / `cargo check --workspace` / `cargo clippy --workspace` / strict foundation clippy / `cargo test -p sim`
|
||||
- [x] Stable asset registry with UUIDs + import settings in asset browser details
|
||||
- [x] Asset Browser expandable model subasset shelves, independent mesh/material/texture thumbnails, staged import/material details with shader-schema parameters, context actions, and trash-first file removal
|
||||
- [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] Unsaved-scene confirm on New/Open/Recent
|
||||
- [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)
|
||||
- [x] `ActorInspectorSection` registry + game demo section (`game::editor_ext`)
|
||||
- [x] Command palette: reset lighting, group selection, focus selection
|
||||
- [x] CI: `cargo test -p shared`, scene authoring-only check on repo level, `cargo check -p editor --features dev`
|
||||
- [x] `scene` crate schema stamp/migrate/validate on save/load + CI `validate-levels`
|
||||
- [x] `scene` crate schema stamp/migrate/validate on save/load + CI `validate-levels` for levels and prefab graphs
|
||||
- [x] Project Settings draft + Apply (HDR/swapchain safe)
|
||||
- [ ] Project launcher/scaffolding with startup-time asset-root selection; the unsafe in-process File → Project scaffold was removed pending BS-JD-001
|
||||
- [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] Prefab instance overrides v2 (transform/material/child visibility apply-revert groups)
|
||||
- [x] Shared Material/Material Instance assets, stable static/skinned renderer material slots, imported-source fallback, orphan preservation, and runtime-only property blocks ([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
|
||||
@@ -328,14 +463,27 @@ crates/
|
||||
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
|
||||
edited from the browser, and delete actions move files to `assets/.trash/`. Skeletal animation
|
||||
playback is not supported by the static mesh path yet.
|
||||
- Prefab instances use stable asset IDs (`PrefabInstance` + registry) with serialized `PrefabOverrides` (transform, material, per-child visibility by name). Inspector **Apply/Revert** per field group; **Unpack** removes the instance link.
|
||||
- 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.
|
||||
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
|
||||
skinned FBX remains blocked until the loader can build hierarchy, Bevy skinned meshes, and clips.
|
||||
See the [animation authoring guide](docs/editor/animation-authoring.md).
|
||||
- Prefab instances use stable asset IDs and shared versioned override data keyed by nested
|
||||
`PrefabActorPath` identity. Generated source members are excluded from owner save/export, while
|
||||
property/component edits and same-layer remove/reparent operations persist as overrides. Revert
|
||||
stays instance-local; explicit **Apply to source** validates and atomically patches the appropriate
|
||||
source layer, with exact-file undo/redo guards against external edits. Source health exposes
|
||||
changed, semantic-conflict, broken, and malformed states with keep/take/retry/relink recovery.
|
||||
**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 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. Dynamic skinned/morph Solari geometry and a persisted property-block authoring workflow remain future work; 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.
|
||||
|
||||
+384
-13
@@ -1,4 +1,40 @@
|
||||
[
|
||||
(
|
||||
id: ("c0a7d10e-53c1-4de0-b0dc-34a66f44ba77"),
|
||||
path: "assets/audio/editor_audition_tone.ogg",
|
||||
label: "editor_audition_tone",
|
||||
kind_tag: "AudioClip",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("fe40db93-181f-4c79-86e6-26bd97464c4b"),
|
||||
path: "assets/audio/Puzzle Lobby.mp3",
|
||||
label: "Puzzle Lobby",
|
||||
kind_tag: "AudioClip",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("31963299-d4c1-45dc-8f67-2f469ca1ad6d"),
|
||||
path: "assets/post_fx/chromatic_aberration.ron",
|
||||
@@ -12,6 +48,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -28,6 +66,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -44,29 +84,46 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: Some("assets/meshes/generated/b98ef565-3500-49e7-9935-f685fa9b2594.static_mesh.ron"),
|
||||
animation_manifest_path: Some("assets/animations/generated/b98ef565-3500-49e7-9935-f685fa9b2594.animation.ron"),
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("71071fc3-7a7f-454d-b9ab-93ebf0feccbe"),
|
||||
path: "assets/models/metal_stool_01_2k.gltf",
|
||||
label: "metal_stool_01_2k",
|
||||
id: ("113f74df-e39c-41d4-9b5b-e48efe541f7f"),
|
||||
path: "assets/models/RobotExpressive.glb",
|
||||
label: "RobotExpressive",
|
||||
kind_tag: "Model",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: SceneInstance,
|
||||
hierarchy_mode: SourceHierarchy,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: Some("assets/meshes/generated/113f74df-e39c-41d4-9b5b-e48efe541f7f.static_mesh.ron"),
|
||||
animation_manifest_path: Some("assets/animations/generated/113f74df-e39c-41d4-9b5b-e48efe541f7f.animation.ron"),
|
||||
default_animation_clip_id: Some("animation:clip:8:standing"),
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("3f63f359-45eb-4cb2-8970-71921cbd7bd0"),
|
||||
path: "assets/models/robot_expressive.glb",
|
||||
label: "robot_expressive",
|
||||
kind_tag: "Model",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: Some("assets/meshes/generated/71071fc3-7a7f-454d-b9ab-93ebf0feccbe.static_mesh.ron"),
|
||||
static_mesh_manifest_path: Some("assets/meshes/generated/3f63f359-45eb-4cb2-8970-71921cbd7bd0.static_mesh.ron"),
|
||||
animation_manifest_path: Some("assets/animations/generated/3f63f359-45eb-4cb2-8970-71921cbd7bd0.animation.ron"),
|
||||
default_animation_clip_id: Some("animation:clip:8:standing"),
|
||||
),
|
||||
dependencies: [
|
||||
"assets/models/metal_stool_01.bin",
|
||||
"assets/models/textures/metal_stool_01_arm_2k.jpg",
|
||||
"assets/models/textures/metal_stool_01_diff_2k.jpg",
|
||||
"assets/models/textures/metal_stool_01_nor_gl_2k.jpg",
|
||||
],
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("c4abe41c-ac88-4aec-8168-27e8a7c90583"),
|
||||
@@ -81,6 +138,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -97,6 +156,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -113,6 +174,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -120,7 +183,7 @@
|
||||
id: ("61802b85-fda9-4aff-94d9-fe5f0860c516"),
|
||||
path: "assets/levels/rendering_showcase.scn.ron",
|
||||
label: "rendering_showcase.scn",
|
||||
kind_tag: "Prefab",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
@@ -129,6 +192,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("706e604e-1a63-4e97-b35d-eeb1d88fe3a9"),
|
||||
path: "assets/levels/navigation_authoring_showcase.scn.ron",
|
||||
label: "navigation_authoring_showcase.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -136,7 +219,7 @@
|
||||
id: ("48bcef13-e6a6-4260-bb1b-c29787bd8c70"),
|
||||
path: "assets/levels/editor_scene 3.scn.ron",
|
||||
label: "editor_scene 3.scn",
|
||||
kind_tag: "Prefab",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
@@ -145,6 +228,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("f3dfcd11-aa5b-4fd4-872b-06832b865c99"),
|
||||
path: "assets/levels/audio_authoring_showcase.scn.ron",
|
||||
label: "audio_authoring_showcase.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -152,7 +255,7 @@
|
||||
id: ("5a2307d0-48e5-40d3-a5c9-527c0cfd30f4"),
|
||||
path: "assets/levels/editor_scene.scn.ron",
|
||||
label: "editor_scene.scn",
|
||||
kind_tag: "Prefab",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
@@ -161,6 +264,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("1b25d451-7b54-41d6-af00-d2e6950f502d"),
|
||||
path: "assets/levels/terrain_authoring_showcase.scn.ron",
|
||||
label: "terrain_authoring_showcase.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -168,6 +291,24 @@
|
||||
id: ("dc13ce01-c7ce-43c5-974c-0e659ae49ab9"),
|
||||
path: "assets/levels/editor_scene 2.scn.ron",
|
||||
label: "editor_scene 2.scn",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("c14f6240-5654-4e80-9edb-2b4c44cf8d61"),
|
||||
path: "assets/prefabs/example_variant.scn.ron",
|
||||
label: "example_variant.scn",
|
||||
kind_tag: "Prefab",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
@@ -177,6 +318,98 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("682191d6-59cd-46a1-9560-6cf7bc1583b2"),
|
||||
path: "assets/prefabs/example_nested.scn.ron",
|
||||
label: "example_nested.scn",
|
||||
kind_tag: "Prefab",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("862530b2-8111-4ebb-9078-29723c002e08"),
|
||||
path: "assets/prefabs/example_base.scn.ron",
|
||||
label: "example_base.scn",
|
||||
kind_tag: "Prefab",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("04a4e00e-4732-43db-8e99-9cd99b94667b"),
|
||||
path: "assets/animations/generated/113f74df-e39c-41d4-9b5b-e48efe541f7f.animation.ron",
|
||||
label: "113f74df-e39c-41d4-9b5b-e48efe541f7f.animation",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("4937e63f-923b-4270-bdfc-298d63bcb814"),
|
||||
path: "assets/animations/generated/3f63f359-45eb-4cb2-8970-71921cbd7bd0.animation.ron",
|
||||
label: "3f63f359-45eb-4cb2-8970-71921cbd7bd0.animation",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("28f1df44-6d24-4722-bf75-6969879995a4"),
|
||||
path: "assets/animations/generated/b98ef565-3500-49e7-9935-f685fa9b2594.animation.ron",
|
||||
label: "b98ef565-3500-49e7-9935-f685fa9b2594.animation",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -193,6 +426,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -209,6 +444,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("264e2010-0693-4d74-8440-99373c2cedb3"),
|
||||
path: "assets/navigation/generated/navigation_showcase_humanoid.nav.ron",
|
||||
label: "navigation_showcase_humanoid.nav",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -225,6 +480,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("cc2769da-c9a5-4cb3-866a-cc81d0688ee2"),
|
||||
path: "assets/materials/surface_tint_instance.ron",
|
||||
label: "surface_tint_instance",
|
||||
kind_tag: "Material",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -241,6 +516,80 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("d6cb4151-7124-4237-aaf9-f7f8abd5fb76"),
|
||||
path: "assets/materials/surface_tint.ron",
|
||||
label: "surface_tint",
|
||||
kind_tag: "Material",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("64fea29e-c123-4987-92dc-ca25f4dc7dea"),
|
||||
path: "assets/build_profiles/qa.ron",
|
||||
label: "qa",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("9213efe6-12c7-45a8-8b64-9e1699f76ba3"),
|
||||
path: "assets/build_profiles/development.ron",
|
||||
label: "development",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("de76f1c9-f05d-48d3-bb69-6b7ce05f29d8"),
|
||||
path: "assets/build_profiles/release.ron",
|
||||
label: "release",
|
||||
kind_tag: "Level",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -257,6 +606,8 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
@@ -273,6 +624,26 @@
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
(
|
||||
id: ("a72943d6-3e9d-4629-8887-5c02d99d4f92"),
|
||||
path: "assets/shaders/surface_tint.shader.ron",
|
||||
label: "surface_tint.shader",
|
||||
kind_tag: "ShaderSchema",
|
||||
import_settings: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: StaticAsset,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
),
|
||||
dependencies: [],
|
||||
),
|
||||
|
||||
@@ -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: [],
|
||||
)
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
|
||||
(
|
||||
version: 1,
|
||||
name: "Development",
|
||||
cargo_profile: Development,
|
||||
target: None,
|
||||
features: [],
|
||||
rendering_tier: "development",
|
||||
default_scene: Some("assets/levels/editor_scene.scn.ron"),
|
||||
output_dir: "dist/development",
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
(
|
||||
version: 1,
|
||||
name: "QA",
|
||||
cargo_profile: Qa,
|
||||
target: None,
|
||||
features: [],
|
||||
rendering_tier: "representative",
|
||||
default_scene: Some("assets/levels/editor_scene.scn.ron"),
|
||||
output_dir: "dist/qa",
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
(
|
||||
version: 1,
|
||||
name: "Release",
|
||||
cargo_profile: Release,
|
||||
target: None,
|
||||
features: [],
|
||||
rendering_tier: "shipping",
|
||||
default_scene: Some("assets/levels/editor_scene.scn.ron"),
|
||||
output_dir: "dist/release",
|
||||
)
|
||||
@@ -0,0 +1,52 @@
|
||||
(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::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",
|
||||
label: "Editor Audition Tone",
|
||||
source_path: Some("assets/audio/editor_audition_tone.ogg"),
|
||||
)),
|
||||
gain_db: -6.0,
|
||||
pitch: 1.0,
|
||||
looping: false,
|
||||
autoplay: true,
|
||||
spatial_blend: 1.0,
|
||||
attenuation: (
|
||||
min_distance: 1.0,
|
||||
max_distance: 18.0,
|
||||
rolloff: Inverse,
|
||||
rolloff_factor: 1.0,
|
||||
),
|
||||
bus: "sfx",
|
||||
),
|
||||
"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::ActorId": ("audio-showcase-listener"),
|
||||
"shared::components::ActorKind": AudioListener,
|
||||
"shared::components::AudioListenerDesc": (
|
||||
enabled: true,
|
||||
priority: 100,
|
||||
ear_gap: 0.2,
|
||||
),
|
||||
"shared::components::LevelObject": (),
|
||||
}),
|
||||
},
|
||||
)
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
+1877
-1604
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)),
|
||||
}),
|
||||
},
|
||||
)
|
||||
@@ -1,17 +1,16 @@
|
||||
(schema_version: 2,
|
||||
resources: {},
|
||||
entities: {
|
||||
4294968001: (
|
||||
components: {
|
||||
"bevy_ecs::name::Name": "Fog Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
(schema_version: 4,resources: {
|
||||
},
|
||||
entities: {
|
||||
4294968001: (components: {
|
||||
"bevy_ecs::name::Name": "Fog Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (0.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (6.0, 3.0, 6.0),
|
||||
priority: 0,
|
||||
blend_distance: 2.0,
|
||||
@@ -23,19 +22,17 @@
|
||||
profile: None,
|
||||
label: Some("Foggy courtyard"),
|
||||
),
|
||||
},
|
||||
),
|
||||
4294968002: (
|
||||
components: {
|
||||
"bevy_ecs::name::Name": "Dark Exposure Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
}),
|
||||
4294968002: (components: {
|
||||
"bevy_ecs::name::Name": "Dark Exposure Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (14.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (4.0, 2.5, 4.0),
|
||||
priority: 5,
|
||||
blend_distance: 1.5,
|
||||
@@ -47,19 +44,17 @@
|
||||
profile: Some("assets/rendering_profiles/cave_dark.ron"),
|
||||
label: Some("Cave mouth"),
|
||||
),
|
||||
},
|
||||
),
|
||||
4294968003: (
|
||||
components: {
|
||||
"bevy_ecs::name::Name": "Vignette FX Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
}),
|
||||
4294968003: (components: {
|
||||
"bevy_ecs::name::Name": "Vignette FX Volume",
|
||||
"bevy_transform::components::transform::Transform": (
|
||||
translation: (-12.0, 2.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
"shared::components::ActorKind": PostProcessVolume,
|
||||
"shared::components::LevelObject": (),
|
||||
"shared::components::PostProcessVolumeDesc": (
|
||||
half_extents: (5.0, 2.0, 5.0),
|
||||
priority: 2,
|
||||
blend_distance: 2.0,
|
||||
@@ -68,7 +63,6 @@
|
||||
profile: None,
|
||||
label: Some("Vignette demo"),
|
||||
),
|
||||
},
|
||||
),
|
||||
},
|
||||
)
|
||||
}),
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,60 @@
|
||||
(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"),
|
||||
)),
|
||||
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.1691, -0.0670, 0.7244, 0.6648),
|
||||
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,
|
||||
),
|
||||
}),
|
||||
})
|
||||
@@ -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: [],
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -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: [],
|
||||
),
|
||||
)
|
||||
)
|
||||
@@ -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: 3,
|
||||
asset_id: "113f74df-e39c-41d4-9b5b-e48efe541f7f",
|
||||
label: "RobotExpressive",
|
||||
source: (
|
||||
path: "assets/models/RobotExpressive.glb",
|
||||
format: "glb",
|
||||
fingerprint: (
|
||||
byte_len: 463988,
|
||||
modified_unix_secs: 1783799272,
|
||||
),
|
||||
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: 3,
|
||||
asset_id: "3f63f359-45eb-4cb2-8970-71921cbd7bd0",
|
||||
label: "robot_expressive",
|
||||
source: (
|
||||
path: "assets/models/robot_expressive.glb",
|
||||
format: "glb",
|
||||
fingerprint: (
|
||||
byte_len: 463988,
|
||||
modified_unix_secs: 1783750957,
|
||||
),
|
||||
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,55 +0,0 @@
|
||||
(
|
||||
schema_version: 1,
|
||||
asset_id: "71071fc3-7a7f-454d-b9ab-93ebf0feccbe",
|
||||
label: "metal_stool_01_2k",
|
||||
source: (
|
||||
path: "assets/models/metal_stool_01_2k.gltf",
|
||||
format: "gltf",
|
||||
fingerprint: (
|
||||
byte_len: 2790,
|
||||
modified_unix_secs: 1780734867,
|
||||
),
|
||||
dependencies: [
|
||||
"assets/models/metal_stool_01.bin",
|
||||
"assets/models/textures/metal_stool_01_arm_2k.jpg",
|
||||
"assets/models/textures/metal_stool_01_diff_2k.jpg",
|
||||
"assets/models/textures/metal_stool_01_nor_gl_2k.jpg",
|
||||
],
|
||||
),
|
||||
import: (
|
||||
scale: 1.0,
|
||||
generate_collider: true,
|
||||
lod0_only: true,
|
||||
placement_mode: SceneInstance,
|
||||
hierarchy_mode: SingleActor,
|
||||
material_policy: SourceMaterials,
|
||||
),
|
||||
metadata: (
|
||||
mesh_count: 1,
|
||||
material_count: 1,
|
||||
node_count: 1,
|
||||
animation_count: 0,
|
||||
skin_count: 0,
|
||||
light_count: 0,
|
||||
camera_count: 0,
|
||||
),
|
||||
parts: [
|
||||
(
|
||||
id: "mesh:mesh0_primitive0",
|
||||
name: "metal_stool_01 / Primitive 0",
|
||||
mesh_label: "Mesh0/Primitive0",
|
||||
material_id: Some("material:material0"),
|
||||
material_slot_name: "metal_stool_01",
|
||||
material_label: Some("Material0"),
|
||||
local_transform: (
|
||||
translation: (0.0, 0.0, 0.0),
|
||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||
scale: (1.0, 1.0, 1.0),
|
||||
),
|
||||
source_node: Some("Node0"),
|
||||
source_mesh: Some("Mesh0"),
|
||||
source_material: Some("metal_stool_01"),
|
||||
),
|
||||
],
|
||||
warnings: [],
|
||||
)
|
||||
@@ -1,5 +1,5 @@
|
||||
(
|
||||
schema_version: 1,
|
||||
schema_version: 3,
|
||||
asset_id: "b98ef565-3500-49e7-9935-f685fa9b2594",
|
||||
label: "painted_wooden_chair_02_2k",
|
||||
source: (
|
||||
@@ -30,7 +30,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,6 +44,7 @@
|
||||
source_node: Some("Node1"),
|
||||
source_mesh: Some("Mesh1"),
|
||||
source_material: Some("painted_wooden_chair_02"),
|
||||
skinned: false,
|
||||
),
|
||||
],
|
||||
warnings: [],
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
# RobotExpressive License And Attribution
|
||||
|
||||
`robot_expressive.glb` is the RobotExpressive model from the Three.js example assets.
|
||||
|
||||
- Model: Tomas Laulhe (Quaternius)
|
||||
- Modifications and glTF conversion: Don McCurdy
|
||||
- License: CC0 1.0 Universal
|
||||
- Source: https://github.com/mrdoob/three.js/tree/dev/examples/models/gltf/RobotExpressive
|
||||
- Imported source SHA-256: `047f5e5fb3bb6d378bd1df16ca6137f2a596c99b3a1b5690b4020c05aaf6f319`
|
||||
|
||||
The upstream modifications add facial-expression morph targets, convert the source with FBX2GLTF,
|
||||
remove duplicate materials, and reduce material metalness.
|
||||
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,
|
||||
),
|
||||
)
|
||||
@@ -0,0 +1,10 @@
|
||||
# Prefab fixtures
|
||||
|
||||
The `example_base` -> `example_nested` -> `example_variant` chain is the production-format
|
||||
fixture for linked prefab ownership, nested stable actor paths, and variant override layering.
|
||||
The variant hides `base-mesh` through an `EditorVisibility` component override targeted as
|
||||
`nested-link / base-link / base-mesh` when the variant is placed in a scene.
|
||||
|
||||
Keep these files loadable by the editor and valid under `cargo validate-levels`. Broken-source,
|
||||
cycle, and conflict fixtures belong in temporary test projects so the shipped asset tree remains
|
||||
healthy.
|
||||
@@ -0,0 +1,17 @@
|
||||
(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": (),
|
||||
}),
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
(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": (
|
||||
asset_id: "11111111-1111-4111-8111-111111111111",
|
||||
source_path: "assets/prefabs/example_base.scn.ron",
|
||||
overrides_ron: None,
|
||||
),
|
||||
}),
|
||||
},
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
(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": (
|
||||
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:[])"),
|
||||
),
|
||||
}),
|
||||
},
|
||||
)
|
||||
@@ -1,8 +1,13 @@
|
||||
(
|
||||
version: 1,
|
||||
project_id: "blacksite-foundation",
|
||||
name: "Bevy FPS Foundation",
|
||||
project_kind: Game,
|
||||
template_version: 1,
|
||||
capabilities: ["editor", "gameplay", "rendering", "audio", "solari"],
|
||||
default_level: "assets/levels/editor_scene.scn.ron",
|
||||
asset_roots: [
|
||||
"assets/audio",
|
||||
"assets/models",
|
||||
"assets/textures",
|
||||
"assets/materials",
|
||||
@@ -29,6 +34,31 @@
|
||||
shadow_first_cascade: 6.0,
|
||||
shadow_max_distance: 220.0,
|
||||
),
|
||||
audio: (
|
||||
buses: [
|
||||
(
|
||||
id: "master",
|
||||
label: "Master",
|
||||
parent: None,
|
||||
gain_db: 0.0,
|
||||
muted: false,
|
||||
),
|
||||
(
|
||||
id: "music",
|
||||
label: "Music",
|
||||
parent: Some("master"),
|
||||
gain_db: 0.0,
|
||||
muted: false,
|
||||
),
|
||||
(
|
||||
id: "sfx",
|
||||
label: "SFX",
|
||||
parent: Some("master"),
|
||||
gain_db: 0.0,
|
||||
muted: false,
|
||||
),
|
||||
],
|
||||
),
|
||||
physics: (
|
||||
player_radius: 0.4,
|
||||
player_length: 1.0,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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: [],
|
||||
)
|
||||
)
|
||||
@@ -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: [],
|
||||
)
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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: [],
|
||||
)
|
||||
)
|
||||
@@ -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"
|
||||
@@ -0,0 +1,762 @@
|
||||
//! Blacksite Surface ABI v1.
|
||||
//!
|
||||
//! The authoring layer persists named values. This crate validates and packs them into a fixed GPU
|
||||
//! contract and supplies the same surface evaluator source to raster and Solari integrations.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
||||
use bevy::mesh::MeshVertexBufferLayoutRef;
|
||||
use bevy::pbr::{
|
||||
ExtendedMaterial, MaterialExtension, MaterialExtensionKey, MaterialExtensionPipeline,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::extract_resource::ExtractResource;
|
||||
use bevy::render::render_resource::{
|
||||
AsBindGroup, RenderPipelineDescriptor, ShaderType, SpecializedMeshPipelineError,
|
||||
};
|
||||
use bevy::shader::{Shader, ShaderRef};
|
||||
use shared::{
|
||||
asset_server_path, material_from_desc, HydratedRendererMaterialBinding, MaterialAsset,
|
||||
MaterialInstanceAsset, MaterialParameterValue, MaterialRef, ShaderPropertyType,
|
||||
ShaderSchemaAsset, MATERIAL_INSTANCE_SCHEMA_VERSION,
|
||||
};
|
||||
|
||||
pub const SURFACE_ABI_VERSION: u32 = 1;
|
||||
pub const SURFACE_PARAMETER_LANES: usize = 16;
|
||||
pub const SURFACE_TEXTURE_SLOTS: usize = 8;
|
||||
pub const DEFAULT_SURFACE_SHADER_PATH: &str = "shaders/blacksite_surface.wgsl";
|
||||
|
||||
#[derive(ShaderType, Reflect, Debug, Clone, Copy, PartialEq)]
|
||||
pub struct SurfaceUniform {
|
||||
pub shader_id: u32,
|
||||
pub flags: u32,
|
||||
pub alpha_cutoff: f32,
|
||||
pub abi_version: u32,
|
||||
pub params: [Vec4; SURFACE_PARAMETER_LANES],
|
||||
pub uv_transforms: [Vec4; SURFACE_TEXTURE_SLOTS],
|
||||
}
|
||||
|
||||
impl Default for SurfaceUniform {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
shader_id: 0,
|
||||
flags: 0,
|
||||
alpha_cutoff: 0.5,
|
||||
abi_version: SURFACE_ABI_VERSION,
|
||||
params: [Vec4::ZERO; SURFACE_PARAMETER_LANES],
|
||||
uv_transforms: [Vec4::new(1.0, 1.0, 0.0, 0.0); SURFACE_TEXTURE_SLOTS],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||
pub struct SurfaceExtensionKey {
|
||||
shader: AssetId<Shader>,
|
||||
}
|
||||
|
||||
impl From<&SurfaceExtension> for SurfaceExtensionKey {
|
||||
fn from(extension: &SurfaceExtension) -> Self {
|
||||
Self {
|
||||
shader: extension.shader.id(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Asset, AsBindGroup, Reflect, Debug, Clone, Default)]
|
||||
#[bind_group_data(SurfaceExtensionKey)]
|
||||
pub struct SurfaceExtension {
|
||||
#[uniform(100)]
|
||||
pub uniform: SurfaceUniform,
|
||||
#[texture(101)]
|
||||
#[sampler(102)]
|
||||
pub texture0: Option<Handle<Image>>,
|
||||
#[texture(103)]
|
||||
#[sampler(104)]
|
||||
pub texture1: Option<Handle<Image>>,
|
||||
#[texture(105)]
|
||||
#[sampler(106)]
|
||||
pub texture2: Option<Handle<Image>>,
|
||||
#[texture(107)]
|
||||
#[sampler(108)]
|
||||
pub texture3: Option<Handle<Image>>,
|
||||
#[texture(109)]
|
||||
#[sampler(110)]
|
||||
pub texture4: Option<Handle<Image>>,
|
||||
#[texture(111)]
|
||||
#[sampler(112)]
|
||||
pub texture5: Option<Handle<Image>>,
|
||||
#[texture(113)]
|
||||
#[sampler(114)]
|
||||
pub texture6: Option<Handle<Image>>,
|
||||
#[texture(115)]
|
||||
#[sampler(116)]
|
||||
pub texture7: Option<Handle<Image>>,
|
||||
#[reflect(ignore)]
|
||||
pub shader: Handle<Shader>,
|
||||
}
|
||||
|
||||
impl SurfaceExtension {
|
||||
pub fn set_texture(&mut self, index: usize, handle: Option<Handle<Image>>) {
|
||||
match index {
|
||||
0 => self.texture0 = handle,
|
||||
1 => self.texture1 = handle,
|
||||
2 => self.texture2 = handle,
|
||||
3 => self.texture3 = handle,
|
||||
4 => self.texture4 = handle,
|
||||
5 => self.texture5 = handle,
|
||||
6 => self.texture6 = handle,
|
||||
7 => self.texture7 = handle,
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl MaterialExtension for SurfaceExtension {
|
||||
fn fragment_shader() -> ShaderRef {
|
||||
DEFAULT_SURFACE_SHADER_PATH.into()
|
||||
}
|
||||
|
||||
fn deferred_fragment_shader() -> ShaderRef {
|
||||
DEFAULT_SURFACE_SHADER_PATH.into()
|
||||
}
|
||||
|
||||
fn prepass_fragment_shader() -> ShaderRef {
|
||||
DEFAULT_SURFACE_SHADER_PATH.into()
|
||||
}
|
||||
|
||||
fn specialize(
|
||||
_pipeline: &MaterialExtensionPipeline,
|
||||
descriptor: &mut RenderPipelineDescriptor,
|
||||
_layout: &MeshVertexBufferLayoutRef,
|
||||
key: MaterialExtensionKey<Self>,
|
||||
) -> Result<(), SpecializedMeshPipelineError> {
|
||||
if let (AssetId::Uuid { uuid }, Some(fragment)) =
|
||||
(key.bind_group_data.shader, descriptor.fragment.as_mut())
|
||||
{
|
||||
fragment.shader = Handle::Uuid(uuid, Default::default());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
pub type SurfaceMaterial = ExtendedMaterial<StandardMaterial, SurfaceExtension>;
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
pub struct SurfaceMaterialCache {
|
||||
handles: HashMap<MaterialRef, Handle<SurfaceMaterial>>,
|
||||
standard_handles: HashMap<MaterialRef, Handle<StandardMaterial>>,
|
||||
revisions: HashMap<MaterialRef, u64>,
|
||||
standard_only: HashMap<MaterialRef, u64>,
|
||||
dependencies: HashMap<MaterialRef, Vec<String>>,
|
||||
failed_revisions: HashMap<MaterialRef, u64>,
|
||||
}
|
||||
|
||||
enum BuiltRendererMaterial {
|
||||
Standard(Box<StandardMaterial>),
|
||||
Surface(Box<SurfaceMaterial>),
|
||||
}
|
||||
|
||||
#[derive(Resource, Default, Debug, Clone)]
|
||||
pub struct SurfaceDiagnostics(pub Vec<String>);
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct SurfaceEvaluatorRecord {
|
||||
pub shader_id: u32,
|
||||
pub evaluator_source: String,
|
||||
pub revision: u64,
|
||||
pub alpha_mode: shared::MaterialAlphaMode,
|
||||
}
|
||||
|
||||
/// Active, validated evaluator generation consumed by both raster and Solari render worlds.
|
||||
#[derive(Resource, ExtractResource, Default, Debug, Clone)]
|
||||
pub struct SurfaceEvaluatorRegistry {
|
||||
pub evaluators: HashMap<u32, SurfaceEvaluatorRecord>,
|
||||
}
|
||||
|
||||
pub struct SurfaceMaterialPlugin;
|
||||
|
||||
impl Plugin for SurfaceMaterialPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins(MaterialPlugin::<SurfaceMaterial>::default())
|
||||
.init_resource::<SurfaceMaterialCache>()
|
||||
.init_resource::<SurfaceDiagnostics>()
|
||||
.init_resource::<SurfaceEvaluatorRegistry>()
|
||||
.add_systems(Update, sync_surface_material_bindings);
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments, clippy::type_complexity)]
|
||||
fn sync_surface_material_bindings(
|
||||
mut commands: Commands,
|
||||
asset_server: Res<AssetServer>,
|
||||
mut shaders: ResMut<Assets<Shader>>,
|
||||
mut standard_materials: ResMut<Assets<StandardMaterial>>,
|
||||
mut surface_materials: ResMut<Assets<SurfaceMaterial>>,
|
||||
mut cache: ResMut<SurfaceMaterialCache>,
|
||||
mut diagnostics: ResMut<SurfaceDiagnostics>,
|
||||
mut evaluator_registry: ResMut<SurfaceEvaluatorRegistry>,
|
||||
bindings: Query<(
|
||||
Entity,
|
||||
&HydratedRendererMaterialBinding,
|
||||
Option<&MeshMaterial3d<StandardMaterial>>,
|
||||
Option<&MeshMaterial3d<SurfaceMaterial>>,
|
||||
)>,
|
||||
) {
|
||||
for (entity, binding, standard_handle, surface_handle) in &bindings {
|
||||
let Some(reference) = binding.effective_material.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
let Some(path) = reference.0.source_path.as_deref() else {
|
||||
continue;
|
||||
};
|
||||
let dependencies = cache
|
||||
.dependencies
|
||||
.get(reference)
|
||||
.cloned()
|
||||
.unwrap_or_else(|| vec![path.to_string()]);
|
||||
let revision = dependency_revision(&dependencies);
|
||||
if cache.failed_revisions.get(reference) == Some(&revision) {
|
||||
continue;
|
||||
}
|
||||
if cache.standard_only.get(reference) == Some(&revision) {
|
||||
if let Some(handle) = cache.standard_handles.get(reference).cloned() {
|
||||
if standard_handle.is_none_or(|current| current.0 != handle)
|
||||
|| surface_handle.is_some()
|
||||
{
|
||||
commands
|
||||
.entity(entity)
|
||||
.remove::<MeshMaterial3d<SurfaceMaterial>>()
|
||||
.insert(MeshMaterial3d(handle));
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
let stale = cache.revisions.get(reference) != Some(&revision);
|
||||
let handle = if !stale {
|
||||
cache.handles.get(reference).cloned()
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let handle = match handle {
|
||||
Some(handle) => handle,
|
||||
None => match build_surface_material(
|
||||
reference,
|
||||
path,
|
||||
&asset_server,
|
||||
&mut shaders,
|
||||
&mut standard_materials,
|
||||
standard_handle,
|
||||
&mut evaluator_registry,
|
||||
) {
|
||||
Ok(BuiltRendererMaterial::Surface(material)) => {
|
||||
let material = *material;
|
||||
cache.standard_only.remove(reference);
|
||||
cache.standard_handles.remove(reference);
|
||||
cache.failed_revisions.remove(reference);
|
||||
if let Some(existing) = cache.handles.get(reference).cloned() {
|
||||
if let Some(mut slot) = surface_materials.get_mut(&existing) {
|
||||
*slot = material;
|
||||
}
|
||||
existing
|
||||
} else {
|
||||
let handle = surface_materials.add(material);
|
||||
cache.handles.insert(reference.clone(), handle.clone());
|
||||
handle
|
||||
}
|
||||
}
|
||||
Ok(BuiltRendererMaterial::Standard(material)) => {
|
||||
let material = *material;
|
||||
// Plain Material assets stay on Bevy's StandardMaterial path, while still
|
||||
// sharing one live-updated handle across every renderer slot.
|
||||
let handle = standard_handle
|
||||
.map(|handle| handle.0.clone())
|
||||
.or_else(|| cache.standard_handles.get(reference).cloned())
|
||||
.unwrap_or_else(|| standard_materials.add(material.clone()));
|
||||
if let Some(mut slot) = standard_materials.get_mut(&handle) {
|
||||
*slot = material;
|
||||
}
|
||||
cache.handles.remove(reference);
|
||||
cache.revisions.remove(reference);
|
||||
cache
|
||||
.standard_handles
|
||||
.insert(reference.clone(), handle.clone());
|
||||
let next_dependencies =
|
||||
material_dependency_paths(path).unwrap_or_else(|_| vec![path.to_string()]);
|
||||
let next_revision = dependency_revision(&next_dependencies);
|
||||
cache
|
||||
.dependencies
|
||||
.insert(reference.clone(), next_dependencies);
|
||||
cache.standard_only.insert(reference.clone(), next_revision);
|
||||
cache.failed_revisions.remove(reference);
|
||||
evaluator_registry
|
||||
.evaluators
|
||||
.remove(&stable_shader_id(reference));
|
||||
if standard_handle.is_none_or(|current| current.0 != handle)
|
||||
|| surface_handle.is_some()
|
||||
{
|
||||
commands
|
||||
.entity(entity)
|
||||
.remove::<MeshMaterial3d<SurfaceMaterial>>()
|
||||
.insert(MeshMaterial3d(handle));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
Err(error) => {
|
||||
cache.failed_revisions.insert(reference.clone(), revision);
|
||||
diagnostics.0.push(format!(
|
||||
"material {} could not build Surface ABI: {error}",
|
||||
reference.0.label
|
||||
));
|
||||
continue;
|
||||
}
|
||||
},
|
||||
};
|
||||
let next_dependencies =
|
||||
material_dependency_paths(path).unwrap_or_else(|_| vec![path.to_string()]);
|
||||
let next_revision = dependency_revision(&next_dependencies);
|
||||
cache
|
||||
.dependencies
|
||||
.insert(reference.clone(), next_dependencies);
|
||||
cache.revisions.insert(reference.clone(), next_revision);
|
||||
if surface_handle.is_none_or(|current| current.0 != handle) {
|
||||
commands
|
||||
.entity(entity)
|
||||
.remove::<MeshMaterial3d<StandardMaterial>>()
|
||||
.insert(MeshMaterial3d(handle));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn build_surface_material(
|
||||
reference: &MaterialRef,
|
||||
path: &str,
|
||||
asset_server: &AssetServer,
|
||||
shaders: &mut Assets<Shader>,
|
||||
standard_materials: &mut Assets<StandardMaterial>,
|
||||
existing_standard: Option<&MeshMaterial3d<StandardMaterial>>,
|
||||
evaluator_registry: &mut SurfaceEvaluatorRegistry,
|
||||
) -> Result<BuiltRendererMaterial, String> {
|
||||
let (mut asset, instance) = match MaterialAsset::load_from_path(path) {
|
||||
Ok(asset) => (asset, None),
|
||||
Err(_) => {
|
||||
let instance = MaterialInstanceAsset::load_from_path(path)?;
|
||||
if instance.schema_version != MATERIAL_INSTANCE_SCHEMA_VERSION {
|
||||
return Err(format!(
|
||||
"unsupported material-instance schema {}",
|
||||
instance.schema_version
|
||||
));
|
||||
}
|
||||
let base_path = instance
|
||||
.base
|
||||
.0
|
||||
.source_path
|
||||
.as_deref()
|
||||
.ok_or_else(|| "material instance base has no loadable path".to_string())?;
|
||||
(MaterialAsset::load_from_path(base_path)?, Some(instance))
|
||||
}
|
||||
};
|
||||
if let Some(instance) = instance.as_ref() {
|
||||
instance.apply_to(&mut asset.material);
|
||||
}
|
||||
let schema_path = asset
|
||||
.shader_ref
|
||||
.as_ref()
|
||||
.and_then(|reference| reference.source_path.as_deref())
|
||||
.or(asset.material.shader.schema_path.as_deref())
|
||||
.or(asset
|
||||
.shader
|
||||
.as_deref()
|
||||
.filter(|path| path.ends_with(".ron")));
|
||||
let schema = schema_path
|
||||
.map(ShaderSchemaAsset::load_from_path)
|
||||
.transpose()?;
|
||||
let evaluator_source = schema
|
||||
.as_ref()
|
||||
.and_then(|schema| schema.wgsl_path.as_deref())
|
||||
.map(fs::read_to_string)
|
||||
.transpose()
|
||||
.map_err(|error| format!("could not read surface WGSL: {error}"))?;
|
||||
|
||||
let mut base = existing_standard
|
||||
.and_then(|handle| standard_materials.get(&handle.0).cloned())
|
||||
.unwrap_or_else(|| material_from_desc(asset_server, &asset.material));
|
||||
base.alpha_mode = match asset.render_state.alpha_mode {
|
||||
shared::MaterialAlphaMode::Opaque => AlphaMode::Opaque,
|
||||
shared::MaterialAlphaMode::Cutout => AlphaMode::Mask(asset.render_state.alpha_cutoff),
|
||||
};
|
||||
base.cull_mode =
|
||||
(!asset.render_state.double_sided).then_some(bevy::render::render_resource::Face::Back);
|
||||
|
||||
let Some(evaluator) = evaluator_source.as_deref() else {
|
||||
return Ok(BuiltRendererMaterial::Standard(Box::new(base)));
|
||||
};
|
||||
validate_surface_evaluator(evaluator)?;
|
||||
let runtime_shader_id = stable_shader_id(reference);
|
||||
evaluator_registry.evaluators.insert(
|
||||
runtime_shader_id,
|
||||
SurfaceEvaluatorRecord {
|
||||
shader_id: runtime_shader_id,
|
||||
evaluator_source: evaluator.to_string(),
|
||||
revision: evaluator_revision(evaluator),
|
||||
alpha_mode: asset.render_state.alpha_mode,
|
||||
},
|
||||
);
|
||||
let virtual_path = format!("generated://surface/{}.wgsl", reference.0.asset_id);
|
||||
let shader_uuid = shader_uuid_for_material(reference);
|
||||
let shader_id = AssetId::<Shader>::Uuid { uuid: shader_uuid };
|
||||
shaders
|
||||
.insert(
|
||||
shader_id,
|
||||
Shader::from_wgsl(compose_surface_shader(evaluator), virtual_path),
|
||||
)
|
||||
.map_err(|error| format!("could not replace generated surface shader: {error}"))?;
|
||||
let shader = Handle::Uuid(shader_uuid, Default::default());
|
||||
|
||||
let mut extension = SurfaceExtension {
|
||||
shader,
|
||||
..default()
|
||||
};
|
||||
extension.uniform.alpha_cutoff = asset.render_state.alpha_cutoff;
|
||||
extension.uniform.shader_id = runtime_shader_id;
|
||||
if let Some(schema) = schema.as_ref() {
|
||||
pack_schema_values(
|
||||
&mut extension,
|
||||
schema,
|
||||
&asset.material,
|
||||
instance.as_ref(),
|
||||
asset_server,
|
||||
)?;
|
||||
}
|
||||
Ok(BuiltRendererMaterial::Surface(Box::new(ExtendedMaterial {
|
||||
base,
|
||||
extension,
|
||||
})))
|
||||
}
|
||||
|
||||
fn material_dependency_paths(path: &str) -> Result<Vec<String>, String> {
|
||||
let mut dependencies = vec![path.to_string()];
|
||||
let asset = match MaterialAsset::load_from_path(path) {
|
||||
Ok(asset) => asset,
|
||||
Err(_) => {
|
||||
let instance = MaterialInstanceAsset::load_from_path(path)?;
|
||||
let base_path = instance
|
||||
.base
|
||||
.0
|
||||
.source_path
|
||||
.as_deref()
|
||||
.ok_or_else(|| "material instance base has no loadable path".to_string())?;
|
||||
dependencies.push(base_path.to_string());
|
||||
MaterialAsset::load_from_path(base_path)?
|
||||
}
|
||||
};
|
||||
let schema_path = asset
|
||||
.shader_ref
|
||||
.as_ref()
|
||||
.and_then(|reference| reference.source_path.as_deref())
|
||||
.or(asset.material.shader.schema_path.as_deref())
|
||||
.or(asset
|
||||
.shader
|
||||
.as_deref()
|
||||
.filter(|path| path.ends_with(".ron")));
|
||||
if let Some(schema_path) = schema_path {
|
||||
dependencies.push(schema_path.to_string());
|
||||
if let Some(wgsl_path) = ShaderSchemaAsset::load_from_path(schema_path)?.wgsl_path {
|
||||
dependencies.push(wgsl_path);
|
||||
}
|
||||
}
|
||||
dependencies.sort();
|
||||
dependencies.dedup();
|
||||
Ok(dependencies)
|
||||
}
|
||||
|
||||
fn dependency_revision(paths: &[String]) -> u64 {
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for path in paths {
|
||||
for byte in path.bytes() {
|
||||
hash ^= u64::from(byte);
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
match fs::metadata(path) {
|
||||
Ok(metadata) => {
|
||||
for byte in metadata.len().to_le_bytes() {
|
||||
hash ^= u64::from(byte);
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
if let Ok(modified) = metadata.modified() {
|
||||
if let Ok(duration) = modified.duration_since(std::time::UNIX_EPOCH) {
|
||||
for byte in duration.as_nanos().to_le_bytes() {
|
||||
hash ^= u64::from(byte);
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_) => {
|
||||
hash ^= u64::MAX;
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
}
|
||||
}
|
||||
hash
|
||||
}
|
||||
|
||||
fn stable_shader_id(reference: &MaterialRef) -> u32 {
|
||||
let mut hash = 0x811c9dc5u32;
|
||||
for byte in reference.0.asset_id.bytes() {
|
||||
hash ^= u32::from(byte);
|
||||
hash = hash.wrapping_mul(0x01000193);
|
||||
}
|
||||
hash
|
||||
}
|
||||
|
||||
fn evaluator_revision(source: &str) -> u64 {
|
||||
let mut hash = 0xcbf29ce484222325u64;
|
||||
for byte in source.bytes() {
|
||||
hash ^= u64::from(byte);
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
hash
|
||||
}
|
||||
|
||||
fn shader_uuid_for_material(reference: &MaterialRef) -> uuid::Uuid {
|
||||
if let Ok(source) = uuid::Uuid::parse_str(&reference.0.asset_id) {
|
||||
let mixed = source.as_u128() ^ 0x7f8c_4e90_f9ab_4f28_9b44_47c1_b2d5_5ac1u128;
|
||||
return uuid::Uuid::from_u128(mixed);
|
||||
}
|
||||
let mut bytes = [0u8; 16];
|
||||
for (index, byte) in reference.0.asset_id.bytes().enumerate() {
|
||||
bytes[index % 16] = bytes[index % 16].wrapping_mul(31).wrapping_add(byte);
|
||||
}
|
||||
uuid::Uuid::from_bytes(bytes)
|
||||
}
|
||||
|
||||
fn pack_schema_values(
|
||||
extension: &mut SurfaceExtension,
|
||||
schema: &ShaderSchemaAsset,
|
||||
material: &shared::MaterialDesc,
|
||||
instance: Option<&MaterialInstanceAsset>,
|
||||
asset_server: &AssetServer,
|
||||
) -> Result<(), String> {
|
||||
let mut numeric_index = 0usize;
|
||||
let mut texture_index = 0usize;
|
||||
for property in &schema.parameters {
|
||||
if matches!(property.property_type, ShaderPropertyType::Texture) {
|
||||
if texture_index >= SURFACE_TEXTURE_SLOTS {
|
||||
return Err(format!(
|
||||
"surface schema exceeds {SURFACE_TEXTURE_SLOTS} textures"
|
||||
));
|
||||
}
|
||||
let binding = instance
|
||||
.and_then(|instance| {
|
||||
instance
|
||||
.textures
|
||||
.iter()
|
||||
.find(|value| value.name == property.name)
|
||||
})
|
||||
.or_else(|| {
|
||||
material
|
||||
.textures
|
||||
.iter()
|
||||
.find(|value| value.name == property.name)
|
||||
});
|
||||
let handle = binding
|
||||
.and_then(|binding| binding.texture.as_ref())
|
||||
.and_then(|reference| reference.source_path.as_deref())
|
||||
.map(asset_server_path)
|
||||
.map(|path| asset_server.load(path));
|
||||
extension.set_texture(texture_index, handle);
|
||||
texture_index += 1;
|
||||
continue;
|
||||
}
|
||||
if numeric_index >= SURFACE_PARAMETER_LANES {
|
||||
return Err(format!(
|
||||
"surface schema exceeds {SURFACE_PARAMETER_LANES} parameter lanes"
|
||||
));
|
||||
}
|
||||
let value = instance
|
||||
.and_then(|instance| {
|
||||
instance
|
||||
.parameters
|
||||
.iter()
|
||||
.find(|value| value.name == property.name)
|
||||
})
|
||||
.or_else(|| {
|
||||
material
|
||||
.parameters
|
||||
.iter()
|
||||
.find(|value| value.name == property.name)
|
||||
})
|
||||
.or_else(|| {
|
||||
schema
|
||||
.default_values
|
||||
.iter()
|
||||
.find(|value| value.name == property.name)
|
||||
});
|
||||
extension.uniform.params[numeric_index] = value
|
||||
.map(|value| parameter_lane(&value.value, &property.property_type))
|
||||
.transpose()?
|
||||
.unwrap_or(Vec4::ZERO);
|
||||
numeric_index += 1;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn parameter_lane(
|
||||
value: &MaterialParameterValue,
|
||||
property_type: &ShaderPropertyType,
|
||||
) -> Result<Vec4, String> {
|
||||
match (value, property_type) {
|
||||
(MaterialParameterValue::Bool(value), ShaderPropertyType::Bool) => {
|
||||
Ok(Vec4::new(u32::from(*value) as f32, 0.0, 0.0, 0.0))
|
||||
}
|
||||
(MaterialParameterValue::Float(value), ShaderPropertyType::Float { .. }) => {
|
||||
Ok(Vec4::new(*value, 0.0, 0.0, 0.0))
|
||||
}
|
||||
(MaterialParameterValue::Vec2(value), ShaderPropertyType::Vec2) => {
|
||||
Ok(Vec4::new(value.x, value.y, 0.0, 0.0))
|
||||
}
|
||||
(MaterialParameterValue::Vec3(value), ShaderPropertyType::Vec3) => Ok(value.extend(0.0)),
|
||||
(MaterialParameterValue::Color(value), ShaderPropertyType::Color) => {
|
||||
Ok(Vec4::new(value.r, value.g, value.b, value.a))
|
||||
}
|
||||
(MaterialParameterValue::Enum(value), ShaderPropertyType::Enum { options }) => {
|
||||
let index = options
|
||||
.iter()
|
||||
.position(|option| option == value)
|
||||
.ok_or_else(|| format!("enum value `{value}` is not declared by the schema"))?;
|
||||
Ok(Vec4::new(index as f32, 0.0, 0.0, 0.0))
|
||||
}
|
||||
_ => Err("material value does not match shader schema type".into()),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate_surface_evaluator(source: &str) -> Result<(), String> {
|
||||
if !source.contains("fn evaluate(") {
|
||||
return Err("surface WGSL must define `fn evaluate(`".into());
|
||||
}
|
||||
for forbidden in [
|
||||
"@group",
|
||||
"@binding",
|
||||
"@vertex",
|
||||
"@fragment",
|
||||
"@compute",
|
||||
"var<",
|
||||
"rayQuery",
|
||||
"dpdx",
|
||||
"dpdy",
|
||||
"fwidth",
|
||||
"discard",
|
||||
"Barrier",
|
||||
"subgroup",
|
||||
"textureStore",
|
||||
"atomic",
|
||||
] {
|
||||
if source.contains(forbidden) {
|
||||
return Err(format!(
|
||||
"surface WGSL uses forbidden construct `{forbidden}`"
|
||||
));
|
||||
}
|
||||
}
|
||||
let validation_source = format!("{EVALUATOR_VALIDATION_PRELUDE}\n{source}");
|
||||
let module = naga::front::wgsl::parse_str(&validation_source)
|
||||
.map_err(|error| format!("surface WGSL syntax error: {error}"))?;
|
||||
naga::valid::Validator::new(
|
||||
naga::valid::ValidationFlags::all(),
|
||||
naga::valid::Capabilities::empty(),
|
||||
)
|
||||
.validate(&module)
|
||||
.map_err(|error| format!("surface WGSL validation error: {error}"))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
const EVALUATOR_VALIDATION_PRELUDE: &str = r#"
|
||||
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;
|
||||
}
|
||||
"#;
|
||||
|
||||
pub fn compose_surface_shader(evaluator: &str) -> String {
|
||||
format!(
|
||||
"{}\n{}\n{}",
|
||||
include_str!("surface_header.wgsl"),
|
||||
evaluator,
|
||||
include_str!("surface_footer.wgsl")
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn rejects_resource_bindings_and_missing_entry() {
|
||||
assert!(validate_surface_evaluator("fn nope() {}").is_err());
|
||||
assert!(validate_surface_evaluator(
|
||||
"@group(0) @binding(0) var t: texture_2d<f32>; fn evaluate() {}"
|
||||
)
|
||||
.is_err());
|
||||
for compute_incompatible in [
|
||||
"dpdx(input.uv0.x)",
|
||||
"dpdy(input.uv0.y)",
|
||||
"fwidth(input.uv0.x)",
|
||||
"discard",
|
||||
"workgroupBarrier()",
|
||||
"subgroupAdd(1u)",
|
||||
] {
|
||||
let source = format!(
|
||||
"fn evaluate(input: SurfaceInput, params: SurfaceParams, samples: SurfaceSamples) -> Surface {{ let invalid = {compute_incompatible}; return surface_default(); }}"
|
||||
);
|
||||
assert!(
|
||||
validate_surface_evaluator(&source).is_err(),
|
||||
"accepted compute-incompatible evaluator: {compute_incompatible}"
|
||||
);
|
||||
}
|
||||
assert!(validate_surface_evaluator(
|
||||
"fn evaluate(input: SurfaceInput, params: SurfaceParams, samples: SurfaceSamples) -> Surface { return missing_symbol; }"
|
||||
)
|
||||
.is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn accepts_surface_only_module_and_composes_wrapper() {
|
||||
let source = "fn evaluate(input: SurfaceInput, params: SurfaceParams, samples: SurfaceSamples) -> Surface { return surface_default(); }";
|
||||
validate_surface_evaluator(source).unwrap();
|
||||
let composed = compose_surface_shader(source);
|
||||
assert!(composed.contains(source));
|
||||
assert!(composed.contains("@fragment"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn abi_limits_are_stable() {
|
||||
assert_eq!(SURFACE_PARAMETER_LANES, 16);
|
||||
assert_eq!(SURFACE_TEXTURE_SLOTS, 8);
|
||||
assert_eq!(std::mem::size_of::<SurfaceUniform>(), 400);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -4,6 +4,7 @@ version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
description = "In-process level editor for the Bevy FPS foundation"
|
||||
default-run = "editor"
|
||||
|
||||
[lib]
|
||||
name = "editor"
|
||||
@@ -13,6 +14,10 @@ path = "src/lib.rs"
|
||||
name = "editor"
|
||||
path = "src/bin/main.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "project_launcher"
|
||||
path = "src/bin/project_launcher.rs"
|
||||
|
||||
[features]
|
||||
dev = ["bevy/dynamic_linking", "game/dev"]
|
||||
hot-reload = ["game/hot-reload", "dep:hot-lib-reloader", "dep:notify"]
|
||||
@@ -28,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 }
|
||||
@@ -37,9 +43,11 @@ sim.workspace = true
|
||||
settings.workspace = true
|
||||
scene.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json = "1"
|
||||
transform-gizmo-bevy.workspace = true
|
||||
rfd = "0.17.2"
|
||||
ron = "0.8"
|
||||
uuid = { version = "1", features = ["v4", "serde"] }
|
||||
walkdir = "2.5"
|
||||
gltf = "1.4"
|
||||
gltf = { version = "1.4", features = ["extras"] }
|
||||
blake3 = "1"
|
||||
@@ -0,0 +1,896 @@
|
||||
//! Generated animation artifacts for imported model sources.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use std::time::UNIX_EPOCH;
|
||||
|
||||
use serde::Deserialize;
|
||||
use shared::{
|
||||
animation_clip_sub_asset_id, animation_skeleton_sub_asset_id, AnimationClipRecord,
|
||||
AnimationDiagnosticSeverity, AnimationEventDesc, AnimationImportDiagnostic, AnimationManifest,
|
||||
AnimationManifestSource, AnimationSkeletonRecord, AnimationSkeletonSignature,
|
||||
AnimationSourceFingerprint, ANIMATION_ARTIFACT_DIR, ANIMATION_MANIFEST_SCHEMA_VERSION,
|
||||
};
|
||||
|
||||
use crate::asset_db::AssetRecord;
|
||||
|
||||
pub fn animation_manifest_path(asset_id: &str) -> String {
|
||||
format!("{ANIMATION_ARTIFACT_DIR}/{asset_id}.animation.ron")
|
||||
}
|
||||
|
||||
pub fn refresh_animation_artifact(record: &mut AssetRecord) -> Result<AnimationManifest, String> {
|
||||
let mut manifest = build_animation_manifest(record)?;
|
||||
manifest.source.dependencies.sort();
|
||||
manifest.source.dependencies.dedup();
|
||||
|
||||
let path = animation_manifest_path(&record.id.as_string());
|
||||
record.import_settings.animation_manifest_path = Some(path.clone());
|
||||
record
|
||||
.dependencies
|
||||
.extend(manifest.source.dependencies.iter().cloned());
|
||||
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}"))?;
|
||||
bevy::log::info!(
|
||||
"Animation manifest refreshed: source={} artifact={} skeletons={} clips={} runtime_supported={}",
|
||||
record.path,
|
||||
path,
|
||||
manifest.skeletons.len(),
|
||||
manifest.clips.len(),
|
||||
manifest.runtime_supported
|
||||
);
|
||||
}
|
||||
|
||||
Ok(manifest)
|
||||
}
|
||||
|
||||
pub fn load_animation_manifest(path: &str) -> Result<AnimationManifest, String> {
|
||||
let text =
|
||||
fs::read_to_string(path).map_err(|error| format!("could not read {path}: {error}"))?;
|
||||
ron::from_str(&text).map_err(|error| format!("could not parse {path}: {error}"))
|
||||
}
|
||||
|
||||
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 format = source_format(&record.path)?;
|
||||
match format.as_str() {
|
||||
"gltf" | "glb" => build_gltf_manifest(record, format, fingerprint, &bytes),
|
||||
"fbx" => build_fbx_manifest(record, format, fingerprint, &bytes),
|
||||
_ => Err(format!("unsupported animation source format `{format}`")),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
struct SkeletonCandidate {
|
||||
compatible_nodes: BTreeSet<usize>,
|
||||
signature: AnimationSkeletonSignature,
|
||||
}
|
||||
|
||||
fn build_gltf_manifest(
|
||||
record: &AssetRecord,
|
||||
format: String,
|
||||
fingerprint: AnimationSourceFingerprint,
|
||||
bytes: &[u8],
|
||||
) -> Result<AnimationManifest, String> {
|
||||
let gltf = gltf::Gltf::from_slice(bytes)
|
||||
.map_err(|error| format!("could not parse glTF {}: {error}", record.path))?;
|
||||
let base = Path::new(&record.path).parent();
|
||||
let buffers = gltf::import_buffers(&gltf.document, base, gltf.blob.clone())
|
||||
.map_err(|error| format!("could not load glTF buffers for {}: {error}", record.path))?;
|
||||
|
||||
let mut dependencies = gltf
|
||||
.document
|
||||
.buffers()
|
||||
.filter_map(|buffer| match buffer.source() {
|
||||
gltf::buffer::Source::Uri(uri) if !uri.starts_with("data:") => {
|
||||
Some(resolve_dependency(&record.path, uri))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
dependencies.sort();
|
||||
dependencies.dedup();
|
||||
|
||||
let node_identity_names = gltf
|
||||
.document
|
||||
.nodes()
|
||||
.map(|node| bevy_node_segment(node.name(), node.index()))
|
||||
.collect::<Vec<_>>();
|
||||
let readable_node_names = gltf
|
||||
.document
|
||||
.nodes()
|
||||
.map(|node| normalized_node_segment(node.name(), node.index()))
|
||||
.collect::<Vec<_>>();
|
||||
let mut parents = vec![None; node_identity_names.len()];
|
||||
for node in gltf.document.nodes() {
|
||||
for child in node.children() {
|
||||
parents[child.index()] = Some(node.index());
|
||||
}
|
||||
}
|
||||
|
||||
let mut skeletons = Vec::new();
|
||||
let mut candidates = Vec::new();
|
||||
for skin in gltf.document.skins() {
|
||||
let source_index = skin.index();
|
||||
let label = skin
|
||||
.name()
|
||||
.filter(|name| !name.trim().is_empty())
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| format!("Skeleton {source_index}"));
|
||||
let joint_indices = skin.joints().map(|joint| joint.index()).collect::<Vec<_>>();
|
||||
let joint_identity_paths = joint_indices
|
||||
.iter()
|
||||
.map(|index| node_path_segments(*index, &node_identity_names, &parents))
|
||||
.collect::<Vec<_>>();
|
||||
let joint_paths = joint_indices
|
||||
.iter()
|
||||
.map(|index| node_path(*index, &readable_node_names, &parents))
|
||||
.collect::<Vec<_>>();
|
||||
let bind_poses = skin
|
||||
.reader(|buffer| Some(buffers[buffer.index()].0.as_slice()))
|
||||
.read_inverse_bind_matrices()
|
||||
.map(|matrices| matrices.map(gltf_matrix_bytes).collect::<Vec<_>>())
|
||||
.unwrap_or_else(|| vec![identity_matrix_bytes(); joint_paths.len()]);
|
||||
let signature = skeleton_signature(&joint_identity_paths, &bind_poses);
|
||||
let mut compatible_nodes = joint_indices.into_iter().collect::<BTreeSet<_>>();
|
||||
if let Some(root) = skin.skeleton() {
|
||||
compatible_nodes.insert(root.index());
|
||||
}
|
||||
candidates.push(SkeletonCandidate {
|
||||
compatible_nodes,
|
||||
signature: signature.clone(),
|
||||
});
|
||||
skeletons.push(AnimationSkeletonRecord {
|
||||
id: animation_skeleton_sub_asset_id(source_index, &label),
|
||||
label,
|
||||
source_index,
|
||||
signature,
|
||||
joint_paths,
|
||||
});
|
||||
}
|
||||
|
||||
let mut diagnostics = Vec::new();
|
||||
let mut clips = Vec::new();
|
||||
let mut animation_roots = BTreeSet::new();
|
||||
for animation in gltf.document.animations() {
|
||||
let source_index = animation.index();
|
||||
let label = animation
|
||||
.name()
|
||||
.filter(|name| !name.trim().is_empty())
|
||||
.map(str::to_string)
|
||||
.unwrap_or_else(|| format!("Animation {source_index}"));
|
||||
let mut duration_seconds = 0.0_f32;
|
||||
let mut target_nodes = BTreeSet::new();
|
||||
for channel in animation.channels() {
|
||||
let target_index = channel.target().node().index();
|
||||
target_nodes.insert(target_index);
|
||||
animation_roots.insert(top_level_node(target_index, &parents));
|
||||
if let Some(inputs) = channel
|
||||
.reader(|buffer| Some(buffers[buffer.index()].0.as_slice()))
|
||||
.read_inputs()
|
||||
{
|
||||
for input in inputs {
|
||||
if input.is_finite() {
|
||||
duration_seconds = duration_seconds.max(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
let target_skeleton_signature = matching_skeleton_signature(&target_nodes, &candidates);
|
||||
if !candidates.is_empty() && target_skeleton_signature.is_none() {
|
||||
diagnostics.push(AnimationImportDiagnostic {
|
||||
severity: AnimationDiagnosticSeverity::Warning,
|
||||
code: "animation.clip_skeleton_unresolved".into(),
|
||||
message: format!(
|
||||
"clip `{label}` does not target a uniquely identifiable imported skeleton"
|
||||
),
|
||||
repair: "Export the clip with channels targeting one skeleton, or split unrelated rigs into separate glTF assets.".into(),
|
||||
});
|
||||
}
|
||||
let events = gltf_animation_events(&animation, duration_seconds, &label, &mut diagnostics);
|
||||
clips.push(AnimationClipRecord {
|
||||
id: animation_clip_sub_asset_id(source_index, &label),
|
||||
label,
|
||||
source_index,
|
||||
duration_seconds,
|
||||
target_skeleton_signature,
|
||||
events,
|
||||
});
|
||||
}
|
||||
|
||||
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
|
||||
.iter()
|
||||
.map(|index| format!("`{}` (node {index})", node_identity_names[*index]))
|
||||
.collect::<Vec<_>>()
|
||||
.join(", ");
|
||||
diagnostics.push(AnimationImportDiagnostic {
|
||||
severity: AnimationDiagnosticSeverity::Error,
|
||||
code: "animation.multiple_roots_unsupported".into(),
|
||||
message: format!(
|
||||
"animation channels target {} distinct top-level roots ({roots}); Bevy requires a separate AnimationPlayer for each root",
|
||||
animation_roots.len()
|
||||
),
|
||||
repair: "Split the source into one animated rig per glTF asset, or export every clip under one common top-level root, then reimport.".into(),
|
||||
});
|
||||
}
|
||||
|
||||
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,
|
||||
fingerprint,
|
||||
dependencies,
|
||||
},
|
||||
runtime_supported,
|
||||
skeletons,
|
||||
clips,
|
||||
diagnostics,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_fbx_manifest(
|
||||
record: &AssetRecord,
|
||||
format: String,
|
||||
fingerprint: AnimationSourceFingerprint,
|
||||
bytes: &[u8],
|
||||
) -> Result<AnimationManifest, String> {
|
||||
let scene = ufbx::load_memory(
|
||||
bytes,
|
||||
ufbx::LoadOpts {
|
||||
target_unit_meters: 1.0,
|
||||
target_axes: ufbx::CoordinateAxes::right_handed_y_up(),
|
||||
..Default::default()
|
||||
},
|
||||
)
|
||||
.map_err(|error| format!("could not parse FBX {}: {error:?}", record.path))?;
|
||||
|
||||
let mut skeletons = Vec::new();
|
||||
for (source_index, skin) in scene.skin_deformers.as_ref().iter().enumerate() {
|
||||
let label = if skin.element.name.is_empty() {
|
||||
format!("Skeleton {source_index}")
|
||||
} else {
|
||||
skin.element.name.to_string()
|
||||
};
|
||||
let mut joint_identity_paths = Vec::new();
|
||||
let mut joint_paths = Vec::new();
|
||||
let mut bind_poses = Vec::new();
|
||||
for cluster in skin.clusters.as_ref() {
|
||||
let Some(bone) = cluster.bone_node.as_ref() else {
|
||||
continue;
|
||||
};
|
||||
let segments = fbx_node_path_segments(bone.as_ref());
|
||||
joint_paths.push(segments.join("/"));
|
||||
joint_identity_paths.push(segments);
|
||||
bind_poses.push(fbx_matrix_bytes(&cluster.bind_to_world));
|
||||
}
|
||||
let signature = skeleton_signature(&joint_identity_paths, &bind_poses);
|
||||
skeletons.push(AnimationSkeletonRecord {
|
||||
id: animation_skeleton_sub_asset_id(source_index, &label),
|
||||
label,
|
||||
source_index,
|
||||
signature,
|
||||
joint_paths,
|
||||
});
|
||||
}
|
||||
|
||||
let fallback_signature = (skeletons.len() == 1).then(|| skeletons[0].signature.clone());
|
||||
let clips = scene
|
||||
.anim_stacks
|
||||
.as_ref()
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(source_index, stack)| {
|
||||
let label = if stack.element.name.is_empty() {
|
||||
format!("Animation {source_index}")
|
||||
} else {
|
||||
stack.element.name.to_string()
|
||||
};
|
||||
AnimationClipRecord {
|
||||
id: animation_clip_sub_asset_id(source_index, &label),
|
||||
label,
|
||||
source_index,
|
||||
duration_seconds: (stack.time_end - stack.time_begin).max(0.0) as f32,
|
||||
target_skeleton_signature: fallback_signature.clone(),
|
||||
events: Vec::new(),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
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,
|
||||
fingerprint,
|
||||
dependencies: Vec::new(),
|
||||
},
|
||||
runtime_supported,
|
||||
skeletons,
|
||||
clips,
|
||||
diagnostics,
|
||||
})
|
||||
}
|
||||
|
||||
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,
|
||||
) -> (bool, Vec<AnimationImportDiagnostic>) {
|
||||
let mut diagnostics = Vec::new();
|
||||
if animation_count > 0 || skin_count > 0 {
|
||||
diagnostics.push(AnimationImportDiagnostic {
|
||||
severity: AnimationDiagnosticSeverity::Error,
|
||||
code: "animation.fbx_runtime_unsupported".into(),
|
||||
message: format!(
|
||||
"FBX contains {animation_count} animation stack(s) and {skin_count} skin deformer(s), but Blacksite's current FBX loader cannot build a runtime skeleton or clips"
|
||||
),
|
||||
repair: "Export the animated source as glTF 2.0 (.glb or .gltf). Keep FBX only for static mesh import until hierarchy, SkinnedMesh, and AnimationClip conversion are implemented.".into(),
|
||||
});
|
||||
}
|
||||
(false, diagnostics)
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize)]
|
||||
struct GltfAnimationExtras {
|
||||
#[serde(default)]
|
||||
blacksite_events: Vec<GltfAnimationEvent>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
struct GltfAnimationEvent {
|
||||
id: String,
|
||||
time_seconds: f32,
|
||||
#[serde(default)]
|
||||
payload: Option<String>,
|
||||
}
|
||||
|
||||
fn gltf_animation_events(
|
||||
animation: &gltf::Animation<'_>,
|
||||
duration_seconds: f32,
|
||||
clip_label: &str,
|
||||
diagnostics: &mut Vec<AnimationImportDiagnostic>,
|
||||
) -> Vec<AnimationEventDesc> {
|
||||
let Some(raw) = animation.extras().as_ref() else {
|
||||
return Vec::new();
|
||||
};
|
||||
let extras = match serde_json::from_str::<GltfAnimationExtras>(raw.get()) {
|
||||
Ok(extras) => extras,
|
||||
Err(error) => {
|
||||
diagnostics.push(AnimationImportDiagnostic {
|
||||
severity: AnimationDiagnosticSeverity::Warning,
|
||||
code: "animation.events_invalid".into(),
|
||||
message: format!("clip `{clip_label}` has invalid animation event metadata: {error}"),
|
||||
repair: "Use an animation extras object with `blacksite_events` entries containing `id`, `time_seconds`, and optional string `payload`.".into(),
|
||||
});
|
||||
return Vec::new();
|
||||
}
|
||||
};
|
||||
|
||||
let mut events = Vec::new();
|
||||
for event in extras.blacksite_events {
|
||||
let valid_time = event.time_seconds.is_finite()
|
||||
&& event.time_seconds >= 0.0
|
||||
&& event.time_seconds <= duration_seconds;
|
||||
if event.id.trim().is_empty() || !valid_time {
|
||||
diagnostics.push(AnimationImportDiagnostic {
|
||||
severity: AnimationDiagnosticSeverity::Warning,
|
||||
code: "animation.event_out_of_range".into(),
|
||||
message: format!(
|
||||
"clip `{clip_label}` contains an event with an empty ID or time outside 0..={duration_seconds:.3}s"
|
||||
),
|
||||
repair: "Give every event a stable non-empty ID and place it within the imported clip duration.".into(),
|
||||
});
|
||||
continue;
|
||||
}
|
||||
events.push(AnimationEventDesc {
|
||||
id: event.id,
|
||||
time_seconds: event.time_seconds,
|
||||
payload: event.payload,
|
||||
});
|
||||
}
|
||||
events.sort_by(|left, right| {
|
||||
left.time_seconds
|
||||
.total_cmp(&right.time_seconds)
|
||||
.then(left.id.cmp(&right.id))
|
||||
.then(left.payload.cmp(&right.payload))
|
||||
});
|
||||
events
|
||||
}
|
||||
|
||||
fn matching_skeleton_signature(
|
||||
target_nodes: &BTreeSet<usize>,
|
||||
candidates: &[SkeletonCandidate],
|
||||
) -> Option<AnimationSkeletonSignature> {
|
||||
let scored = candidates
|
||||
.iter()
|
||||
.map(|candidate| {
|
||||
(
|
||||
candidate
|
||||
.compatible_nodes
|
||||
.intersection(target_nodes)
|
||||
.count(),
|
||||
candidate,
|
||||
)
|
||||
})
|
||||
.filter(|(score, _)| *score > 0)
|
||||
.collect::<Vec<_>>();
|
||||
let best_score = scored.iter().map(|(score, _)| *score).max()?;
|
||||
let mut best = scored
|
||||
.into_iter()
|
||||
.filter(|(score, _)| *score == best_score)
|
||||
.map(|(_, candidate)| candidate);
|
||||
let candidate = best.next()?;
|
||||
best.all(|other| other.signature == candidate.signature)
|
||||
.then(|| candidate.signature.clone())
|
||||
}
|
||||
|
||||
fn node_path(index: usize, names: &[String], parents: &[Option<usize>]) -> String {
|
||||
node_path_segments(index, names, parents).join("/")
|
||||
}
|
||||
|
||||
fn node_path_segments(index: usize, names: &[String], parents: &[Option<usize>]) -> Vec<String> {
|
||||
let mut segments = Vec::new();
|
||||
let mut current = Some(index);
|
||||
while let Some(node_index) = current {
|
||||
segments.push(names[node_index].clone());
|
||||
current = parents[node_index];
|
||||
}
|
||||
segments.reverse();
|
||||
segments
|
||||
}
|
||||
|
||||
fn top_level_node(index: usize, parents: &[Option<usize>]) -> usize {
|
||||
let mut current = index;
|
||||
while let Some(parent) = parents[current] {
|
||||
current = parent;
|
||||
}
|
||||
current
|
||||
}
|
||||
|
||||
fn bevy_node_segment(name: Option<&str>, index: usize) -> String {
|
||||
name.map(str::to_string)
|
||||
.unwrap_or_else(|| format!("GltfNode{index}"))
|
||||
}
|
||||
|
||||
fn normalized_node_segment(name: Option<&str>, index: usize) -> String {
|
||||
name.map(str::trim)
|
||||
.filter(|name| !name.is_empty())
|
||||
.map(|name| name.replace(['/', '\\'], "_"))
|
||||
.unwrap_or_else(|| format!("Node{index}"))
|
||||
}
|
||||
|
||||
fn fbx_node_path_segments(node: &ufbx::Node) -> Vec<String> {
|
||||
let mut segments = Vec::new();
|
||||
let mut current = Some(node);
|
||||
while let Some(node) = current {
|
||||
segments.push(normalized_node_segment(
|
||||
(!node.element.name.is_empty()).then(|| node.element.name.as_ref()),
|
||||
node.element.element_id as usize,
|
||||
));
|
||||
current = node.parent.as_ref().map(|parent| parent.as_ref());
|
||||
}
|
||||
segments.reverse();
|
||||
segments
|
||||
}
|
||||
|
||||
fn skeleton_signature(
|
||||
joint_path_segments: &[Vec<String>],
|
||||
bind_pose_bytes: &[Vec<u8>],
|
||||
) -> AnimationSkeletonSignature {
|
||||
let mut hasher = blake3::Hasher::new();
|
||||
hasher.update(b"blacksite-animation-skeleton-v2\0");
|
||||
hasher.update(&(joint_path_segments.len() as u64).to_le_bytes());
|
||||
for path in joint_path_segments {
|
||||
hasher.update(&(path.len() as u64).to_le_bytes());
|
||||
for segment in path {
|
||||
let bytes = segment.as_bytes();
|
||||
hasher.update(&(bytes.len() as u64).to_le_bytes());
|
||||
hasher.update(bytes);
|
||||
}
|
||||
}
|
||||
hasher.update(&(bind_pose_bytes.len() as u64).to_le_bytes());
|
||||
for bytes in bind_pose_bytes {
|
||||
hasher.update(&(bytes.len() as u64).to_le_bytes());
|
||||
hasher.update(bytes);
|
||||
}
|
||||
AnimationSkeletonSignature::new(hasher.finalize().to_hex().to_string())
|
||||
}
|
||||
|
||||
fn gltf_matrix_bytes(matrix: [[f32; 4]; 4]) -> Vec<u8> {
|
||||
matrix
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.flat_map(f32::to_le_bytes)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn identity_matrix_bytes() -> Vec<u8> {
|
||||
gltf_matrix_bytes([
|
||||
[1.0, 0.0, 0.0, 0.0],
|
||||
[0.0, 1.0, 0.0, 0.0],
|
||||
[0.0, 0.0, 1.0, 0.0],
|
||||
[0.0, 0.0, 0.0, 1.0],
|
||||
])
|
||||
}
|
||||
|
||||
fn fbx_matrix_bytes(matrix: &ufbx::Matrix) -> Vec<u8> {
|
||||
[
|
||||
matrix.m00, matrix.m10, matrix.m20, matrix.m01, matrix.m11, matrix.m21, matrix.m02,
|
||||
matrix.m12, matrix.m22, matrix.m03, matrix.m13, matrix.m23,
|
||||
]
|
||||
.into_iter()
|
||||
.flat_map(f64::to_le_bytes)
|
||||
.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_format(path: &str) -> Result<String, String> {
|
||||
Path::new(path)
|
||||
.extension()
|
||||
.and_then(|extension| extension.to_str())
|
||||
.map(|extension| extension.to_ascii_lowercase())
|
||||
.ok_or_else(|| format!("asset path `{path}` has no extension"))
|
||||
}
|
||||
|
||||
fn resolve_dependency(source_path: &str, uri: &str) -> String {
|
||||
Path::new(source_path)
|
||||
.parent()
|
||||
.unwrap_or_else(|| Path::new(""))
|
||||
.join(uri)
|
||||
.to_string_lossy()
|
||||
.replace('\\', "/")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::asset_db::{AssetId, ImportSettings};
|
||||
use uuid::Uuid;
|
||||
|
||||
fn fixture_record(path: &Path) -> AssetRecord {
|
||||
AssetRecord {
|
||||
id: AssetId(Uuid::nil()),
|
||||
path: path.to_string_lossy().replace('\\', "/"),
|
||||
label: "Animated Hero".into(),
|
||||
kind_tag: "Model".into(),
|
||||
import_settings: ImportSettings::default(),
|
||||
dependencies: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn write_animated_gltf(root: &Path) -> std::path::PathBuf {
|
||||
fs::create_dir_all(root).unwrap();
|
||||
let mut buffer = Vec::new();
|
||||
for value in [0.0_f32, 1.25] {
|
||||
buffer.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
for value in [0.0_f32, 0.0, 0.0, 1.0, 0.0, 0.38268343, 0.0, 0.9238795] {
|
||||
buffer.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
fs::write(root.join("animated.bin"), buffer).unwrap();
|
||||
let gltf = r#"{
|
||||
"asset":{"version":"2.0"},
|
||||
"scene":0,
|
||||
"scenes":[{"nodes":[0]}],
|
||||
"nodes":[{"name":"Armature","children":[1]},{"name":"Hip"}],
|
||||
"skins":[{"name":"Hero Rig","skeleton":0,"joints":[1]}],
|
||||
"buffers":[{"uri":"animated.bin","byteLength":40}],
|
||||
"bufferViews":[
|
||||
{"buffer":0,"byteOffset":0,"byteLength":8},
|
||||
{"buffer":0,"byteOffset":8,"byteLength":32}
|
||||
],
|
||||
"accessors":[
|
||||
{"bufferView":0,"componentType":5126,"count":2,"type":"SCALAR","min":[0.0],"max":[1.25]},
|
||||
{"bufferView":1,"componentType":5126,"count":2,"type":"VEC4"}
|
||||
],
|
||||
"animations":[{
|
||||
"name":"Idle Loop",
|
||||
"samplers":[{"input":0,"output":1,"interpolation":"LINEAR"}],
|
||||
"channels":[{"sampler":0,"target":{"node":1,"path":"rotation"}}],
|
||||
"extras":{"blacksite_events":[{"id":"footstep.left","time_seconds":0.5,"payload":"stone"}]}
|
||||
}]
|
||||
}"#;
|
||||
let path = root.join("animated.gltf");
|
||||
fs::write(&path, gltf).unwrap();
|
||||
path
|
||||
}
|
||||
|
||||
fn write_multi_root_animated_gltf(root: &Path) -> std::path::PathBuf {
|
||||
fs::create_dir_all(root).unwrap();
|
||||
let mut buffer = Vec::new();
|
||||
for value in [0.0_f32, 1.0] {
|
||||
buffer.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
for value in [0.0_f32, 0.0, 0.0, 1.0, 0.0, 0.38268343, 0.0, 0.9238795] {
|
||||
buffer.extend_from_slice(&value.to_le_bytes());
|
||||
}
|
||||
fs::write(root.join("multi-root.bin"), buffer).unwrap();
|
||||
let gltf = r#"{
|
||||
"asset":{"version":"2.0"},
|
||||
"scene":0,
|
||||
"scenes":[{"nodes":[0,2]}],
|
||||
"nodes":[
|
||||
{"name":"Character A","children":[1]},
|
||||
{"name":"Joint A"},
|
||||
{"name":"Character B","children":[3]},
|
||||
{"name":"Joint B"}
|
||||
],
|
||||
"buffers":[{"uri":"multi-root.bin","byteLength":40}],
|
||||
"bufferViews":[
|
||||
{"buffer":0,"byteOffset":0,"byteLength":8},
|
||||
{"buffer":0,"byteOffset":8,"byteLength":32}
|
||||
],
|
||||
"accessors":[
|
||||
{"bufferView":0,"componentType":5126,"count":2,"type":"SCALAR","min":[0.0],"max":[1.0]},
|
||||
{"bufferView":1,"componentType":5126,"count":2,"type":"VEC4"}
|
||||
],
|
||||
"animations":[{
|
||||
"name":"Two Players Required",
|
||||
"samplers":[
|
||||
{"input":0,"output":1,"interpolation":"LINEAR"},
|
||||
{"input":0,"output":1,"interpolation":"LINEAR"}
|
||||
],
|
||||
"channels":[
|
||||
{"sampler":0,"target":{"node":1,"path":"rotation"}},
|
||||
{"sampler":1,"target":{"node":3,"path":"rotation"}}
|
||||
]
|
||||
}]
|
||||
}"#;
|
||||
let path = root.join("multi-root.gltf");
|
||||
fs::write(&path, gltf).unwrap();
|
||||
path
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn animation_manifest_path_uses_registry_uuid() {
|
||||
assert_eq!(
|
||||
animation_manifest_path("abc"),
|
||||
"assets/animations/generated/abc.animation.ron"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gltf_extraction_is_deterministic_and_preserves_duration_events_and_signature() {
|
||||
let root = std::env::temp_dir().join(format!("blacksite-animation-{}", Uuid::new_v4()));
|
||||
let path = write_animated_gltf(&root);
|
||||
let record = fixture_record(&path);
|
||||
|
||||
let first = build_animation_manifest(&record).unwrap();
|
||||
let second = build_animation_manifest(&record).unwrap();
|
||||
|
||||
assert_eq!(first, second);
|
||||
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);
|
||||
assert_eq!(first.clips.len(), 1);
|
||||
assert_eq!(first.skeletons[0].id, "animation:skeleton:0:hero_rig");
|
||||
assert!(!first.skeletons[0].signature.is_empty());
|
||||
assert_eq!(first.clips[0].id, "animation:clip:0:idle_loop");
|
||||
assert_eq!(first.clips[0].duration_seconds, 1.25);
|
||||
assert_eq!(
|
||||
first.clips[0].target_skeleton_signature,
|
||||
Some(first.skeletons[0].signature.clone())
|
||||
);
|
||||
assert_eq!(first.clips[0].events.len(), 1);
|
||||
assert_eq!(first.clips[0].events[0].id, "footstep.left");
|
||||
assert_eq!(first.clips[0].events[0].time_seconds, 0.5);
|
||||
assert_eq!(first.diagnostics, Vec::new());
|
||||
|
||||
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();
|
||||
let first = skeleton_signature(
|
||||
&[vec!["Armature".into(), "Hip".into()]],
|
||||
std::slice::from_ref(&identity),
|
||||
);
|
||||
let renamed = skeleton_signature(
|
||||
&[vec!["Armature".into(), "Pelvis".into()]],
|
||||
std::slice::from_ref(&identity),
|
||||
);
|
||||
let mut changed_pose = identity;
|
||||
changed_pose[0] ^= 1;
|
||||
let rebound = skeleton_signature(&[vec!["Armature".into(), "Hip".into()]], &[changed_pose]);
|
||||
assert_ne!(first, renamed);
|
||||
assert_ne!(first, rebound);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exact_signature_preserves_bevy_node_bytes_and_segment_boundaries() {
|
||||
let identity = identity_matrix_bytes();
|
||||
let slash_in_name = vec![vec!["Armature".into(), "Hip/Joint".into()]];
|
||||
let slash_as_boundary = vec![vec!["Armature/Hip".into(), "Joint".into()]];
|
||||
|
||||
assert_eq!(slash_in_name[0].join("/"), slash_as_boundary[0].join("/"));
|
||||
assert_ne!(
|
||||
skeleton_signature(&slash_in_name, std::slice::from_ref(&identity)),
|
||||
skeleton_signature(&slash_as_boundary, std::slice::from_ref(&identity))
|
||||
);
|
||||
|
||||
let backslash = vec![vec!["Armature".into(), "Hip\\Joint".into()]];
|
||||
assert_eq!(
|
||||
normalized_node_segment(Some("Hip/Joint"), 1),
|
||||
normalized_node_segment(Some("Hip\\Joint"), 1)
|
||||
);
|
||||
assert_ne!(
|
||||
skeleton_signature(&slash_in_name, std::slice::from_ref(&identity)),
|
||||
skeleton_signature(&backslash, std::slice::from_ref(&identity))
|
||||
);
|
||||
assert_eq!(bevy_node_segment(Some(" /Joint "), 7), " /Joint ");
|
||||
assert_eq!(bevy_node_segment(None, 7), "GltfNode7");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gltf_with_multiple_animation_roots_is_runtime_unsupported() {
|
||||
let root =
|
||||
std::env::temp_dir().join(format!("blacksite-animation-multi-root-{}", Uuid::new_v4()));
|
||||
let path = write_multi_root_animated_gltf(&root);
|
||||
let manifest = build_animation_manifest(&fixture_record(&path)).unwrap();
|
||||
|
||||
assert!(!manifest.runtime_supported);
|
||||
let diagnostic = manifest
|
||||
.diagnostics
|
||||
.iter()
|
||||
.find(|diagnostic| diagnostic.code == "animation.multiple_roots_unsupported")
|
||||
.expect("multi-root glTF should include an actionable blocking diagnostic");
|
||||
assert_eq!(diagnostic.severity, AnimationDiagnosticSeverity::Error);
|
||||
assert!(diagnostic.message.contains("2 distinct top-level roots"));
|
||||
assert!(diagnostic.repair.contains("one common top-level root"));
|
||||
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn animated_or_skinned_fbx_is_runtime_unsupported_with_repair_guidance() {
|
||||
let (supported, diagnostics) = fbx_runtime_support(2, 1);
|
||||
assert!(!supported);
|
||||
assert_eq!(diagnostics.len(), 1);
|
||||
assert_eq!(diagnostics[0].severity, AnimationDiagnosticSeverity::Error);
|
||||
assert_eq!(diagnostics[0].code, "animation.fbx_runtime_unsupported");
|
||||
assert!(diagnostics[0].repair.contains("glTF 2.0"));
|
||||
|
||||
let (supported, diagnostics) = fbx_runtime_support(0, 0);
|
||||
assert!(!supported);
|
||||
assert!(diagnostics.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn committed_robot_fixture_exposes_a_skin_and_multiple_named_states() {
|
||||
let path =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/models/robot_expressive.glb");
|
||||
let manifest = build_animation_manifest(&fixture_record(&path)).unwrap();
|
||||
|
||||
assert!(manifest.runtime_supported);
|
||||
assert_eq!(manifest.skeletons.len(), 2);
|
||||
assert_eq!(manifest.skeletons[0].id, "animation:skeleton:0:skeleton_0");
|
||||
assert_eq!(manifest.skeletons[1].id, "animation:skeleton:1:skeleton_1");
|
||||
assert!(manifest
|
||||
.skeletons
|
||||
.iter()
|
||||
.all(|skeleton| skeleton.joint_paths.len() == 43));
|
||||
let signature = &manifest.skeletons[0].signature;
|
||||
assert!(manifest
|
||||
.skeletons
|
||||
.iter()
|
||||
.all(|skeleton| &skeleton.signature == signature));
|
||||
assert_eq!(manifest.clips.len(), 14);
|
||||
for expected in ["Idle", "Walking", "Running", "Jump", "Wave"] {
|
||||
assert!(
|
||||
manifest.clips.iter().any(|clip| clip.label == expected),
|
||||
"missing expected fixture clip {expected}"
|
||||
);
|
||||
}
|
||||
assert!(manifest
|
||||
.clips
|
||||
.iter()
|
||||
.all(|clip| clip.duration_seconds.is_finite() && clip.duration_seconds > 0.0));
|
||||
assert!(manifest
|
||||
.clips
|
||||
.iter()
|
||||
.all(|clip| { clip.target_skeleton_signature.as_ref() == Some(signature) }));
|
||||
assert!(manifest.diagnostics.is_empty());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use uuid::Uuid;
|
||||
|
||||
/// Stable asset identity for dependency tracking and prefab references.
|
||||
@@ -27,8 +27,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,
|
||||
}
|
||||
|
||||
@@ -59,6 +63,12 @@ pub struct ImportSettings {
|
||||
pub material_policy: MaterialImportPolicy,
|
||||
#[serde(default)]
|
||||
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 {
|
||||
@@ -71,6 +81,8 @@ impl Default for ImportSettings {
|
||||
hierarchy_mode: ModelHierarchyMode::default(),
|
||||
material_policy: MaterialImportPolicy::default(),
|
||||
static_mesh_manifest_path: None,
|
||||
animation_manifest_path: None,
|
||||
default_animation_clip_id: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -115,6 +127,11 @@ fn sync_registry_from_browser(
|
||||
.drain(..)
|
||||
.map(|record| (record.path.clone(), record))
|
||||
.collect();
|
||||
let current_paths = assets
|
||||
.assets
|
||||
.iter()
|
||||
.filter_map(|asset| asset.path.clone())
|
||||
.collect::<HashSet<_>>();
|
||||
|
||||
let mut next_records = Vec::new();
|
||||
let mut seen_paths = HashMap::new();
|
||||
@@ -129,7 +146,18 @@ fn sync_registry_from_browser(
|
||||
seen_paths.insert(path.clone(), ());
|
||||
|
||||
let kind_tag = format!("{:?}", asset.kind);
|
||||
let mut record = if let Some(mut prior) = existing.remove(&path) {
|
||||
let mut record = if let Some(mut prior) = existing.remove(&path).or_else(|| {
|
||||
take_uniquely_moved_model_record(&mut existing, ¤t_paths, &path, &kind_tag)
|
||||
}) {
|
||||
if prior.path != path {
|
||||
info!(
|
||||
"Asset registry preserved model identity {} across move {} -> {}",
|
||||
prior.id.as_string(),
|
||||
prior.path,
|
||||
path
|
||||
);
|
||||
prior.path = path.clone();
|
||||
}
|
||||
prior.label = asset.label.clone();
|
||||
prior.kind_tag = kind_tag;
|
||||
prior
|
||||
@@ -144,9 +172,9 @@ fn sync_registry_from_browser(
|
||||
}
|
||||
};
|
||||
if record.kind_tag == "Model" {
|
||||
if let Err(error) = super::static_mesh::refresh_static_mesh_artifact(&mut record) {
|
||||
if let Err(error) = super::refresh_model_artifacts(&mut record) {
|
||||
warn!(
|
||||
"Static mesh processor failed for {} (asset id {}): {error}",
|
||||
"Model artifact refresh failed for {} (asset id {}): {error}",
|
||||
record.path,
|
||||
record.id.as_string()
|
||||
);
|
||||
@@ -170,6 +198,34 @@ fn sync_registry_from_browser(
|
||||
}
|
||||
}
|
||||
|
||||
fn take_uniquely_moved_model_record(
|
||||
existing: &mut HashMap<String, AssetRecord>,
|
||||
current_paths: &HashSet<String>,
|
||||
new_path: &str,
|
||||
kind_tag: &str,
|
||||
) -> Option<AssetRecord> {
|
||||
if kind_tag != "Model" {
|
||||
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" {
|
||||
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())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if candidates.len() != 1 {
|
||||
return None;
|
||||
}
|
||||
existing.remove(&candidates[0])
|
||||
}
|
||||
|
||||
pub fn find_asset_by_path(registry: &AssetRegistry, path: &str) -> Option<AssetRecord> {
|
||||
registry
|
||||
.records
|
||||
@@ -196,6 +252,34 @@ pub fn find_asset_mut_by_path<'a>(
|
||||
.find(|record| record.path == path)
|
||||
}
|
||||
|
||||
pub fn ensure_asset_record(
|
||||
registry: &mut AssetRegistry,
|
||||
path: impl Into<String>,
|
||||
label: impl Into<String>,
|
||||
kind_tag: impl Into<String>,
|
||||
) -> Result<AssetRecord, String> {
|
||||
let path = path.into();
|
||||
if let Some(record) = find_asset_by_path(registry, &path) {
|
||||
return Ok(record);
|
||||
}
|
||||
let record = AssetRecord {
|
||||
id: AssetId::new(),
|
||||
path,
|
||||
label: label.into(),
|
||||
kind_tag: kind_tag.into(),
|
||||
import_settings: ImportSettings::default(),
|
||||
dependencies: Vec::new(),
|
||||
};
|
||||
registry.records.push(record.clone());
|
||||
registry.index_dirty = true;
|
||||
if let Err(error) = save_registry(registry) {
|
||||
registry.records.pop();
|
||||
return Err(error);
|
||||
}
|
||||
registry.index_dirty = false;
|
||||
Ok(record)
|
||||
}
|
||||
|
||||
pub fn update_import_settings(
|
||||
registry: &mut AssetRegistry,
|
||||
path: &str,
|
||||
@@ -240,3 +324,99 @@ pub fn load_registry() -> AssetRegistry {
|
||||
Err(_) => AssetRegistry::default(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use shared::{
|
||||
AnimationManifest, AnimationManifestSource, AnimationSourceFingerprint,
|
||||
ANIMATION_MANIFEST_SCHEMA_VERSION,
|
||||
};
|
||||
|
||||
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"));
|
||||
let manifest_path =
|
||||
std::env::temp_dir().join(format!("blacksite-moved-model-{key}.animation.ron"));
|
||||
std::fs::write(&source_path, bytes).unwrap();
|
||||
let id = AssetId::new();
|
||||
let old_path = format!("assets/models/old-{key}.glb");
|
||||
let manifest = AnimationManifest {
|
||||
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(),
|
||||
},
|
||||
runtime_supported: true,
|
||||
skeletons: Vec::new(),
|
||||
clips: 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,
|
||||
path: old_path,
|
||||
label: "Moved Model".into(),
|
||||
kind_tag: "Model".into(),
|
||||
import_settings: ImportSettings {
|
||||
animation_manifest_path: Some(manifest_path.to_string_lossy().into_owned()),
|
||||
..Default::default()
|
||||
},
|
||||
dependencies: Vec::new(),
|
||||
};
|
||||
(source_path, manifest_path, record)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unique_content_match_preserves_model_record_across_move() {
|
||||
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 moved = take_uniquely_moved_model_record(
|
||||
&mut existing,
|
||||
&HashSet::new(),
|
||||
&source_path.to_string_lossy(),
|
||||
"Model",
|
||||
)
|
||||
.expect("unique moved model should retain its registry record");
|
||||
|
||||
assert_eq!(moved.id, expected_id);
|
||||
assert!(existing.is_empty());
|
||||
let _ = std::fs::remove_file(source_path);
|
||||
let _ = std::fs::remove_file(manifest_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_source_path_is_not_reconciled_as_a_copy_move() {
|
||||
let (source_path, manifest_path, record) = moved_model_fixture(b"copied model bytes");
|
||||
let old_path = record.path.clone();
|
||||
let mut existing = HashMap::from([(old_path.clone(), record)]);
|
||||
let current_paths = HashSet::from([old_path]);
|
||||
|
||||
let moved = take_uniquely_moved_model_record(
|
||||
&mut existing,
|
||||
¤t_paths,
|
||||
&source_path.to_string_lossy(),
|
||||
"Model",
|
||||
);
|
||||
|
||||
assert!(moved.is_none());
|
||||
assert_eq!(existing.len(), 1);
|
||||
let _ = std::fs::remove_file(source_path);
|
||||
let _ = std::fs::remove_file(manifest_path);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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_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,38 +16,115 @@ 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(
|
||||
world: &mut World,
|
||||
asset: &EditorAsset,
|
||||
selected: &bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities,
|
||||
) {
|
||||
let Some(path) = asset.path.clone() else {
|
||||
return;
|
||||
) -> Result<(), String> {
|
||||
let path = asset
|
||||
.path
|
||||
.clone()
|
||||
.ok_or_else(|| format!("Material has no source path: {}", asset.label))?;
|
||||
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 desc = match material_desc_from_asset(&path) {
|
||||
Ok(desc) => desc,
|
||||
Err(err) => {
|
||||
world.resource_mut::<crate::scene_io::SceneIo>().status = err;
|
||||
return;
|
||||
}
|
||||
};
|
||||
for entity in crate::ui::helpers::selected_level_entities(world, selected) {
|
||||
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 world.get::<MaterialDesc>(entity).is_none() {
|
||||
world.entity_mut(entity).insert(desc.clone());
|
||||
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;
|
||||
}
|
||||
set_material_with_history(world, entity, desc.clone());
|
||||
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(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Asset catalog, database, thumbnails, materials, and prefab overrides.
|
||||
|
||||
pub mod animation;
|
||||
pub mod asset_db;
|
||||
mod catalog;
|
||||
mod import;
|
||||
@@ -11,6 +12,25 @@ pub mod thumbnails;
|
||||
|
||||
pub use catalog::*;
|
||||
pub use thumbnails::{
|
||||
draw_asset_cell_with, invalidate_on_catalog_refresh, kind_icon, prefetch_folder_thumbnails,
|
||||
AssetThumbnailCache, ThumbnailCacheSnapshot, ThumbnailState, ThumbnailStudio, ThumbnailsPlugin,
|
||||
draw_asset_cell_with, gltf_skinned_primitive_labels, invalidate_on_catalog_refresh, kind_icon,
|
||||
prefetch_asset_thumbnails, prefetch_folder_thumbnails, AssetThumbnailCache,
|
||||
ThumbnailCacheSnapshot, ThumbnailState, ThumbnailStudio, ThumbnailsPlugin,
|
||||
};
|
||||
|
||||
/// Refreshes both generated contracts derived from one imported model source.
|
||||
pub fn refresh_model_artifacts(
|
||||
record: &mut asset_db::AssetRecord,
|
||||
) -> Result<static_mesh::StaticMeshManifest, String> {
|
||||
let static_mesh = static_mesh::refresh_static_mesh_artifact(record);
|
||||
let animation = animation::refresh_animation_artifact(record);
|
||||
match (static_mesh, animation) {
|
||||
(Ok(static_mesh), Ok(_)) => Ok(static_mesh),
|
||||
(Err(static_error), Ok(_)) => Err(format!("static mesh processor failed: {static_error}")),
|
||||
(Ok(_), Err(animation_error)) => {
|
||||
Err(format!("animation processor failed: {animation_error}"))
|
||||
}
|
||||
(Err(static_error), Err(animation_error)) => Err(format!(
|
||||
"static mesh processor failed: {static_error}; animation processor failed: {animation_error}"
|
||||
)),
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,11 @@ use crate::ui::helpers::{
|
||||
apply_material_asset_to_selection, apply_texture_to_selection, selected_level_entities,
|
||||
};
|
||||
|
||||
use super::{spawn_asset_at, spawn_subasset_at, AssetSelection, EditorAsset};
|
||||
use super::{
|
||||
animation_clip_authoring_data, animation_skeleton_signature_for_ref, audio_clip_ref_for_asset,
|
||||
compatible_animation_skeleton_for_model, spawn_asset_at, spawn_subasset_at,
|
||||
validate_prefab_asset, AssetSelection, EditorAsset,
|
||||
};
|
||||
|
||||
fn selection_availability(world: &World, selected: &SelectedEntities) -> OperatorAvailability {
|
||||
if selected_level_entities(world, selected).is_empty() {
|
||||
@@ -26,6 +30,7 @@ pub fn place_asset_operator(world: &mut World, asset: EditorAsset, translation:
|
||||
&label,
|
||||
OperatorAvailability::Ready,
|
||||
move |world| {
|
||||
validate_prefab_asset(world, &asset)?;
|
||||
spawn_asset_at(world, &asset, translation)
|
||||
.map(|_| ())
|
||||
.ok_or_else(|| format!("Asset cannot be placed: {}", asset.label))
|
||||
@@ -64,10 +69,7 @@ pub fn apply_texture_operator(
|
||||
"assets.apply_texture",
|
||||
&label,
|
||||
availability,
|
||||
move |world| {
|
||||
apply_texture_to_selection(world, &asset, selected);
|
||||
Ok(())
|
||||
},
|
||||
move |world| apply_texture_to_selection(world, &asset, selected),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -83,9 +85,452 @@ pub fn apply_material_operator(
|
||||
"assets.apply_material",
|
||||
&label,
|
||||
availability,
|
||||
move |world| apply_material_asset_to_selection(world, &asset, selected),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn assign_audio_clip_operator(world: &mut World, asset: EditorAsset, entity: Entity) -> bool {
|
||||
let availability = if world.get::<shared::AudioSourceDesc>(entity).is_some() {
|
||||
OperatorAvailability::Ready
|
||||
} else {
|
||||
OperatorAvailability::Disabled("Select an authored audio source".to_string())
|
||||
};
|
||||
let label = format!("Assign Audio Clip {}", asset.label);
|
||||
run_immediate_operator(
|
||||
world,
|
||||
"assets.assign_audio_clip",
|
||||
&label,
|
||||
availability,
|
||||
move |world| {
|
||||
apply_material_asset_to_selection(world, &asset, selected);
|
||||
let clip = audio_clip_ref_for_asset(world, &asset)?;
|
||||
let mut source = world
|
||||
.get::<shared::AudioSourceDesc>(entity)
|
||||
.cloned()
|
||||
.ok_or_else(|| "Selected actor is not an audio source".to_string())?;
|
||||
source.clip = Some(clip);
|
||||
crate::history::set_audio_source_with_history(world, entity, source);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn assign_animation_clip_operator(
|
||||
world: &mut World,
|
||||
selection: AssetSelection,
|
||||
entity: Entity,
|
||||
) -> bool {
|
||||
let availability = if world.get::<shared::SkinnedMeshRenderer>(entity).is_some() {
|
||||
OperatorAvailability::Ready
|
||||
} else {
|
||||
OperatorAvailability::Disabled("Select an authored skinned-mesh actor".to_string())
|
||||
};
|
||||
let label = format!("Assign Animation Clip {}", selection.display_label());
|
||||
run_immediate_operator(
|
||||
world,
|
||||
"assets.assign_animation_clip",
|
||||
&label,
|
||||
availability,
|
||||
move |world| {
|
||||
let authored = animation_clip_authoring_data(world, &selection)?;
|
||||
let model = world
|
||||
.get::<shared::SkinnedMeshRenderer>(entity)
|
||||
.cloned()
|
||||
.ok_or_else(|| "Selected actor has no SkinnedMeshRenderer".to_string())?;
|
||||
let mut controller = world
|
||||
.get::<shared::AnimationControllerDesc>(entity)
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
|
||||
let skeleton = match controller.skeleton.as_ref() {
|
||||
Some(reference) => {
|
||||
let existing_signature =
|
||||
animation_skeleton_signature_for_ref(world, reference)?;
|
||||
if existing_signature != authored.skeleton_signature {
|
||||
return Err(format!(
|
||||
"Clip `{}` targets rig `{}` but the actor uses `{}`. Animation v1 requires an exact skeleton match.",
|
||||
authored.state.label,
|
||||
authored.skeleton_signature.0,
|
||||
existing_signature.0
|
||||
));
|
||||
}
|
||||
reference.clone()
|
||||
}
|
||||
None => compatible_animation_skeleton_for_model(
|
||||
world,
|
||||
&model,
|
||||
&authored.skeleton_signature,
|
||||
)?,
|
||||
};
|
||||
|
||||
if controller.states.iter().any(|state| {
|
||||
state.clip.asset_id == authored.state.clip.asset_id
|
||||
&& state.clip.sub_asset_id == authored.state.clip.sub_asset_id
|
||||
}) {
|
||||
return Err(format!(
|
||||
"Animation controller already contains clip `{}`.",
|
||||
authored.state.label
|
||||
));
|
||||
}
|
||||
|
||||
let mut state = authored.state;
|
||||
let base_id = state.id.clone();
|
||||
let mut suffix = 2;
|
||||
while controller.states.iter().any(|entry| entry.id == state.id) {
|
||||
state.id = format!("{base_id}_{suffix}");
|
||||
suffix += 1;
|
||||
}
|
||||
controller.skeleton = Some(skeleton);
|
||||
if controller.default_state.trim().is_empty() {
|
||||
controller.default_state = state.id.clone();
|
||||
}
|
||||
controller.states.push(state);
|
||||
crate::history::set_animation_controller_with_history(world, entity, controller);
|
||||
Ok(())
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use shared::{
|
||||
animation_clip_sub_asset_id, animation_skeleton_sub_asset_id, ActorKind,
|
||||
AnimationClipRecord, AnimationControllerDesc, AnimationManifest, AnimationManifestSource,
|
||||
AnimationSkeletonRecord, AnimationSkeletonSignature, AnimationSourceFingerprint,
|
||||
AudioSourceDesc, LevelObject, MaterialDesc, PrimitiveShape, SkinnedMeshRenderer,
|
||||
ANIMATION_MANIFEST_SCHEMA_VERSION,
|
||||
};
|
||||
|
||||
use crate::asset_db::{AssetId, AssetRecord, AssetRegistry, ImportSettings};
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::{assert_undo_redo_round_trip, OperatorInvariantHarness};
|
||||
use crate::operators::ActiveOperator;
|
||||
use crate::scene_io::SceneIo;
|
||||
use crate::selection::SelectedEntity;
|
||||
|
||||
fn authored_count(world: &mut World) -> usize {
|
||||
let mut query = world.query_filtered::<Entity, With<LevelObject>>();
|
||||
query.iter(world).count()
|
||||
}
|
||||
|
||||
fn animation_fixture() -> (std::path::PathBuf, AssetRecord, AssetSelection) {
|
||||
let model_path = "assets/models/operator_fixture.glb".to_string();
|
||||
let asset_id = AssetId::new();
|
||||
let skeleton_id = animation_skeleton_sub_asset_id(0, "Rig");
|
||||
let clip_id = animation_clip_sub_asset_id(0, "Idle");
|
||||
let manifest = AnimationManifest {
|
||||
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(),
|
||||
},
|
||||
runtime_supported: true,
|
||||
skeletons: vec![AnimationSkeletonRecord {
|
||||
id: skeleton_id,
|
||||
label: "Rig".into(),
|
||||
source_index: 0,
|
||||
signature: AnimationSkeletonSignature::new("exact-rig"),
|
||||
joint_paths: vec!["Root".into()],
|
||||
}],
|
||||
clips: vec![AnimationClipRecord {
|
||||
id: clip_id.clone(),
|
||||
label: "Idle".into(),
|
||||
source_index: 0,
|
||||
duration_seconds: 1.0,
|
||||
target_skeleton_signature: Some(AnimationSkeletonSignature::new("exact-rig")),
|
||||
events: Vec::new(),
|
||||
}],
|
||||
diagnostics: Vec::new(),
|
||||
};
|
||||
let path = std::env::temp_dir().join(format!(
|
||||
"blacksite-animation-operator-{}.animation.ron",
|
||||
uuid::Uuid::new_v4()
|
||||
));
|
||||
std::fs::write(
|
||||
&path,
|
||||
ron::ser::to_string_pretty(&manifest, ron::ser::PrettyConfig::default()).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
let record = AssetRecord {
|
||||
id: asset_id,
|
||||
path: model_path.clone(),
|
||||
label: "Operator Fixture".into(),
|
||||
kind_tag: "Model".into(),
|
||||
import_settings: ImportSettings {
|
||||
animation_manifest_path: Some(path.to_string_lossy().into_owned()),
|
||||
..Default::default()
|
||||
},
|
||||
dependencies: Vec::new(),
|
||||
};
|
||||
let selection = AssetSelection::SubAsset {
|
||||
parent_path: model_path.clone(),
|
||||
sub_asset_id: clip_id,
|
||||
label: "Idle".into(),
|
||||
kind: super::super::AssetSubAssetKind::AnimationClip,
|
||||
source_path: Some(model_path),
|
||||
};
|
||||
(path, record, selection)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asset_placement_commits_one_undo_group_and_round_trips() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world.init_resource::<SelectedEntity>();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let asset = EditorAsset {
|
||||
label: "Cube".to_string(),
|
||||
path: None,
|
||||
folder_path: "Built-ins".to_string(),
|
||||
kind: super::super::EditorAssetKind::Primitive(PrimitiveShape::Box),
|
||||
};
|
||||
|
||||
assert!(place_asset_operator(&mut world, asset, Vec3::ZERO));
|
||||
|
||||
harness.assert_committed(&mut world, 1, 1);
|
||||
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();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let path = "assets/audio/impact.ogg".to_string();
|
||||
world.insert_resource(AssetRegistry {
|
||||
records: vec![AssetRecord {
|
||||
id: AssetId::new(),
|
||||
path: path.clone(),
|
||||
label: "Impact".into(),
|
||||
kind_tag: "AudioClip".into(),
|
||||
import_settings: Default::default(),
|
||||
dependencies: Vec::new(),
|
||||
}],
|
||||
index_dirty: false,
|
||||
});
|
||||
let entity = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
ActorKind::AudioSource,
|
||||
Transform::IDENTITY,
|
||||
AudioSourceDesc::default(),
|
||||
))
|
||||
.id();
|
||||
let asset = EditorAsset {
|
||||
label: "Impact".into(),
|
||||
path: Some(path.clone()),
|
||||
folder_path: "assets/audio".into(),
|
||||
kind: super::super::EditorAssetKind::AudioClip,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let read_clip = move |world: &mut World| {
|
||||
world
|
||||
.get::<AudioSourceDesc>(entity)
|
||||
.and_then(|source| source.clip.clone())
|
||||
};
|
||||
|
||||
assert!(assign_audio_clip_operator(&mut world, asset, entity));
|
||||
|
||||
let assigned = read_clip(&mut world).expect("clip assigned");
|
||||
assert_eq!(assigned.source_path.as_deref(), Some(path.as_str()));
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
assert_undo_redo_round_trip(&mut world, None, Some(assigned), read_clip);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn animation_clip_assignment_is_one_undoable_operator() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let (manifest_path, record, selection) = animation_fixture();
|
||||
let model_path = record.path.clone();
|
||||
world.insert_resource(AssetRegistry {
|
||||
records: vec![record],
|
||||
index_dirty: false,
|
||||
});
|
||||
let entity = world
|
||||
.spawn((
|
||||
LevelObject,
|
||||
ActorKind::SkinnedMesh,
|
||||
SkinnedMeshRenderer::new(model_path),
|
||||
))
|
||||
.id();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let read_controller =
|
||||
move |world: &mut World| world.get::<AnimationControllerDesc>(entity).cloned();
|
||||
|
||||
assert!(assign_animation_clip_operator(
|
||||
&mut world, selection, entity
|
||||
));
|
||||
|
||||
let assigned = read_controller(&mut world).expect("controller assigned");
|
||||
assert_eq!(assigned.default_state, "idle");
|
||||
assert_eq!(assigned.states.len(), 1);
|
||||
assert_eq!(assigned.states[0].id, "idle");
|
||||
assert_eq!(
|
||||
assigned.skeleton.as_ref().unwrap().sub_asset_id,
|
||||
animation_skeleton_sub_asset_id(0, "Rig")
|
||||
);
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
assert_undo_redo_round_trip(&mut world, None, Some(assigned), read_controller);
|
||||
let _ = std::fs::remove_file(manifest_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn multi_actor_texture_assignment_is_one_undo_group() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
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: "Grid".to_string(),
|
||||
path: Some("assets/textures/grid.png".to_string()),
|
||||
folder_path: "assets/textures".to_string(),
|
||||
kind: super::super::EditorAssetKind::Texture,
|
||||
};
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let read_textures = move |world: &mut World| {
|
||||
[first, second]
|
||||
.into_iter()
|
||||
.map(|entity| {
|
||||
world
|
||||
.get::<MaterialDesc>(entity)
|
||||
.and_then(|material| material.base_color_texture.clone())
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
assert!(apply_texture_operator(&mut world, asset, &selected));
|
||||
|
||||
harness.assert_committed(&mut world, 1, 0);
|
||||
assert_undo_redo_round_trip(
|
||||
&mut world,
|
||||
vec![None, None],
|
||||
vec![
|
||||
Some("assets/textures/grid.png".to_string()),
|
||||
Some("assets/textures/grid.png".to_string()),
|
||||
],
|
||||
read_textures,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_subasset_commit_cancels_without_side_effects() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let selection = AssetSelection::SubAsset {
|
||||
parent_path: "assets/models/missing.glb".to_string(),
|
||||
sub_asset_id: "mesh:missing".to_string(),
|
||||
label: "Missing Mesh".to_string(),
|
||||
kind: super::super::AssetSubAssetKind::Mesh,
|
||||
source_path: None,
|
||||
};
|
||||
|
||||
assert!(!place_subasset_operator(&mut world, selection, Vec3::ZERO));
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_material_source_cancels_without_side_effects() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
let entity = world.spawn(LevelObject).id();
|
||||
let mut selected = SelectedEntities::default();
|
||||
selected.select_replace(entity);
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
let asset = EditorAsset {
|
||||
label: "Missing Material".to_string(),
|
||||
path: Some("assets/materials/does-not-exist.material.ron".to_string()),
|
||||
folder_path: "assets/materials".to_string(),
|
||||
kind: super::super::EditorAssetKind::Material,
|
||||
};
|
||||
|
||||
assert!(!apply_material_operator(&mut world, asset, &selected));
|
||||
|
||||
harness.assert_canceled(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn texture_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: "Grid".to_string(),
|
||||
path: Some("assets/textures/grid.png".to_string()),
|
||||
folder_path: "assets/textures".to_string(),
|
||||
kind: super::super::EditorAssetKind::Texture,
|
||||
};
|
||||
|
||||
assert!(!apply_texture_operator(
|
||||
&mut world,
|
||||
asset,
|
||||
&SelectedEntities::default()
|
||||
));
|
||||
|
||||
harness.assert_blocked(&mut world);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -14,9 +14,12 @@ use serde::{Deserialize, Serialize};
|
||||
use crate::asset_db::{
|
||||
AssetRecord, ImportSettings, MaterialImportPolicy, ModelHierarchyMode, ModelPlacementMode,
|
||||
};
|
||||
use shared::{ComponentInstanceId, EditorAssetRef, StaticMeshRenderer, StaticMeshRendererEntry};
|
||||
use shared::{
|
||||
ComponentInstanceId, EditorAssetRef, MaterialRef, RendererMaterialSet, RendererMaterialSlot,
|
||||
StaticMeshRenderer, StaticMeshRendererEntry,
|
||||
};
|
||||
|
||||
pub const STATIC_MESH_MANIFEST_SCHEMA: u32 = 1;
|
||||
pub const STATIC_MESH_MANIFEST_SCHEMA: u32 = 3;
|
||||
pub const STATIC_MESH_ARTIFACT_DIR: &str = "assets/meshes/generated";
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
@@ -80,6 +83,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 +101,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() {
|
||||
@@ -151,38 +169,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)
|
||||
@@ -255,23 +341,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 +392,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 +460,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 +476,7 @@ fn collect_gltf_mesh_parts(
|
||||
source_node,
|
||||
source_mesh: Some(format!("Mesh{mesh_index}")),
|
||||
source_material: Some(material_name),
|
||||
skinned,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -405,6 +509,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 +533,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 +545,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(),
|
||||
);
|
||||
}
|
||||
@@ -554,6 +660,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 {
|
||||
@@ -597,6 +704,7 @@ mod tests {
|
||||
source_node: Some("Node0".into()),
|
||||
source_mesh: Some("Mesh0".into()),
|
||||
source_material: Some("Wood".into()),
|
||||
skinned: false,
|
||||
}],
|
||||
warnings: Vec::new(),
|
||||
}
|
||||
@@ -645,4 +753,48 @@ 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(),
|
||||
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());
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ use bevy::prelude::*;
|
||||
use bevy_egui::{egui, EguiPrimaryContextPass, EguiTextureHandle, EguiUserTextures};
|
||||
use egui_phosphor_icons::icons;
|
||||
|
||||
use super::sources::gltf::gltf_base_color_texture_path;
|
||||
use super::sources::gltf::{gltf_base_color_texture_path, validate_gltf_dependencies};
|
||||
use super::studio::{model_file_exists, ThumbnailStudio};
|
||||
use super::ThumbnailJobSource;
|
||||
use crate::assets::{
|
||||
@@ -100,13 +100,12 @@ impl AssetThumbnailCache {
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(texture_path) = gltf_base_color_texture_path(&model_path) {
|
||||
self.request_texture(key, texture_path, asset_server);
|
||||
if !self.model_source_ready(&key, &model_path) {
|
||||
return;
|
||||
}
|
||||
|
||||
if !model_file_exists(&model_path) {
|
||||
self.mark_studio_failed(&key, "file not found", false);
|
||||
if let Some(texture_path) = gltf_base_color_texture_path(&model_path) {
|
||||
self.request_texture(key, texture_path, asset_server);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -121,6 +120,7 @@ impl AssetThumbnailCache {
|
||||
model_path: String,
|
||||
mesh_label: String,
|
||||
material_label: Option<String>,
|
||||
requires_scene_instance: bool,
|
||||
studio: &mut ThumbnailStudio,
|
||||
) {
|
||||
if matches!(
|
||||
@@ -130,18 +130,19 @@ impl AssetThumbnailCache {
|
||||
{
|
||||
return;
|
||||
}
|
||||
if !model_file_exists(&model_path) {
|
||||
self.mark_studio_failed(&key, "file not found", false);
|
||||
if !self.model_source_ready(&key, &model_path) {
|
||||
return;
|
||||
}
|
||||
if studio.enqueue_source(
|
||||
key.clone(),
|
||||
let source = if requires_scene_instance {
|
||||
ThumbnailJobSource::Model { model_path }
|
||||
} else {
|
||||
ThumbnailJobSource::MeshSubAsset {
|
||||
model_path,
|
||||
mesh_label,
|
||||
material_label,
|
||||
},
|
||||
) {
|
||||
}
|
||||
};
|
||||
if studio.enqueue_source(key.clone(), source) {
|
||||
self.studio_pending.insert(key);
|
||||
}
|
||||
}
|
||||
@@ -160,8 +161,7 @@ impl AssetThumbnailCache {
|
||||
{
|
||||
return;
|
||||
}
|
||||
if !model_file_exists(&model_path) {
|
||||
self.mark_studio_failed(&key, "file not found", false);
|
||||
if !self.model_source_ready(&key, &model_path) {
|
||||
return;
|
||||
}
|
||||
if studio.enqueue_source(
|
||||
@@ -188,24 +188,42 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
fn model_source_ready(&mut self, key: &str, model_path: &str) -> bool {
|
||||
if !model_file_exists(model_path) {
|
||||
self.mark_studio_failed(key, "file not found", false);
|
||||
return false;
|
||||
}
|
||||
if let Err(reason) = validate_gltf_dependencies(model_path) {
|
||||
self.mark_studio_failed(key, &reason, false);
|
||||
return false;
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn complete_studio_thumbnail(
|
||||
&mut self,
|
||||
key: &str,
|
||||
@@ -283,6 +301,7 @@ pub fn kind_icon(kind: &EditorAssetKind) -> egui_phosphor_icons::Icon {
|
||||
EditorAssetKind::Model => icons::CUBE_TRANSPARENT,
|
||||
EditorAssetKind::Texture => icons::IMAGE,
|
||||
EditorAssetKind::Material => icons::PAINT_BRUSH,
|
||||
EditorAssetKind::AudioClip => icons::WAVEFORM,
|
||||
EditorAssetKind::Level => icons::MAP_TRIFOLD,
|
||||
EditorAssetKind::Prefab => icons::PACKAGE,
|
||||
EditorAssetKind::PostProcessVolume => icons::CAMERA,
|
||||
@@ -469,6 +488,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>() {
|
||||
|
||||
@@ -8,11 +8,14 @@ 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::{FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource};
|
||||
pub use sources::{
|
||||
gltf_skinned_primitive_labels, FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource,
|
||||
};
|
||||
pub use studio::{
|
||||
model_file_exists, model_scene_asset_path, ThumbnailStudio, ThumbnailStudioPlugin,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! glTF/GLB fast-path texture extraction for asset browser thumbnails.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
|
||||
/// Returns an asset-server path for the first base-color texture referenced by a glTF/GLB file.
|
||||
@@ -29,6 +30,67 @@ pub fn gltf_base_color_texture_path(model_asset_path: &str) -> Option<String> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Verifies local external buffers and images before Bevy starts an async glTF load.
|
||||
pub fn validate_gltf_dependencies(model_asset_path: &str) -> Result<(), String> {
|
||||
let model_path = Path::new(model_asset_path);
|
||||
if !is_gltf_path(model_path) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let gltf = gltf::Gltf::open(model_path).map_err(|error| format!("invalid glTF: {error}"))?;
|
||||
let mut uris = Vec::new();
|
||||
for buffer in gltf.buffers() {
|
||||
if let gltf::buffer::Source::Uri(uri) = buffer.source() {
|
||||
uris.push(uri);
|
||||
}
|
||||
}
|
||||
for image in gltf.images() {
|
||||
if let gltf::image::Source::Uri { uri, .. } = image.source() {
|
||||
uris.push(uri);
|
||||
}
|
||||
}
|
||||
|
||||
let model_dir = model_path.parent().unwrap_or_else(|| Path::new(""));
|
||||
for uri in uris {
|
||||
if uri.starts_with("data:") || uri.contains("://") {
|
||||
continue;
|
||||
}
|
||||
let dependency = model_dir.join(uri);
|
||||
if !dependency.is_file() {
|
||||
let display = normalize_asset_path(&dependency)
|
||||
.unwrap_or_else(|| dependency.to_string_lossy().replace('\\', "/"));
|
||||
return Err(format!("missing dependency: {display}"));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns primitive labels that cannot be rendered without their source skin hierarchy.
|
||||
pub fn gltf_skinned_primitive_labels(model_asset_path: &str) -> HashSet<String> {
|
||||
let model_path = Path::new(model_asset_path);
|
||||
if !is_gltf_path(model_path) {
|
||||
return HashSet::new();
|
||||
}
|
||||
let Ok(gltf) = gltf::Gltf::open(model_path) else {
|
||||
return HashSet::new();
|
||||
};
|
||||
gltf.meshes()
|
||||
.flat_map(|mesh| {
|
||||
let mesh_index = mesh.index();
|
||||
mesh.primitives()
|
||||
.filter(|primitive| {
|
||||
primitive.attributes().any(|(semantic, _)| {
|
||||
matches!(
|
||||
semantic,
|
||||
gltf::Semantic::Joints(_) | gltf::Semantic::Weights(_)
|
||||
)
|
||||
})
|
||||
})
|
||||
.map(move |primitive| format!("Mesh{mesh_index}/Primitive{}", primitive.index()))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub struct GltfThumbnailSource;
|
||||
|
||||
fn is_gltf_path(path: &Path) -> bool {
|
||||
@@ -61,7 +123,9 @@ fn normalize_asset_path(path: &Path) -> Option<String> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[test]
|
||||
fn normalize_asset_path_keeps_assets_prefix() {
|
||||
@@ -79,4 +143,37 @@ mod tests {
|
||||
Some("assets/models/textures/chair_albedo.png".into())
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dependency_validation_reports_missing_external_buffer() {
|
||||
let nonce = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_nanos();
|
||||
let directory = std::env::temp_dir().join(format!("blacksite-gltf-{nonce}"));
|
||||
fs::create_dir_all(&directory).unwrap();
|
||||
let model = directory.join("missing-buffer.gltf");
|
||||
fs::write(
|
||||
&model,
|
||||
r#"{"asset":{"version":"2.0"},"buffers":[{"uri":"missing.bin","byteLength":4}]}"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let error = validate_gltf_dependencies(model.to_str().unwrap()).unwrap_err();
|
||||
assert!(error.contains("missing.bin"));
|
||||
|
||||
fs::remove_dir_all(directory).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn committed_robot_fixture_identifies_skinned_primitives() {
|
||||
let path =
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../assets/models/robot_expressive.glb");
|
||||
let labels = gltf_skinned_primitive_labels(path.to_str().unwrap());
|
||||
|
||||
assert!(labels.contains("Mesh12/Primitive0"));
|
||||
assert!(labels.contains("Mesh13/Primitive0"));
|
||||
assert!(!labels.contains("Mesh0/Primitive0"));
|
||||
assert!(!labels.contains("Mesh999/Primitive0"));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ mod fbx;
|
||||
pub(crate) mod gltf;
|
||||
|
||||
pub use fbx::FbxThumbnailSource;
|
||||
pub use gltf::GltfThumbnailSource;
|
||||
pub use gltf::{gltf_skinned_primitive_labels, GltfThumbnailSource};
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ use bevy::mesh::VertexAttributeValues;
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::render_resource::TextureFormat;
|
||||
use bevy_egui::EguiUserTextures;
|
||||
use shared::{material_from_desc, ModelRef};
|
||||
use shared::{material_from_desc, standard_material_asset_path, ModelRef};
|
||||
|
||||
use super::cache::AssetThumbnailCache;
|
||||
use super::job::{ThumbnailJob, ThumbnailJobSource};
|
||||
@@ -21,6 +21,10 @@ 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 RENDER_FRAMES: u8 = 3;
|
||||
@@ -61,6 +65,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 +166,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()
|
||||
}),
|
||||
))
|
||||
@@ -229,6 +252,7 @@ fn process_thumbnail_studio(
|
||||
&mesh3d,
|
||||
&mesh_storage,
|
||||
&mut camera_transforms,
|
||||
active.framing,
|
||||
) {
|
||||
active.framed = true;
|
||||
active.post_attach_frames = 0;
|
||||
@@ -315,10 +339,14 @@ fn process_thumbnail_studio(
|
||||
ThumbnailStudioLayer,
|
||||
RenderLayers::layer(THUMBNAIL_LAYER),
|
||||
Transform::default(),
|
||||
Visibility::Visible,
|
||||
InheritedVisibility::default(),
|
||||
ViewVisibility::default(),
|
||||
))
|
||||
.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,
|
||||
@@ -347,6 +375,7 @@ fn process_thumbnail_studio(
|
||||
framed: false,
|
||||
frames_remaining: 0,
|
||||
wait_frames: 0,
|
||||
framing,
|
||||
},
|
||||
"no renderable meshes",
|
||||
true,
|
||||
@@ -366,6 +395,7 @@ fn process_thumbnail_studio(
|
||||
framed: false,
|
||||
frames_remaining: 0,
|
||||
wait_frames: 0,
|
||||
framing,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -410,7 +440,7 @@ fn spawn_thumbnail_job_content(
|
||||
commands,
|
||||
mesh_storage,
|
||||
root,
|
||||
asset_server.load(labeled_asset_path(
|
||||
asset_server.load(standard_material_asset_path(
|
||||
&asset_server_path(model_path),
|
||||
material_label,
|
||||
)),
|
||||
@@ -434,7 +464,7 @@ fn spawn_mesh_subasset_preview(
|
||||
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 {
|
||||
asset_server.load(labeled_asset_path(&source_path, material_label))
|
||||
asset_server.load(standard_material_asset_path(&source_path, material_label))
|
||||
} else {
|
||||
materials.add(StandardMaterial {
|
||||
base_color: Color::srgb(0.72, 0.72, 0.75),
|
||||
@@ -585,6 +615,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);
|
||||
@@ -630,8 +661,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() {
|
||||
@@ -641,6 +671,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 {
|
||||
@@ -670,3 +714,24 @@ 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));
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,27 @@
|
||||
//! In-process editor binary entry point.
|
||||
|
||||
fn main() {
|
||||
let startup = match editor::launcher::parse_startup_arguments(std::env::args().skip(1)) {
|
||||
Ok(startup) => startup,
|
||||
Err(error) => {
|
||||
eprintln!(
|
||||
"Blacksite Editor: {error}\n\n{}",
|
||||
editor::launcher::command_line_help()
|
||||
);
|
||||
std::process::exit(2);
|
||||
}
|
||||
};
|
||||
if startup.help {
|
||||
println!("{}", editor::launcher::command_line_help());
|
||||
return;
|
||||
}
|
||||
if let Some(root) = startup.project {
|
||||
if let Err(error) = editor::launcher::activate_project_root(&root) {
|
||||
eprintln!("Blacksite Editor: {error}");
|
||||
std::process::exit(2);
|
||||
}
|
||||
}
|
||||
|
||||
if std::env::var_os("WGPU_VALIDATION").is_none() {
|
||||
// SAFETY: called before any threads or GPU init.
|
||||
unsafe { std::env::set_var("WGPU_VALIDATION", "0") };
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
//! Dedicated pre-engine Blacksite project browser.
|
||||
|
||||
fn main() {
|
||||
if std::env::var_os("WGPU_VALIDATION").is_none() {
|
||||
// SAFETY: called before Bevy starts worker threads or initializes the renderer.
|
||||
unsafe { std::env::set_var("WGPU_VALIDATION", "0") };
|
||||
}
|
||||
editor::launcher::run_project_launcher();
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use shared::{
|
||||
ActorId, ActorKind, ActorName, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder,
|
||||
LightDesc, MaterialDesc, MaterialOverride, ModelRef, ObjectiveMarker, PhysicsBody,
|
||||
PostProcessVolumeDesc, PrefabInstance, PrefabRef, Primitive, RigidBodyDesc, StaticMeshRenderer,
|
||||
ActorId, ActorKind, ActorName, AnimationControllerDesc, AudioListenerDesc, AudioSourceDesc,
|
||||
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)]
|
||||
@@ -15,12 +19,16 @@ 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>,
|
||||
pub collider: Option<ColliderDesc>,
|
||||
pub physics: Option<PhysicsBody>,
|
||||
pub light: Option<LightDesc>,
|
||||
pub animation_controller: Option<AnimationControllerDesc>,
|
||||
pub audio_source: Option<AudioSourceDesc>,
|
||||
pub audio_listener: Option<AudioListenerDesc>,
|
||||
pub player_spawn: bool,
|
||||
pub model: Option<ModelRef>,
|
||||
pub prefab: Option<PrefabRef>,
|
||||
@@ -30,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,
|
||||
@@ -42,6 +91,17 @@ pub struct SiblingChange {
|
||||
pub new_parent: Option<Entity>,
|
||||
pub old_index: i32,
|
||||
pub new_index: i32,
|
||||
pub old_transform: Option<Transform>,
|
||||
pub new_transform: Option<Transform>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct PrefabEditState {
|
||||
pub instance: Option<PrefabInstance>,
|
||||
pub prefab_ref: Option<PrefabRef>,
|
||||
pub blocked_reason: Option<String>,
|
||||
pub transform: Option<Transform>,
|
||||
pub material: Option<MaterialDesc>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -77,6 +137,11 @@ pub enum EditorCommand {
|
||||
old: Option<MaterialDesc>,
|
||||
new: MaterialDesc,
|
||||
},
|
||||
SetMaterialGroup {
|
||||
entities: Vec<Entity>,
|
||||
olds: Vec<Option<MaterialDesc>>,
|
||||
news: Vec<MaterialDesc>,
|
||||
},
|
||||
SetMaterialOverride {
|
||||
entity: Entity,
|
||||
old: Option<MaterialOverride>,
|
||||
@@ -87,6 +152,21 @@ pub enum EditorCommand {
|
||||
old: Option<LightDesc>,
|
||||
new: LightDesc,
|
||||
},
|
||||
SetAnimationController {
|
||||
entity: Entity,
|
||||
old: Option<AnimationControllerDesc>,
|
||||
new: AnimationControllerDesc,
|
||||
},
|
||||
SetAudioSource {
|
||||
entity: Entity,
|
||||
old: Option<AudioSourceDesc>,
|
||||
new: AudioSourceDesc,
|
||||
},
|
||||
SetAudioListener {
|
||||
entity: Entity,
|
||||
old: Option<AudioListenerDesc>,
|
||||
new: AudioListenerDesc,
|
||||
},
|
||||
SetPhysics {
|
||||
entity: Entity,
|
||||
old: Option<PhysicsBody>,
|
||||
@@ -137,6 +217,11 @@ pub enum EditorCommand {
|
||||
old: Option<PostProcessVolumeDesc>,
|
||||
new: PostProcessVolumeDesc,
|
||||
},
|
||||
SetNavigation {
|
||||
entity: Entity,
|
||||
old: NavigationComponentState,
|
||||
new: NavigationComponentState,
|
||||
},
|
||||
SetTransformGroup {
|
||||
entities: Vec<Entity>,
|
||||
olds: Vec<Transform>,
|
||||
@@ -165,6 +250,35 @@ pub enum EditorCommand {
|
||||
old: Option<InspectorOrder>,
|
||||
new: InspectorOrder,
|
||||
},
|
||||
SetSceneComposition {
|
||||
old: SceneComposition,
|
||||
new: SceneComposition,
|
||||
},
|
||||
SetPrefabState {
|
||||
entity: Entity,
|
||||
old: PrefabEditState,
|
||||
new: PrefabEditState,
|
||||
},
|
||||
ApplyPrefabToSource {
|
||||
entity: Entity,
|
||||
source_path: PathBuf,
|
||||
before_source: String,
|
||||
after_source: String,
|
||||
old: PrefabEditState,
|
||||
new: PrefabEditState,
|
||||
},
|
||||
UnpackPrefab {
|
||||
entity: Entity,
|
||||
instance: PrefabInstance,
|
||||
prefab_ref: PrefabRef,
|
||||
linked_actor_kind: ActorKind,
|
||||
fully_local: bool,
|
||||
linked_local_snapshots: Vec<EditorEntitySnapshot>,
|
||||
linked_local_roots: Vec<Entity>,
|
||||
unpacked_snapshots: Vec<EditorEntitySnapshot>,
|
||||
unpacked_parented_to_anchor: Vec<bool>,
|
||||
unpacked_roots: Vec<Entity>,
|
||||
},
|
||||
AddComponent {
|
||||
entity: Entity,
|
||||
snapshot: EditorEntitySnapshot,
|
||||
@@ -173,6 +287,7 @@ pub enum EditorCommand {
|
||||
entity: Entity,
|
||||
snapshot: EditorEntitySnapshot,
|
||||
},
|
||||
ComponentTransaction(ComponentTransaction),
|
||||
}
|
||||
|
||||
impl EditorCommand {
|
||||
@@ -185,8 +300,12 @@ impl EditorCommand {
|
||||
EditorCommand::Rename { .. } => "Rename",
|
||||
EditorCommand::SetTransform { .. } => "Move",
|
||||
EditorCommand::SetMaterial { .. } => "Set Material",
|
||||
EditorCommand::SetMaterialGroup { .. } => "Apply Material to Selection",
|
||||
EditorCommand::SetMaterialOverride { .. } => "Set Material Override",
|
||||
EditorCommand::SetLight { .. } => "Set Light",
|
||||
EditorCommand::SetAnimationController { .. } => "Set Animation Controller",
|
||||
EditorCommand::SetAudioSource { .. } => "Set Audio Source",
|
||||
EditorCommand::SetAudioListener { .. } => "Set Audio Listener",
|
||||
EditorCommand::SetPhysics { .. } => "Set Physics",
|
||||
EditorCommand::SetRigidBody { .. } => "Set Rigid Body",
|
||||
EditorCommand::SetCollider { .. } => "Set Collider",
|
||||
@@ -196,14 +315,25 @@ 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",
|
||||
EditorCommand::ReorderSibling { .. } => "Reorder Hierarchy",
|
||||
EditorCommand::SetEditorVisibility { .. } => "Set Visibility",
|
||||
EditorCommand::SetInspectorOrder { .. } => "Set Component Order",
|
||||
EditorCommand::SetSceneComposition { .. } => "Set Scene Composition",
|
||||
EditorCommand::SetPrefabState { .. } => "Edit Prefab Instance",
|
||||
EditorCommand::ApplyPrefabToSource { .. } => "Apply Prefab to Source",
|
||||
EditorCommand::UnpackPrefab {
|
||||
fully_local: true, ..
|
||||
} => "Convert Prefab to Local",
|
||||
EditorCommand::UnpackPrefab {
|
||||
fully_local: false, ..
|
||||
} => "Unpack Prefab Layer",
|
||||
EditorCommand::AddComponent { .. } => "Add Component",
|
||||
EditorCommand::RemoveComponent { .. } => "Remove Component",
|
||||
EditorCommand::ComponentTransaction(transaction) => transaction.label,
|
||||
}
|
||||
}
|
||||
}
|
||||
+2047
-30
File diff suppressed because it is too large.
Load diff
@@ -22,7 +22,12 @@ 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::session;
|
||||
pub use project::settings_ui;
|
||||
pub use scene::scene_io;
|
||||
pub use scene::scene_schema;
|
||||
@@ -33,6 +38,7 @@ 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::render_view;
|
||||
pub use viewport::rendering_diagnostics;
|
||||
pub use viewport::selection;
|
||||
@@ -43,7 +49,8 @@ use bevy::app::PluginGroupBuilder;
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::EguiPlugin;
|
||||
use game::{
|
||||
launch, GameInputEnabled, GameInputFocused, GamePlugin, GameRenderBootstrap, SimEnabled,
|
||||
launch, GameInputEnabled, GameInputFocused, GamePlugin, GameRenderBootstrap,
|
||||
GameSceneBootstrap, SimEnabled,
|
||||
};
|
||||
use transform_gizmo_bevy::prelude::TransformGizmoPlugin;
|
||||
|
||||
@@ -57,14 +64,19 @@ use extensibility::ExtensibilityPlugin;
|
||||
use gizmos::EditorGizmoPlugin;
|
||||
use history::EditorHistoryPlugin;
|
||||
use infra::EditorInfraPlugin;
|
||||
use material_drop::MaterialDropPlugin;
|
||||
use operators::OperatorPlugin;
|
||||
use play::audio_preview::AudioPreviewPlugin;
|
||||
use play::PlaySessionPlugin;
|
||||
use project::collaboration::CollaborationPlugin;
|
||||
use project::native_dialog::NativeDialogPlugin;
|
||||
use project_io::ProjectIoPlugin;
|
||||
use render_view::RenderViewPlugin;
|
||||
use scene_io::SceneIoPlugin;
|
||||
use scene_view::SceneViewPlugin;
|
||||
use selection::EditorSelectionPlugin;
|
||||
use selection_outline::SelectionOutlinePlugin;
|
||||
use session::EditorSessionPlugin;
|
||||
use settings_ui::SettingsUiPlugin;
|
||||
use state::EditorStatePlugin;
|
||||
use ui::EditorUiPlugin;
|
||||
@@ -80,6 +92,7 @@ impl PluginGroup for EditorPluginGroup {
|
||||
let group = PluginGroupBuilder::start::<Self>()
|
||||
.add(EditorInfraPlugin)
|
||||
.add(ProjectIoPlugin)
|
||||
.add(NativeDialogPlugin)
|
||||
.add(scene_schema::SceneSchemaPlugin)
|
||||
.add(net_editor::NetEditorPlugin)
|
||||
.add(AssetDbPlugin)
|
||||
@@ -97,14 +110,18 @@ impl PluginGroup for EditorPluginGroup {
|
||||
.add(BrushEditPlugin)
|
||||
.add(BrushToolPlugin)
|
||||
.add(EditorCameraPlugin)
|
||||
.add(AudioPreviewPlugin)
|
||||
.add(ActorIconsPlugin)
|
||||
.add(MaterialDropPlugin)
|
||||
.add(EditorSelectionPlugin)
|
||||
.add(SelectionOutlinePlugin)
|
||||
.add(EditorGizmoPlugin)
|
||||
.add(EditorVisualizersPlugin)
|
||||
.add(EditorHistoryPlugin)
|
||||
.add(SceneIoPlugin)
|
||||
.add(CollaborationPlugin)
|
||||
.add(EditorUiPlugin)
|
||||
.add(EditorSessionPlugin)
|
||||
.add(brp::BrpPlugin);
|
||||
#[cfg(feature = "hot-reload")]
|
||||
let group = group.add(hot_reload::HotReloadPlugin);
|
||||
@@ -121,6 +138,9 @@ pub fn configure_editor_app(app: &mut App) {
|
||||
.insert_resource(GameRenderBootstrap {
|
||||
defer_player_camera_fx: true,
|
||||
})
|
||||
.insert_resource(GameSceneBootstrap {
|
||||
defer_default_level: true,
|
||||
})
|
||||
.add_plugins(GamePlugin)
|
||||
.add_plugins(MeshPickingPlugin)
|
||||
.add_plugins(TransformGizmoPlugin)
|
||||
|
||||
@@ -4,6 +4,9 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::history::EditorHistory;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) mod test_harness;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum OperatorPhase {
|
||||
Idle,
|
||||
@@ -227,12 +230,19 @@ fn set_operator_status(world: &mut World, status: OperatorStatus) {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::history::EditorHistory;
|
||||
use crate::operators::test_harness::OperatorInvariantHarness;
|
||||
use crate::scene_io::SceneIo;
|
||||
|
||||
#[derive(Resource, Default)]
|
||||
struct Counter(i32);
|
||||
|
||||
#[derive(Component)]
|
||||
struct PreviewHelper;
|
||||
|
||||
struct CounterOperator {
|
||||
before: i32,
|
||||
helper: Option<Entity>,
|
||||
}
|
||||
|
||||
impl EditorOperator for CounterOperator {
|
||||
@@ -246,6 +256,7 @@ mod tests {
|
||||
|
||||
fn begin(&mut self, world: &mut World) -> Result<(), String> {
|
||||
self.before = world.resource::<Counter>().0;
|
||||
self.helper = Some(world.spawn(PreviewHelper).id());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -254,34 +265,50 @@ mod tests {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn commit(&mut self, _world: &mut World) -> Result<(), String> {
|
||||
fn commit(&mut self, world: &mut World) -> Result<(), String> {
|
||||
self.remove_helper(world);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn cancel(&mut self, world: &mut World) {
|
||||
world.resource_mut::<Counter>().0 = self.before;
|
||||
self.remove_helper(world);
|
||||
}
|
||||
}
|
||||
|
||||
impl CounterOperator {
|
||||
fn remove_helper(&mut self, world: &mut World) {
|
||||
if let Some(helper) = self.helper.take() {
|
||||
if let Ok(entity) = world.get_entity_mut(helper) {
|
||||
entity.despawn();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn test_world() -> World {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<Counter>();
|
||||
world.init_resource::<EditorHistory>();
|
||||
world.init_resource::<SceneIo>();
|
||||
world
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn operator_commit_keeps_previewed_change() {
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<Counter>();
|
||||
let mut world = test_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
let mut operator = CounterOperator { before: 0 };
|
||||
let mut operator = CounterOperator {
|
||||
before: 0,
|
||||
helper: None,
|
||||
};
|
||||
|
||||
assert!(run_operator(&mut world, &mut operator));
|
||||
assert_eq!(world.resource::<Counter>().0, 1);
|
||||
assert_eq!(
|
||||
world
|
||||
.resource::<ActiveOperator>()
|
||||
.status
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.phase,
|
||||
OperatorPhase::Committed
|
||||
);
|
||||
harness.assert_committed(&mut world, 0, 0);
|
||||
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -314,22 +341,38 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
let mut world = World::new();
|
||||
world.init_resource::<ActiveOperator>();
|
||||
world.init_resource::<Counter>();
|
||||
let mut world = test_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
let mut operator = FailingCounterOperator(CounterOperator { before: 0 });
|
||||
let mut operator = FailingCounterOperator(CounterOperator {
|
||||
before: 0,
|
||||
helper: None,
|
||||
});
|
||||
|
||||
assert!(!run_operator(&mut world, &mut operator));
|
||||
assert_eq!(world.resource::<Counter>().0, 0);
|
||||
assert_eq!(
|
||||
world
|
||||
.resource::<ActiveOperator>()
|
||||
.status
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.phase,
|
||||
OperatorPhase::Canceled
|
||||
harness.assert_canceled(&mut world);
|
||||
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn blocked_operator_never_begins_or_mutates_world() {
|
||||
let mut world = test_world();
|
||||
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||
|
||||
let result = run_immediate_operator(
|
||||
&mut world,
|
||||
"test.blocked",
|
||||
"Blocked Operator",
|
||||
OperatorAvailability::Disabled("fixture unavailable".to_string()),
|
||||
|world| {
|
||||
world.resource_mut::<Counter>().0 += 1;
|
||||
Ok(())
|
||||
},
|
||||
);
|
||||
|
||||
assert!(!result);
|
||||
assert_eq!(world.resource::<Counter>().0, 0);
|
||||
harness.assert_blocked(&mut world);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
//! Reusable invariant assertions for modal tools and editor operators.
|
||||
|
||||
use std::fmt::Debug;
|
||||
|
||||
use bevy::prelude::*;
|
||||
use shared::LevelObject;
|
||||
|
||||
use crate::history::{apply_command_redo, apply_command_undo, EditorHistory};
|
||||
use crate::operators::{ActiveOperator, OperatorPhase};
|
||||
use crate::scene_io::SceneIo;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct OperatorInvariantHarness {
|
||||
undo_depth: usize,
|
||||
dirty: bool,
|
||||
authored_count: usize,
|
||||
}
|
||||
|
||||
impl OperatorInvariantHarness {
|
||||
pub(crate) fn capture(world: &mut World) -> Self {
|
||||
Self {
|
||||
undo_depth: world
|
||||
.get_resource::<EditorHistory>()
|
||||
.map(EditorHistory::undo_depth)
|
||||
.unwrap_or_default(),
|
||||
dirty: world
|
||||
.get_resource::<SceneIo>()
|
||||
.is_some_and(|scene_io| scene_io.dirty),
|
||||
authored_count: authored_count(world),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn assert_committed(
|
||||
&self,
|
||||
world: &mut World,
|
||||
undo_delta: usize,
|
||||
authored_delta: isize,
|
||||
) {
|
||||
self.assert_phase(world, OperatorPhase::Committed);
|
||||
assert_eq!(
|
||||
world.resource::<EditorHistory>().undo_depth(),
|
||||
self.undo_depth + undo_delta,
|
||||
"committed operator must create the expected number of undo groups"
|
||||
);
|
||||
if undo_delta > 0 {
|
||||
assert!(
|
||||
world.resource::<SceneIo>().dirty,
|
||||
"a committed authored mutation must mark the scene dirty"
|
||||
);
|
||||
}
|
||||
assert_eq!(
|
||||
authored_count(world) as isize,
|
||||
self.authored_count as isize + authored_delta,
|
||||
"committed operator changed an unexpected number of authored entities"
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_canceled(&self, world: &mut World) {
|
||||
self.assert_phase(world, OperatorPhase::Canceled);
|
||||
assert_eq!(
|
||||
world.resource::<EditorHistory>().undo_depth(),
|
||||
self.undo_depth,
|
||||
"canceled operator must not create undo history"
|
||||
);
|
||||
assert_eq!(
|
||||
world.resource::<SceneIo>().dirty,
|
||||
self.dirty,
|
||||
"canceled operator must preserve the prior dirty state"
|
||||
);
|
||||
assert_eq!(
|
||||
authored_count(world),
|
||||
self.authored_count,
|
||||
"canceled operator must restore authored entity state"
|
||||
);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_blocked(&self, world: &mut World) {
|
||||
self.assert_phase(world, OperatorPhase::Blocked);
|
||||
assert_eq!(
|
||||
world.resource::<EditorHistory>().undo_depth(),
|
||||
self.undo_depth
|
||||
);
|
||||
assert_eq!(world.resource::<SceneIo>().dirty, self.dirty);
|
||||
assert_eq!(authored_count(world), self.authored_count);
|
||||
}
|
||||
|
||||
pub(crate) fn assert_no_helpers<T: Component>(&self, world: &mut World) {
|
||||
let mut query = world.query_filtered::<Entity, With<T>>();
|
||||
assert_eq!(
|
||||
query.iter(world).count(),
|
||||
0,
|
||||
"operator left preview/helper entities behind"
|
||||
);
|
||||
}
|
||||
|
||||
fn assert_phase(&self, world: &World, expected: OperatorPhase) {
|
||||
let phase = world
|
||||
.resource::<ActiveOperator>()
|
||||
.status
|
||||
.as_ref()
|
||||
.map(|status| status.phase.clone());
|
||||
assert_eq!(phase, Some(expected), "operator reported the wrong phase");
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn assert_undo_redo_round_trip<T>(
|
||||
world: &mut World,
|
||||
initial: T,
|
||||
committed: T,
|
||||
mut read: impl FnMut(&mut World) -> T,
|
||||
) where
|
||||
T: Debug + PartialEq,
|
||||
{
|
||||
assert_eq!(
|
||||
read(world),
|
||||
committed,
|
||||
"commit state did not match expectation"
|
||||
);
|
||||
apply_command_undo(world);
|
||||
assert_eq!(
|
||||
read(world),
|
||||
initial,
|
||||
"undo did not restore the initial state"
|
||||
);
|
||||
apply_command_redo(world);
|
||||
assert_eq!(
|
||||
read(world),
|
||||
committed,
|
||||
"redo did not restore the committed state"
|
||||
);
|
||||
}
|
||||
|
||||
fn authored_count(world: &mut World) -> usize {
|
||||
let mut query = world.query_filtered::<Entity, With<LevelObject>>();
|
||||
query.iter(world).count()
|
||||
}
|
||||
@@ -0,0 +1,468 @@
|
||||
//! Transient, non-dirty audio audition owned by the editor.
|
||||
|
||||
use bevy::asset::LoadState;
|
||||
use bevy::audio::{
|
||||
AudioPlayer, AudioSink, AudioSinkPlayback, AudioSource, PlaybackMode, PlaybackSettings,
|
||||
SpatialAudioSink, SpatialListener, SpatialScale, Volume,
|
||||
};
|
||||
use bevy::prelude::*;
|
||||
use settings::AUDIO_BUS_SFX_ID;
|
||||
use shared::{asset_server_path, AudioAttenuationDesc, AudioSourceDesc};
|
||||
|
||||
use crate::assets::{EditorAsset, EditorAssetKind};
|
||||
use crate::camera::EditorCamera;
|
||||
use crate::infra::EditorOnly;
|
||||
use crate::state::EditorMode;
|
||||
|
||||
#[derive(Resource, Debug, Clone, Default)]
|
||||
pub struct AudioPreviewState {
|
||||
pub voices: Vec<Entity>,
|
||||
pub source: Option<Entity>,
|
||||
pub clip_path: Option<String>,
|
||||
pub status: String,
|
||||
clip_handle: Option<Handle<AudioSource>>,
|
||||
listener: Option<Entity>,
|
||||
}
|
||||
|
||||
#[derive(Component, Debug, Clone)]
|
||||
struct AudioPreviewVoice {
|
||||
source: Option<Entity>,
|
||||
bus: String,
|
||||
source_gain_db: f32,
|
||||
mix_weight: f32,
|
||||
spatial: bool,
|
||||
attenuation: AudioAttenuationDesc,
|
||||
}
|
||||
|
||||
#[derive(Component, Debug, Clone, Copy)]
|
||||
struct EditorAudioPreviewListener;
|
||||
|
||||
pub struct AudioPreviewPlugin;
|
||||
|
||||
impl Plugin for AudioPreviewPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<AudioPreviewState>()
|
||||
.add_systems(Update, update_audio_preview)
|
||||
.add_systems(OnEnter(EditorMode::Playing), stop_audio_preview);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn audition_audio_source(world: &mut World, source: Entity) -> Result<(), String> {
|
||||
ensure_edit_mode(world)?;
|
||||
let descriptor = world
|
||||
.get::<AudioSourceDesc>(source)
|
||||
.cloned()
|
||||
.ok_or_else(|| "Selected actor has no AudioSourceDesc".to_string())?;
|
||||
let path = descriptor
|
||||
.clip
|
||||
.as_ref()
|
||||
.and_then(|clip| clip.source_path.as_deref())
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
.ok_or_else(|| "Assign an audio clip before auditioning this source".to_string())?
|
||||
.to_string();
|
||||
spawn_preview(world, path, Some((source, descriptor)))
|
||||
}
|
||||
|
||||
pub fn audition_audio_asset(world: &mut World, asset: &EditorAsset) -> Result<(), String> {
|
||||
ensure_edit_mode(world)?;
|
||||
if !matches!(asset.kind, EditorAssetKind::AudioClip) {
|
||||
return Err("Selected asset is not an audio clip".into());
|
||||
}
|
||||
let path = asset
|
||||
.path
|
||||
.as_deref()
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
.ok_or_else(|| "Audio clip has no project path".to_string())?
|
||||
.to_string();
|
||||
spawn_preview(world, path, None)
|
||||
}
|
||||
|
||||
fn ensure_edit_mode(world: &World) -> Result<(), String> {
|
||||
if *world.resource::<State<EditorMode>>().get() != EditorMode::Editing {
|
||||
return Err("Audio audition is available only in Edit mode".into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn spawn_preview(
|
||||
world: &mut World,
|
||||
path: String,
|
||||
source: Option<(Entity, AudioSourceDesc)>,
|
||||
) -> Result<(), String> {
|
||||
stop_audio_preview(world);
|
||||
let descriptor = source
|
||||
.as_ref()
|
||||
.map(|(_, descriptor)| descriptor.clone())
|
||||
.unwrap_or_else(|| AudioSourceDesc {
|
||||
autoplay: false,
|
||||
spatial_blend: 0.0,
|
||||
bus: AUDIO_BUS_SFX_ID.into(),
|
||||
..Default::default()
|
||||
});
|
||||
let source_entity = source.as_ref().map(|(entity, _)| *entity);
|
||||
let mixes = game::audio::audio_voice_mix(descriptor.spatial_blend);
|
||||
let panning_scale = game::audio::spatial_panning_scale(&descriptor.attenuation, 0.2);
|
||||
let needs_listener = mixes.iter().any(|(spatial, _)| *spatial);
|
||||
let listener = if needs_listener {
|
||||
let mut query = world
|
||||
.query_filtered::<(Entity, &GlobalTransform, Has<SpatialListener>), With<EditorCamera>>(
|
||||
);
|
||||
Some(
|
||||
query
|
||||
.iter(world)
|
||||
.next()
|
||||
.map(|(entity, transform, has_listener)| (entity, *transform, has_listener))
|
||||
.ok_or_else(|| "Editor camera is unavailable for spatial audition".to_string())?,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let listener = listener.map(|(camera, camera_transform, has_listener)| {
|
||||
if has_listener {
|
||||
camera
|
||||
} else {
|
||||
world
|
||||
.spawn((
|
||||
Name::new("Editor Audio Preview Listener"),
|
||||
EditorOnly,
|
||||
Transform::IDENTITY,
|
||||
camera_transform,
|
||||
SpatialListener::new(0.2),
|
||||
EditorAudioPreviewListener,
|
||||
ChildOf(camera),
|
||||
))
|
||||
.id()
|
||||
}
|
||||
});
|
||||
|
||||
let asset_server = world.resource::<AssetServer>().clone();
|
||||
let handle: Handle<AudioSource> = asset_server.load(asset_server_path(&path));
|
||||
let mut voices = Vec::with_capacity(mixes.len());
|
||||
for (spatial, mix_weight) in mixes {
|
||||
let mut voice = world.spawn((
|
||||
Name::new(if spatial {
|
||||
"Editor Spatial Audio Preview"
|
||||
} else {
|
||||
"Editor 2D Audio Preview"
|
||||
}),
|
||||
EditorOnly,
|
||||
Transform::IDENTITY,
|
||||
AudioPlayer::new(handle.clone()),
|
||||
PlaybackSettings {
|
||||
mode: PlaybackMode::Once,
|
||||
volume: Volume::Linear(0.0),
|
||||
speed: descriptor.pitch,
|
||||
paused: false,
|
||||
muted: false,
|
||||
spatial,
|
||||
spatial_scale: spatial.then(|| SpatialScale::new(panning_scale)),
|
||||
start_position: None,
|
||||
duration: None,
|
||||
},
|
||||
AudioPreviewVoice {
|
||||
source: source_entity,
|
||||
bus: descriptor.bus.clone(),
|
||||
source_gain_db: descriptor.gain_db,
|
||||
mix_weight,
|
||||
spatial,
|
||||
attenuation: descriptor.attenuation,
|
||||
},
|
||||
));
|
||||
if let Some(source) = source_entity {
|
||||
voice.insert(ChildOf(source));
|
||||
}
|
||||
voices.push(voice.id());
|
||||
}
|
||||
*world.resource_mut::<AudioPreviewState>() = AudioPreviewState {
|
||||
voices,
|
||||
source: source_entity,
|
||||
clip_path: Some(path.clone()),
|
||||
status: format!("Auditioning {}", file_label(&path)),
|
||||
clip_handle: Some(handle),
|
||||
listener,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn file_label(path: &str) -> &str {
|
||||
std::path::Path::new(path)
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.unwrap_or(path)
|
||||
}
|
||||
|
||||
pub fn stop_audio_preview(world: &mut World) {
|
||||
stop_audio_preview_with_status(world, "Audio preview stopped");
|
||||
}
|
||||
|
||||
fn stop_audio_preview_with_status(world: &mut World, status: impl Into<String>) {
|
||||
let voices = std::mem::take(&mut world.resource_mut::<AudioPreviewState>().voices);
|
||||
for voice in voices {
|
||||
if let Some(sink) = world.get::<AudioSink>(voice) {
|
||||
sink.stop();
|
||||
}
|
||||
if let Some(sink) = world.get::<SpatialAudioSink>(voice) {
|
||||
sink.stop();
|
||||
}
|
||||
if let Ok(entity_mut) = world.get_entity_mut(voice) {
|
||||
entity_mut.despawn();
|
||||
}
|
||||
}
|
||||
let mut query = world.query_filtered::<Entity, With<EditorAudioPreviewListener>>();
|
||||
let listeners: Vec<Entity> = query.iter(world).collect();
|
||||
for listener in listeners {
|
||||
if let Ok(entity_mut) = world.get_entity_mut(listener) {
|
||||
entity_mut.despawn();
|
||||
}
|
||||
}
|
||||
let state = world.resource_mut::<AudioPreviewState>().into_inner();
|
||||
state.source = None;
|
||||
state.clip_path = None;
|
||||
state.clip_handle = None;
|
||||
state.listener = None;
|
||||
state.status = status.into();
|
||||
}
|
||||
|
||||
fn update_audio_preview(world: &mut World) {
|
||||
let state = world.resource::<AudioPreviewState>().clone();
|
||||
if state.voices.is_empty() {
|
||||
return;
|
||||
}
|
||||
if *world.resource::<State<EditorMode>>().get() != EditorMode::Editing {
|
||||
stop_audio_preview_with_status(world, "Audio preview stopped on entering Play mode");
|
||||
return;
|
||||
}
|
||||
if state.source.is_some_and(|source| {
|
||||
world.get_entity(source).is_err() || world.get::<AudioSourceDesc>(source).is_none()
|
||||
}) {
|
||||
stop_audio_preview_with_status(world, "Audio preview stopped because its source changed");
|
||||
return;
|
||||
}
|
||||
if state
|
||||
.listener
|
||||
.is_some_and(|listener| world.get::<GlobalTransform>(listener).is_none())
|
||||
{
|
||||
stop_audio_preview_with_status(
|
||||
world,
|
||||
"Audio preview stopped because the editor camera changed",
|
||||
);
|
||||
return;
|
||||
}
|
||||
if let Some(LoadState::Failed(error)) = state
|
||||
.clip_handle
|
||||
.as_ref()
|
||||
.map(|handle| world.resource::<AssetServer>().load_state(handle.id()))
|
||||
{
|
||||
let status = format!("Audio preview failed: {error}");
|
||||
stop_audio_preview_with_status(world, status.clone());
|
||||
if let Some(mut scene_io) = world.get_resource_mut::<crate::scene_io::SceneIo>() {
|
||||
scene_io.set_status(status);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
let listener_position = state
|
||||
.listener
|
||||
.and_then(|listener| world.get::<GlobalTransform>(listener))
|
||||
.map(GlobalTransform::translation);
|
||||
let project_audio = world.resource::<settings::ProjectSettings>().audio.clone();
|
||||
let bus_runtime = world.resource::<game::audio::AudioBusRuntime>().clone();
|
||||
let mut finished = 0usize;
|
||||
for voice_entity in &state.voices {
|
||||
let Some(voice) = world.get::<AudioPreviewVoice>(*voice_entity).cloned() else {
|
||||
finished += 1;
|
||||
continue;
|
||||
};
|
||||
let source_position = voice
|
||||
.source
|
||||
.and_then(|source| world.get::<GlobalTransform>(source))
|
||||
.map(GlobalTransform::translation);
|
||||
let attenuation = if voice.spatial {
|
||||
match (listener_position, source_position) {
|
||||
(Some(listener), Some(source)) => {
|
||||
game::audio::attenuation_gain(&voice.attenuation, listener.distance(source))
|
||||
}
|
||||
_ => 0.0,
|
||||
}
|
||||
} else {
|
||||
1.0
|
||||
};
|
||||
let gain = game::audio::db_to_linear(voice.source_gain_db)
|
||||
* game::audio::effective_bus_gain_linear(&project_audio, &bus_runtime, &voice.bus)
|
||||
* voice.mix_weight
|
||||
* attenuation;
|
||||
if let Some(mut sink) = world.get_mut::<AudioSink>(*voice_entity) {
|
||||
sink.set_volume(Volume::Linear(gain));
|
||||
if sink.empty() {
|
||||
finished += 1;
|
||||
}
|
||||
} else if let Some(mut sink) = world.get_mut::<SpatialAudioSink>(*voice_entity) {
|
||||
sink.set_volume(Volume::Linear(gain));
|
||||
if sink.empty() {
|
||||
finished += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if finished == state.voices.len() {
|
||||
stop_audio_preview_with_status(world, "Audio preview finished");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use bevy::asset::{AssetApp, AssetPlugin};
|
||||
use bevy::state::app::StatesPlugin;
|
||||
use shared::{EditorAssetRef, AUDIO_CLIP_SUB_ASSET_ID};
|
||||
|
||||
#[test]
|
||||
fn file_label_is_stable_for_project_paths() {
|
||||
assert_eq!(file_label("assets/audio/impact.ogg"), "impact.ogg");
|
||||
assert_eq!(file_label("clip.wav"), "clip.wav");
|
||||
}
|
||||
|
||||
fn preview_app() -> App {
|
||||
let mut app = App::new();
|
||||
app.add_plugins((MinimalPlugins, AssetPlugin::default(), StatesPlugin))
|
||||
.init_asset::<AudioSource>()
|
||||
.init_state::<EditorMode>()
|
||||
.add_plugins(AudioPreviewPlugin)
|
||||
.init_resource::<crate::scene_io::SceneIo>()
|
||||
.init_resource::<crate::history::EditorHistory>()
|
||||
.init_resource::<game::audio::AudioBusRuntime>()
|
||||
.insert_resource(settings::ProjectSettings::default());
|
||||
app
|
||||
}
|
||||
|
||||
fn spawn_camera(app: &mut App, listener: Option<SpatialListener>) -> Entity {
|
||||
let mut camera = app.world_mut().spawn((
|
||||
EditorCamera::default(),
|
||||
Transform::IDENTITY,
|
||||
GlobalTransform::IDENTITY,
|
||||
));
|
||||
if let Some(listener) = listener {
|
||||
camera.insert(listener);
|
||||
}
|
||||
camera.id()
|
||||
}
|
||||
|
||||
fn spawn_source(app: &mut App) -> Entity {
|
||||
app.world_mut()
|
||||
.spawn((
|
||||
Transform::from_xyz(0.0, 0.0, -2.0),
|
||||
GlobalTransform::IDENTITY,
|
||||
AudioSourceDesc {
|
||||
clip: Some(
|
||||
EditorAssetRef::new("audio-id", AUDIO_CLIP_SUB_ASSET_ID, "Impact")
|
||||
.with_source_path("assets/audio/impact.ogg"),
|
||||
),
|
||||
..Default::default()
|
||||
},
|
||||
))
|
||||
.id()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn audition_and_stop_do_not_dirty_scene_or_push_history() {
|
||||
let mut app = preview_app();
|
||||
spawn_camera(&mut app, None);
|
||||
let source = spawn_source(&mut app);
|
||||
|
||||
audition_audio_source(app.world_mut(), source).unwrap();
|
||||
|
||||
assert!(!app
|
||||
.world()
|
||||
.resource::<AudioPreviewState>()
|
||||
.voices
|
||||
.is_empty());
|
||||
assert!(!app.world().resource::<crate::scene_io::SceneIo>().dirty);
|
||||
assert_eq!(
|
||||
app.world()
|
||||
.resource::<crate::history::EditorHistory>()
|
||||
.undo_depth(),
|
||||
0
|
||||
);
|
||||
|
||||
stop_audio_preview(app.world_mut());
|
||||
|
||||
assert!(app
|
||||
.world()
|
||||
.resource::<AudioPreviewState>()
|
||||
.voices
|
||||
.is_empty());
|
||||
assert!(!app.world().resource::<crate::scene_io::SceneIo>().dirty);
|
||||
assert_eq!(
|
||||
app.world()
|
||||
.resource::<crate::history::EditorHistory>()
|
||||
.undo_depth(),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn spatial_preview_preserves_an_existing_editor_camera_listener() {
|
||||
let mut app = preview_app();
|
||||
let camera = spawn_camera(&mut app, Some(SpatialListener::new(0.5)));
|
||||
let source = spawn_source(&mut app);
|
||||
let expected = app.world().get::<SpatialListener>(camera).unwrap().clone();
|
||||
|
||||
audition_audio_source(app.world_mut(), source).unwrap();
|
||||
|
||||
let actual = app.world().get::<SpatialListener>(camera).unwrap();
|
||||
assert_eq!(actual.left_ear_offset, expected.left_ear_offset);
|
||||
assert_eq!(actual.right_ear_offset, expected.right_ear_offset);
|
||||
assert_eq!(
|
||||
app.world().resource::<AudioPreviewState>().listener,
|
||||
Some(camera)
|
||||
);
|
||||
let mut preview_listeners = app
|
||||
.world_mut()
|
||||
.query_filtered::<Entity, With<EditorAudioPreviewListener>>();
|
||||
assert_eq!(preview_listeners.iter(app.world()).count(), 0);
|
||||
|
||||
stop_audio_preview(app.world_mut());
|
||||
|
||||
let actual = app.world().get::<SpatialListener>(camera).unwrap();
|
||||
assert_eq!(actual.left_ear_offset, expected.left_ear_offset);
|
||||
assert_eq!(actual.right_ear_offset, expected.right_ear_offset);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn source_component_removal_cleans_up_preview() {
|
||||
let mut app = preview_app();
|
||||
spawn_camera(&mut app, None);
|
||||
let source = spawn_source(&mut app);
|
||||
audition_audio_source(app.world_mut(), source).unwrap();
|
||||
|
||||
app.world_mut()
|
||||
.entity_mut(source)
|
||||
.remove::<AudioSourceDesc>();
|
||||
update_audio_preview(app.world_mut());
|
||||
|
||||
let state = app.world().resource::<AudioPreviewState>();
|
||||
assert!(state.voices.is_empty());
|
||||
assert!(state.source.is_none());
|
||||
assert!(state.status.contains("source changed"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn entering_play_mode_cleans_up_preview() {
|
||||
let mut app = preview_app();
|
||||
spawn_camera(&mut app, None);
|
||||
let source = spawn_source(&mut app);
|
||||
audition_audio_source(app.world_mut(), source).unwrap();
|
||||
|
||||
app.world_mut()
|
||||
.resource_mut::<NextState<EditorMode>>()
|
||||
.set(EditorMode::Playing);
|
||||
app.update();
|
||||
|
||||
let state = app.world().resource::<AudioPreviewState>();
|
||||
assert!(state.voices.is_empty());
|
||||
assert!(state.source.is_none());
|
||||
let mut preview_listeners = app
|
||||
.world_mut()
|
||||
.query_filtered::<Entity, With<EditorAudioPreviewListener>>();
|
||||
assert_eq!(preview_listeners.iter(app.world()).count(), 0);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Play-in-editor session, editor mode state, and net editor profiles.
|
||||
|
||||
pub mod audio_preview;
|
||||
pub mod net_editor;
|
||||
mod session;
|
||||
pub mod state;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -7,7 +7,6 @@ use protocol::PlayerInputIntent;
|
||||
use sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
|
||||
|
||||
use crate::camera::EditorCamera;
|
||||
use crate::scene_io::SceneIo;
|
||||
|
||||
/// Editor/game mode. `Playing` runs the real game sim; use [`PlayPossession`] for camera control.
|
||||
#[derive(States, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
||||
@@ -252,6 +251,8 @@ fn sync_play_input_focus(
|
||||
}
|
||||
|
||||
fn enter_play_mode(world: &mut World) {
|
||||
// Edit-mode scrubbing must not override authored controller playback in PIE.
|
||||
game::animation::stop_animation_preview(world);
|
||||
let snapshot = snapshot_player_sim(world);
|
||||
world.resource_mut::<PlayModeSnapshot>().player = Some(snapshot);
|
||||
}
|
||||
@@ -260,9 +261,9 @@ fn exit_play_mode(world: &mut World) {
|
||||
if let Some(snapshot) = world.resource_mut::<PlayModeSnapshot>().player.take() {
|
||||
restore_player_sim(world, &snapshot);
|
||||
}
|
||||
if let Some(mut scene_io) = world.get_resource_mut::<SceneIo>() {
|
||||
scene_io.dirty = true;
|
||||
}
|
||||
world.resource_mut::<SimEnabled>().0 = false;
|
||||
game::animation::reset_authored_animation_runtime(world);
|
||||
game::audio::reset_authored_audio_runtime(world);
|
||||
}
|
||||
|
||||
fn snapshot_player_sim(world: &mut World) -> PlayerSimSnapshot {
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,278 @@
|
||||
//! Privacy-bounded support bundle export for editor troubleshooting.
|
||||
|
||||
use std::path::PathBuf;
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy::render::renderer::RenderAdapterInfo;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use shared::{brush_math::validate_brush, BrushDesc, LevelObject};
|
||||
|
||||
use crate::project_io::ProjectWorkspace;
|
||||
use crate::scene::recovery::{atomic_write, default_state_root};
|
||||
use crate::scene_io::{SceneIo, SceneIoEventSeverity};
|
||||
use crate::session::EditorSessionRuntime;
|
||||
|
||||
const DIAGNOSTICS_SCHEMA_VERSION: u32 = 1;
|
||||
const DIAGNOSTICS_DIR: &str = "diagnostics";
|
||||
const MAX_EVENT_MESSAGE_CHARS: usize = 512;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticBuildInfo {
|
||||
pub editor_version: String,
|
||||
pub bevy_version: String,
|
||||
pub target_os: String,
|
||||
pub target_arch: String,
|
||||
pub build_profile: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticRendererInfo {
|
||||
pub adapter_name: String,
|
||||
pub device_type: String,
|
||||
pub backend: String,
|
||||
pub driver: String,
|
||||
pub driver_info: String,
|
||||
pub vendor_id: u32,
|
||||
pub device_id: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticProjectInfo {
|
||||
pub project_root: String,
|
||||
pub settings_path: String,
|
||||
pub active_scene: Option<String>,
|
||||
pub scene_dirty: bool,
|
||||
pub project_settings_dirty: bool,
|
||||
pub layout_dirty: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticValidationSummary {
|
||||
pub level_object_count: usize,
|
||||
pub brush_actor_count: usize,
|
||||
pub invalid_brush_count: usize,
|
||||
pub brush_error_count: usize,
|
||||
pub brush_warning_count: usize,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticSceneIoEvent {
|
||||
pub id: u64,
|
||||
pub severity: String,
|
||||
pub message: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct DiagnosticBundleDocument {
|
||||
pub schema_version: u32,
|
||||
pub created_unix_seconds: u64,
|
||||
pub build: DiagnosticBuildInfo,
|
||||
pub renderer: Option<DiagnosticRendererInfo>,
|
||||
pub project: DiagnosticProjectInfo,
|
||||
pub validation: DiagnosticValidationSummary,
|
||||
pub prior_abnormal_shutdown: bool,
|
||||
pub scene_io_events: Vec<DiagnosticSceneIoEvent>,
|
||||
}
|
||||
|
||||
/// Writes an allowlisted support report without scene data, environment values, or credentials.
|
||||
pub fn export_diagnostic_bundle(world: &mut World) -> Result<PathBuf, String> {
|
||||
let document = capture_diagnostic_bundle(world);
|
||||
let directory = default_state_root()
|
||||
.ok_or_else(|| "XDG_STATE_HOME and HOME are both unavailable".to_string())?
|
||||
.join(DIAGNOSTICS_DIR);
|
||||
let timestamp = document.created_unix_seconds;
|
||||
let path = directory.join(format!(
|
||||
"blacksite-diagnostics-{timestamp:020}-{}.ron",
|
||||
std::process::id()
|
||||
));
|
||||
let text = serialize_diagnostic_bundle(&document)?;
|
||||
atomic_write(&path, text.as_bytes())?;
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
fn capture_diagnostic_bundle(world: &mut World) -> DiagnosticBundleDocument {
|
||||
let validation = validation_summary(world);
|
||||
let renderer =
|
||||
world
|
||||
.get_resource::<RenderAdapterInfo>()
|
||||
.map(|adapter| DiagnosticRendererInfo {
|
||||
adapter_name: adapter.name.clone(),
|
||||
device_type: format!("{:?}", adapter.device_type),
|
||||
backend: format!("{:?}", adapter.backend),
|
||||
driver: adapter.driver.clone(),
|
||||
driver_info: adapter.driver_info.clone(),
|
||||
vendor_id: adapter.vendor,
|
||||
device_id: adapter.device,
|
||||
});
|
||||
let scene_io = world.resource::<SceneIo>();
|
||||
let workspace = world.resource::<ProjectWorkspace>();
|
||||
let project = DiagnosticProjectInfo {
|
||||
project_root: workspace.root.clone(),
|
||||
settings_path: workspace.settings_path.clone(),
|
||||
active_scene: scene_io
|
||||
.active_path
|
||||
.as_ref()
|
||||
.map(|path| path.display().to_string()),
|
||||
scene_dirty: scene_io.has_unsaved_tabs(),
|
||||
project_settings_dirty: workspace.settings_dirty,
|
||||
layout_dirty: workspace.layout_dirty,
|
||||
};
|
||||
let scene_io_events = scene_io
|
||||
.events
|
||||
.iter()
|
||||
.map(|event| DiagnosticSceneIoEvent {
|
||||
id: event.id,
|
||||
severity: match event.severity {
|
||||
SceneIoEventSeverity::Info => "info",
|
||||
SceneIoEventSeverity::Error => "error",
|
||||
}
|
||||
.to_string(),
|
||||
message: bounded_message(&event.message),
|
||||
})
|
||||
.collect();
|
||||
|
||||
DiagnosticBundleDocument {
|
||||
schema_version: DIAGNOSTICS_SCHEMA_VERSION,
|
||||
created_unix_seconds: SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_secs(),
|
||||
build: build_info(),
|
||||
renderer,
|
||||
project,
|
||||
validation,
|
||||
prior_abnormal_shutdown: world
|
||||
.get_resource::<EditorSessionRuntime>()
|
||||
.is_some_and(|runtime| runtime.prior_abnormal_shutdown),
|
||||
scene_io_events,
|
||||
}
|
||||
}
|
||||
|
||||
fn validation_summary(world: &mut World) -> DiagnosticValidationSummary {
|
||||
let mut level_query = world.query_filtered::<Entity, With<LevelObject>>();
|
||||
let level_object_count = level_query.iter(world).count();
|
||||
let mut brush_query = world.query_filtered::<&BrushDesc, With<LevelObject>>();
|
||||
let mut summary = DiagnosticValidationSummary {
|
||||
level_object_count,
|
||||
brush_actor_count: 0,
|
||||
invalid_brush_count: 0,
|
||||
brush_error_count: 0,
|
||||
brush_warning_count: 0,
|
||||
};
|
||||
for brush in brush_query.iter(world) {
|
||||
summary.brush_actor_count += 1;
|
||||
let report = validate_brush(brush);
|
||||
let errors = report
|
||||
.diagnostics
|
||||
.iter()
|
||||
.filter(|diagnostic| {
|
||||
diagnostic.severity == shared::brush_math::BrushDiagnosticSeverity::Error
|
||||
})
|
||||
.count();
|
||||
let warnings = report.diagnostics.len().saturating_sub(errors);
|
||||
summary.brush_error_count += errors;
|
||||
summary.brush_warning_count += warnings;
|
||||
summary.invalid_brush_count += usize::from(errors > 0);
|
||||
}
|
||||
summary
|
||||
}
|
||||
|
||||
fn build_info() -> DiagnosticBuildInfo {
|
||||
DiagnosticBuildInfo {
|
||||
editor_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
bevy_version: "0.19".to_string(),
|
||||
target_os: std::env::consts::OS.to_string(),
|
||||
target_arch: std::env::consts::ARCH.to_string(),
|
||||
build_profile: if cfg!(debug_assertions) {
|
||||
"debug"
|
||||
} else {
|
||||
"release"
|
||||
}
|
||||
.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
fn bounded_message(message: &str) -> String {
|
||||
message
|
||||
.chars()
|
||||
.filter(|character| !character.is_control() || *character == ' ')
|
||||
.take(MAX_EVENT_MESSAGE_CHARS)
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn serialize_diagnostic_bundle(document: &DiagnosticBundleDocument) -> Result<String, String> {
|
||||
ron::ser::to_string_pretty(document, ron::ser::PrettyConfig::default())
|
||||
.map_err(|error| format!("could not serialize diagnostics: {error}"))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn fixture() -> DiagnosticBundleDocument {
|
||||
DiagnosticBundleDocument {
|
||||
schema_version: DIAGNOSTICS_SCHEMA_VERSION,
|
||||
created_unix_seconds: 42,
|
||||
build: build_info(),
|
||||
renderer: None,
|
||||
project: DiagnosticProjectInfo {
|
||||
project_root: "/project".to_string(),
|
||||
settings_path: "assets/project.ron".to_string(),
|
||||
active_scene: Some("assets/levels/test.scn.ron".to_string()),
|
||||
scene_dirty: true,
|
||||
project_settings_dirty: false,
|
||||
layout_dirty: false,
|
||||
},
|
||||
validation: DiagnosticValidationSummary {
|
||||
level_object_count: 12,
|
||||
brush_actor_count: 2,
|
||||
invalid_brush_count: 1,
|
||||
brush_error_count: 1,
|
||||
brush_warning_count: 0,
|
||||
},
|
||||
prior_abnormal_shutdown: true,
|
||||
scene_io_events: vec![DiagnosticSceneIoEvent {
|
||||
id: 1,
|
||||
severity: "error".to_string(),
|
||||
message: "Save failed: disk full".to_string(),
|
||||
}],
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialized_bundle_contains_only_allowlisted_sections() {
|
||||
let text = serialize_diagnostic_bundle(&fixture()).unwrap();
|
||||
|
||||
for allowed in [
|
||||
"build",
|
||||
"renderer",
|
||||
"project",
|
||||
"validation",
|
||||
"scene_io_events",
|
||||
] {
|
||||
assert!(text.contains(allowed));
|
||||
}
|
||||
for forbidden in [
|
||||
"scene_contents",
|
||||
"asset_contents",
|
||||
"environment",
|
||||
"credential",
|
||||
"access_token",
|
||||
"hostname",
|
||||
"username",
|
||||
"modal_operator",
|
||||
] {
|
||||
assert!(!text.to_ascii_lowercase().contains(forbidden));
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn event_messages_are_control_free_and_bounded() {
|
||||
let message = format!("failure\n{}", "x".repeat(MAX_EVENT_MESSAGE_CHARS + 20));
|
||||
let bounded = bounded_message(&message);
|
||||
|
||||
assert!(bounded.chars().count() <= MAX_EVENT_MESSAGE_CHARS);
|
||||
assert!(!bounded.contains('\n'));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,879 @@
|
||||
//! Pre-engine project validation, recent-project discovery, and sandbox scaffolding.
|
||||
|
||||
use std::collections::HashSet;
|
||||
use std::path::{Component, Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use bevy::app::AppExit;
|
||||
use bevy::prelude::*;
|
||||
use bevy::window::{CompositeAlphaMode, PresentMode, WindowPlugin};
|
||||
use bevy_egui::{egui, EguiContext, EguiPlugin, EguiPrimaryContextPass, PrimaryEguiContext};
|
||||
use settings::{
|
||||
save_project_settings_to_string, ProjectKind, ProjectSettings, DEFAULT_PROJECT_PATH,
|
||||
PROJECT_TEMPLATE_VERSION,
|
||||
};
|
||||
|
||||
use crate::native_dialog::{NativeDialogBroker, NativeDialogPlugin};
|
||||
use crate::project_io::UserPreferences;
|
||||
use crate::scene::recovery::atomic_write;
|
||||
use crate::ui::theme::{
|
||||
apply_editor_theme, ACCENT, BORDER, CANVAS_BG, PANEL_BG, PANEL_BG_DARK, SELECTION, TEXT,
|
||||
TEXT_DIM, TEXT_MUTED,
|
||||
};
|
||||
|
||||
const SANDBOX_DIRECTORIES: &[&str] = &[
|
||||
"assets/.index",
|
||||
"assets/.trash",
|
||||
"assets/audio",
|
||||
"assets/build_profiles",
|
||||
"assets/levels",
|
||||
"assets/materials",
|
||||
"assets/meshes/generated",
|
||||
"assets/models",
|
||||
"assets/post_fx",
|
||||
"assets/rendering_profiles",
|
||||
"assets/shaders",
|
||||
"assets/textures",
|
||||
];
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ProjectSummary {
|
||||
pub root: PathBuf,
|
||||
pub project_id: String,
|
||||
pub name: String,
|
||||
pub project_kind: ProjectKind,
|
||||
pub template_version: u32,
|
||||
pub capabilities: Vec<String>,
|
||||
pub default_level: PathBuf,
|
||||
pub last_scene: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default)]
|
||||
pub struct StartupArguments {
|
||||
pub project: Option<PathBuf>,
|
||||
pub help: bool,
|
||||
}
|
||||
|
||||
#[derive(Resource)]
|
||||
struct ProjectLauncherUi {
|
||||
recents: Vec<ProjectSummary>,
|
||||
sandbox_name: String,
|
||||
sandbox_destination: Option<PathBuf>,
|
||||
status: Option<String>,
|
||||
}
|
||||
|
||||
impl Default for ProjectLauncherUi {
|
||||
fn default() -> Self {
|
||||
let mut preferences = crate::project_io::read_user_preferences();
|
||||
if let Ok(root) = std::env::current_dir().and_then(|root| root.canonicalize()) {
|
||||
crate::project_io::remember_project_root(&mut preferences, &root);
|
||||
}
|
||||
Self {
|
||||
recents: recent_project_summaries(&preferences),
|
||||
sandbox_name: "New Sandbox".to_string(),
|
||||
sandbox_destination: None,
|
||||
status: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_project_launcher() {
|
||||
let mut app = App::new();
|
||||
app.add_plugins(DefaultPlugins.set(WindowPlugin {
|
||||
primary_window: Some(Window {
|
||||
title: "Blacksite Project Browser".to_string(),
|
||||
name: Some("blacksite-project-launcher".to_string()),
|
||||
resolution: (960, 620).into(),
|
||||
present_mode: PresentMode::AutoVsync,
|
||||
transparent: false,
|
||||
composite_alpha_mode: CompositeAlphaMode::Opaque,
|
||||
..default()
|
||||
}),
|
||||
..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);
|
||||
app.run();
|
||||
}
|
||||
|
||||
fn spawn_project_launcher_camera(mut commands: Commands) {
|
||||
commands.spawn((Camera2d, PrimaryEguiContext));
|
||||
}
|
||||
|
||||
pub fn spawn_project_launcher_process() -> Result<(), String> {
|
||||
let executable = sibling_executable("project_launcher")?;
|
||||
let root = std::env::current_dir()
|
||||
.map_err(|error| format!("could not resolve active project root: {error}"))?;
|
||||
spawn_detached(&executable, &[], &root)
|
||||
}
|
||||
|
||||
pub fn reveal_project_root(root: &Path) -> Result<(), String> {
|
||||
Command::new("xdg-open")
|
||||
.arg(root)
|
||||
.spawn()
|
||||
.map_err(|error| format!("could not reveal {}: {error}", root.display()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn project_launcher_ui_system(world: &mut World) {
|
||||
let Ok(context) = world
|
||||
.query_filtered::<&mut EguiContext, With<PrimaryEguiContext>>()
|
||||
.single(world)
|
||||
else {
|
||||
return;
|
||||
};
|
||||
let mut context = context.clone();
|
||||
world.resource_scope(|world, mut state: Mut<ProjectLauncherUi>| {
|
||||
project_launcher_ui(world, context.get_mut(), &mut state);
|
||||
});
|
||||
}
|
||||
|
||||
#[expect(
|
||||
deprecated,
|
||||
reason = "bevy_egui exposes a Context during EguiPrimaryContextPass, requiring one top-level context-based panel"
|
||||
)]
|
||||
fn project_launcher_ui(world: &mut World, context: &egui::Context, state: &mut ProjectLauncherUi) {
|
||||
apply_editor_theme(context);
|
||||
egui::CentralPanel::default()
|
||||
.frame(
|
||||
egui::Frame::new()
|
||||
.fill(CANVAS_BG)
|
||||
.inner_margin(egui::Margin::same(24)),
|
||||
)
|
||||
.show(context, |ui| {
|
||||
let content_width = ui.available_width().min(1240.0);
|
||||
let side_space = ((ui.available_width() - content_width) * 0.5).max(0.0);
|
||||
ui.horizontal(|ui| {
|
||||
ui.add_space(side_space);
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(content_width);
|
||||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.label(
|
||||
egui::RichText::new("BLACKSITE")
|
||||
.size(22.0)
|
||||
.strong()
|
||||
.color(ACCENT),
|
||||
);
|
||||
ui.label(
|
||||
egui::RichText::new("PROJECT BROWSER")
|
||||
.size(11.0)
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
});
|
||||
ui.add_space(18.0);
|
||||
ui.separator();
|
||||
ui.add_space(10.0);
|
||||
ui.label(
|
||||
egui::RichText::new(
|
||||
"Choose a validated workspace before the engine starts",
|
||||
)
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
});
|
||||
ui.add_space(22.0);
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(340.0);
|
||||
launcher_actions(world, ui, state);
|
||||
});
|
||||
ui.add_space(18.0);
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width((content_width - 358.0).max(360.0));
|
||||
recent_projects(world, ui, state);
|
||||
});
|
||||
});
|
||||
|
||||
if let Some(status) = state.status.as_deref() {
|
||||
ui.add_space(12.0);
|
||||
ui.separator();
|
||||
ui.label(egui::RichText::new(status).color(TEXT_DIM));
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn launcher_actions(world: &mut World, ui: &mut egui::Ui, state: &mut ProjectLauncherUi) {
|
||||
egui::Frame::new()
|
||||
.fill(PANEL_BG_DARK)
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.inner_margin(egui::Margin::same(16))
|
||||
.show(ui, |ui| {
|
||||
ui.set_min_height(455.0);
|
||||
ui.heading("Open Project");
|
||||
ui.label(
|
||||
egui::RichText::new("Select a root containing assets/project.ron").color(TEXT_DIM),
|
||||
);
|
||||
ui.add_space(8.0);
|
||||
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}"));
|
||||
}
|
||||
}
|
||||
|
||||
ui.add_space(24.0);
|
||||
ui.separator();
|
||||
ui.add_space(14.0);
|
||||
ui.heading("New Sandbox");
|
||||
ui.label(
|
||||
egui::RichText::new("Creates a clean content workspace with a valid empty level")
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
ui.add_space(8.0);
|
||||
ui.label(egui::RichText::new("Project name").color(TEXT_DIM));
|
||||
ui.text_edit_singleline(&mut state.sandbox_name);
|
||||
ui.add_space(6.0);
|
||||
let destination = state
|
||||
.sandbox_destination
|
||||
.as_ref()
|
||||
.map(|path| path.display().to_string())
|
||||
.unwrap_or_else(|| "No destination selected".to_string());
|
||||
ui.add(
|
||||
egui::Label::new(
|
||||
egui::RichText::new(destination)
|
||||
.monospace()
|
||||
.color(TEXT_MUTED),
|
||||
)
|
||||
.truncate(),
|
||||
);
|
||||
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();
|
||||
if ui
|
||||
.add_enabled(can_create, egui::Button::new("Create And Open Sandbox"))
|
||||
.clicked()
|
||||
{
|
||||
let destination = state.sandbox_destination.clone().unwrap();
|
||||
match scaffold_sandbox_project(&destination, &state.sandbox_name) {
|
||||
Ok(summary) => launch_editor_and_close(world, state, &summary),
|
||||
Err(error) => state.status = Some(error),
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn recent_projects(world: &mut World, ui: &mut egui::Ui, state: &mut ProjectLauncherUi) {
|
||||
ui.horizontal(|ui| {
|
||||
ui.heading("Recent Projects");
|
||||
ui.add_space(8.0);
|
||||
ui.label(egui::RichText::new(state.recents.len().to_string()).color(TEXT_MUTED));
|
||||
});
|
||||
ui.label(
|
||||
egui::RichText::new("Missing and invalid projects are filtered automatically")
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
ui.add_space(10.0);
|
||||
if state.recents.is_empty() {
|
||||
egui::Frame::new()
|
||||
.fill(PANEL_BG)
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.inner_margin(egui::Margin::same(16))
|
||||
.show(ui, |ui| {
|
||||
ui.label(egui::RichText::new("No valid recent projects").color(TEXT));
|
||||
ui.label(
|
||||
egui::RichText::new("Browse an existing project or create a sandbox.")
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let recents = state.recents.clone();
|
||||
egui::ScrollArea::vertical()
|
||||
.id_salt("project_launcher_recents")
|
||||
.show(ui, |ui| {
|
||||
for summary in recents {
|
||||
let response = egui::Frame::new()
|
||||
.fill(PANEL_BG)
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.inner_margin(egui::Margin::same(14))
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.vertical(|ui| {
|
||||
ui.label(egui::RichText::new(&summary.name).strong().color(TEXT));
|
||||
ui.label(
|
||||
egui::RichText::new(summary.root.display().to_string())
|
||||
.monospace()
|
||||
.size(11.0)
|
||||
.color(TEXT_MUTED),
|
||||
);
|
||||
let detail = summary.last_scene.as_ref().map_or_else(
|
||||
|| format!("{:?} | default scene", summary.project_kind),
|
||||
|scene| {
|
||||
format!(
|
||||
"{:?} | {}",
|
||||
summary.project_kind,
|
||||
scene
|
||||
.strip_prefix(&summary.root)
|
||||
.unwrap_or(scene)
|
||||
.display()
|
||||
)
|
||||
},
|
||||
);
|
||||
ui.label(egui::RichText::new(detail).size(11.0).color(TEXT_DIM));
|
||||
});
|
||||
ui.with_layout(
|
||||
egui::Layout::right_to_left(egui::Align::Center),
|
||||
|ui| {
|
||||
if ui.button("Open").clicked() {
|
||||
launch_editor_and_close(world, state, &summary);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
if response.response.hovered() {
|
||||
ui.painter().rect_stroke(
|
||||
response.response.rect,
|
||||
0.0,
|
||||
egui::Stroke::new(1.0, SELECTION),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
}
|
||||
ui.add_space(8.0);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn open_project_from_launcher(world: &mut World, state: &mut ProjectLauncherUi, root: PathBuf) {
|
||||
match inspect_project(&root, None) {
|
||||
Ok(summary) => launch_editor_and_close(world, state, &summary),
|
||||
Err(error) => state.status = Some(error),
|
||||
}
|
||||
}
|
||||
|
||||
fn launch_editor_and_close(
|
||||
world: &mut World,
|
||||
state: &mut ProjectLauncherUi,
|
||||
summary: &ProjectSummary,
|
||||
) {
|
||||
match spawn_editor_process(&summary.root) {
|
||||
Ok(()) => {
|
||||
state.status = Some(format!("Opening {}", summary.name));
|
||||
world.write_message(AppExit::Success);
|
||||
}
|
||||
Err(error) => state.status = Some(error),
|
||||
}
|
||||
}
|
||||
|
||||
fn spawn_editor_process(root: &Path) -> Result<(), String> {
|
||||
let executable = sibling_executable("editor")?;
|
||||
spawn_detached(
|
||||
&executable,
|
||||
&[std::ffi::OsStr::new("--project"), root.as_os_str()],
|
||||
root,
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
fn spawn_detached(
|
||||
executable: &Path,
|
||||
arguments: &[&std::ffi::OsStr],
|
||||
cwd: &Path,
|
||||
) -> Result<(), String> {
|
||||
let mut command = Command::new("systemd-run");
|
||||
command
|
||||
.args(["--user", "--collect", "--quiet", "--service-type=exec"])
|
||||
.arg(format!("--working-directory={}", cwd.display()));
|
||||
for variable in [
|
||||
"PATH",
|
||||
"WAYLAND_DISPLAY",
|
||||
"DISPLAY",
|
||||
"XAUTHORITY",
|
||||
"XDG_RUNTIME_DIR",
|
||||
"HYPRLAND_INSTANCE_SIGNATURE",
|
||||
"DBUS_SESSION_BUS_ADDRESS",
|
||||
"XDG_CURRENT_DESKTOP",
|
||||
"XDG_SESSION_DESKTOP",
|
||||
"XDG_SESSION_TYPE",
|
||||
"XDG_DATA_HOME",
|
||||
"XDG_CONFIG_HOME",
|
||||
"XDG_STATE_HOME",
|
||||
"GDK_BACKEND",
|
||||
"LD_LIBRARY_PATH",
|
||||
"WGPU_VALIDATION",
|
||||
"BEVY_FPS_HDR",
|
||||
] {
|
||||
if let Some(value) = std::env::var_os(variable) {
|
||||
command.arg(format!("--setenv={variable}={}", value.to_string_lossy()));
|
||||
}
|
||||
}
|
||||
let status = command
|
||||
.arg(executable)
|
||||
.args(arguments)
|
||||
.status()
|
||||
.map_err(|error| format!("could not invoke systemd-run: {error}"))?;
|
||||
status.success().then_some(()).ok_or_else(|| {
|
||||
format!(
|
||||
"systemd-run could not start {} (status {status})",
|
||||
executable.display()
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
fn spawn_detached(
|
||||
executable: &Path,
|
||||
arguments: &[&std::ffi::OsStr],
|
||||
cwd: &Path,
|
||||
) -> Result<(), String> {
|
||||
Command::new(executable)
|
||||
.args(arguments)
|
||||
.current_dir(cwd)
|
||||
.spawn()
|
||||
.map_err(|error| format!("could not start {}: {error}", executable.display()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sibling_executable(name: &str) -> Result<PathBuf, String> {
|
||||
let current = std::env::current_exe()
|
||||
.map_err(|error| format!("could not locate current executable: {error}"))?;
|
||||
let extension = current
|
||||
.extension()
|
||||
.map(|extension| extension.to_os_string());
|
||||
let mut executable = current.with_file_name(name);
|
||||
if let Some(extension) = extension {
|
||||
executable.set_extension(extension);
|
||||
}
|
||||
executable
|
||||
.is_file()
|
||||
.then_some(executable.clone())
|
||||
.ok_or_else(|| format!("required executable is not built: {}", executable.display()))
|
||||
}
|
||||
|
||||
pub fn parse_startup_arguments(
|
||||
arguments: impl IntoIterator<Item = String>,
|
||||
) -> Result<StartupArguments, String> {
|
||||
let mut parsed = StartupArguments::default();
|
||||
let mut arguments = arguments.into_iter();
|
||||
while let Some(argument) = arguments.next() {
|
||||
match argument.as_str() {
|
||||
"--project" => {
|
||||
if parsed.project.is_some() {
|
||||
return Err("--project may only be provided once".to_string());
|
||||
}
|
||||
let path = arguments
|
||||
.next()
|
||||
.ok_or_else(|| "--project requires a project root path".to_string())?;
|
||||
parsed.project = Some(PathBuf::from(path));
|
||||
}
|
||||
"--help" | "-h" => parsed.help = true,
|
||||
unknown => return Err(format!("unknown editor argument `{unknown}`")),
|
||||
}
|
||||
}
|
||||
Ok(parsed)
|
||||
}
|
||||
|
||||
pub fn command_line_help() -> &'static str {
|
||||
"Blacksite Editor\n\nUSAGE:\n editor [--project <root>]\n\nOPTIONS:\n --project <root> Open a validated Blacksite project before engine startup\n -h, --help Print this help"
|
||||
}
|
||||
|
||||
pub fn activate_project_root(root: &Path) -> Result<ProjectSummary, String> {
|
||||
let summary = inspect_project(root, None)?;
|
||||
std::env::set_current_dir(&summary.root).map_err(|error| {
|
||||
format!(
|
||||
"could not activate project root {}: {error}",
|
||||
summary.root.display()
|
||||
)
|
||||
})?;
|
||||
Ok(summary)
|
||||
}
|
||||
|
||||
pub fn inspect_project(root: &Path, last_scene: Option<&Path>) -> Result<ProjectSummary, String> {
|
||||
let root = root
|
||||
.canonicalize()
|
||||
.map_err(|error| format!("could not open project root {}: {error}", root.display()))?;
|
||||
if !root.is_dir() {
|
||||
return Err(format!(
|
||||
"project root is not a directory: {}",
|
||||
root.display()
|
||||
));
|
||||
}
|
||||
let manifest_path = root.join(DEFAULT_PROJECT_PATH);
|
||||
let text = std::fs::read_to_string(&manifest_path)
|
||||
.map_err(|error| format!("could not read {}: {error}", manifest_path.display()))?;
|
||||
let manifest: ProjectSettings = ron::from_str(&text).map_err(|error| {
|
||||
format!(
|
||||
"invalid project manifest {}: {error}",
|
||||
manifest_path.display()
|
||||
)
|
||||
})?;
|
||||
if manifest.name.trim().is_empty() {
|
||||
return Err(format!(
|
||||
"project name is empty in {}",
|
||||
manifest_path.display()
|
||||
));
|
||||
}
|
||||
manifest.audio.validate().map_err(|error| {
|
||||
format!(
|
||||
"invalid audio settings in {}: {error}",
|
||||
manifest_path.display()
|
||||
)
|
||||
})?;
|
||||
let default_reference = Path::new(&manifest.default_level);
|
||||
if !default_reference.starts_with("assets/levels")
|
||||
|| !manifest.default_level.ends_with(".scn.ron")
|
||||
{
|
||||
return Err("default_level must be a .scn.ron scene under assets/levels/".into());
|
||||
}
|
||||
let default_level = safe_project_path(&root, default_reference, "default_level")?;
|
||||
let default_metadata = std::fs::symlink_metadata(&default_level).ok();
|
||||
if !default_metadata
|
||||
.as_ref()
|
||||
.is_some_and(std::fs::Metadata::is_file)
|
||||
|| default_metadata.is_some_and(|metadata| metadata.file_type().is_symlink())
|
||||
{
|
||||
return Err(format!(
|
||||
"default level is missing or is not a regular file: {}",
|
||||
default_level.display()
|
||||
));
|
||||
}
|
||||
let default_level_text = std::fs::read_to_string(&default_level).map_err(|error| {
|
||||
format!(
|
||||
"could not read default level {}: {error}",
|
||||
default_level.display()
|
||||
)
|
||||
})?;
|
||||
scene::validate_level_text(&default_level_text).map_err(|error| {
|
||||
format!(
|
||||
"default level failed validation {}: {error}",
|
||||
default_level.display()
|
||||
)
|
||||
})?;
|
||||
scene::validate_composition_graph(&default_level, &root).map_err(|error| {
|
||||
format!(
|
||||
"default level composition failed validation {}: {error}",
|
||||
default_level.display()
|
||||
)
|
||||
})?;
|
||||
|
||||
let last_scene = last_scene
|
||||
.and_then(|path| safe_project_path(&root, path, "last_scene").ok())
|
||||
.filter(|path| path.is_file());
|
||||
let project_id = if manifest.project_id.trim().is_empty() {
|
||||
format!("legacy:{}", root.display())
|
||||
} else {
|
||||
manifest.project_id
|
||||
};
|
||||
Ok(ProjectSummary {
|
||||
root,
|
||||
project_id,
|
||||
name: manifest.name,
|
||||
project_kind: manifest.project_kind,
|
||||
template_version: manifest.template_version,
|
||||
capabilities: manifest.capabilities,
|
||||
default_level,
|
||||
last_scene,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn recent_project_summaries(preferences: &UserPreferences) -> Vec<ProjectSummary> {
|
||||
let mut seen = HashSet::new();
|
||||
preferences
|
||||
.recent_projects
|
||||
.iter()
|
||||
.filter_map(|root| {
|
||||
let root = PathBuf::from(root);
|
||||
let last_scene = preferences
|
||||
.recent_levels
|
||||
.iter()
|
||||
.map(PathBuf::from)
|
||||
.find(|scene| root.join(scene).is_file());
|
||||
inspect_project(&root, last_scene.as_deref()).ok()
|
||||
})
|
||||
.filter(|summary| seen.insert(summary.root.clone()))
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn scaffold_sandbox_project(destination: &Path, name: &str) -> Result<ProjectSummary, String> {
|
||||
let name = name.trim();
|
||||
if name.is_empty() {
|
||||
return Err("sandbox project name cannot be empty".to_string());
|
||||
}
|
||||
if destination.exists() {
|
||||
let mut entries = std::fs::read_dir(destination)
|
||||
.map_err(|error| format!("could not inspect {}: {error}", destination.display()))?;
|
||||
if entries.next().is_some() {
|
||||
return Err(format!(
|
||||
"sandbox destination must be empty: {}",
|
||||
destination.display()
|
||||
));
|
||||
}
|
||||
}
|
||||
for directory in SANDBOX_DIRECTORIES {
|
||||
std::fs::create_dir_all(destination.join(directory)).map_err(|error| {
|
||||
format!(
|
||||
"could not create sandbox directory {}: {error}",
|
||||
destination.join(directory).display()
|
||||
)
|
||||
})?;
|
||||
}
|
||||
|
||||
let default_level = "assets/levels/main.scn.ron";
|
||||
let empty_scene = format!(
|
||||
"(schema_version: {},\n resources: {{}},\n entities: {{}},\n)\n",
|
||||
scene::CURRENT_SCENE_SCHEMA_VERSION
|
||||
);
|
||||
scene::validate_level_text(&empty_scene)?;
|
||||
atomic_write(&destination.join(default_level), empty_scene.as_bytes())?;
|
||||
|
||||
let manifest = ProjectSettings {
|
||||
project_id: uuid::Uuid::new_v4().to_string(),
|
||||
name: name.to_string(),
|
||||
project_kind: ProjectKind::Sandbox,
|
||||
template_version: PROJECT_TEMPLATE_VERSION,
|
||||
capabilities: vec![
|
||||
"editor".into(),
|
||||
"gameplay".into(),
|
||||
"rendering".into(),
|
||||
"audio".into(),
|
||||
],
|
||||
default_level: default_level.to_string(),
|
||||
asset_roots: vec![
|
||||
"assets/audio".into(),
|
||||
"assets/levels".into(),
|
||||
"assets/materials".into(),
|
||||
"assets/meshes".into(),
|
||||
"assets/models".into(),
|
||||
"assets/textures".into(),
|
||||
],
|
||||
..ProjectSettings::default()
|
||||
};
|
||||
let manifest_text = save_project_settings_to_string(&manifest)
|
||||
.map_err(|error| format!("could not serialize sandbox manifest: {error}"))?;
|
||||
atomic_write(
|
||||
&destination.join(DEFAULT_PROJECT_PATH),
|
||||
manifest_text.as_bytes(),
|
||||
)?;
|
||||
for (name, profile) in sandbox_build_profiles(default_level) {
|
||||
atomic_write(
|
||||
&destination.join("assets/build_profiles").join(name),
|
||||
profile.as_bytes(),
|
||||
)?;
|
||||
}
|
||||
inspect_project(destination, None)
|
||||
}
|
||||
|
||||
fn sandbox_build_profiles(default_level: &str) -> [(&'static str, String); 3] {
|
||||
[
|
||||
(
|
||||
"development.ron",
|
||||
format!(
|
||||
"(version:1,name:\"Development\",cargo_profile:Development,target:None,features:[],rendering_tier:\"development\",default_scene:Some(\"{default_level}\"),output_dir:\"dist/development\")\n"
|
||||
),
|
||||
),
|
||||
(
|
||||
"qa.ron",
|
||||
format!(
|
||||
"(version:1,name:\"QA\",cargo_profile:Qa,target:None,features:[],rendering_tier:\"representative\",default_scene:Some(\"{default_level}\"),output_dir:\"dist/qa\")\n"
|
||||
),
|
||||
),
|
||||
(
|
||||
"release.ron",
|
||||
format!(
|
||||
"(version:1,name:\"Release\",cargo_profile:Release,target:None,features:[],rendering_tier:\"shipping\",default_scene:Some(\"{default_level}\"),output_dir:\"dist/release\")\n"
|
||||
),
|
||||
),
|
||||
]
|
||||
}
|
||||
|
||||
fn safe_project_path(root: &Path, path: impl AsRef<Path>, field: &str) -> Result<PathBuf, String> {
|
||||
let path = path.as_ref();
|
||||
if path.as_os_str().is_empty() || path.is_absolute() {
|
||||
return Err(format!("{field} must be a non-empty project-relative path"));
|
||||
}
|
||||
if path.components().any(|component| {
|
||||
matches!(
|
||||
component,
|
||||
Component::ParentDir | Component::RootDir | Component::Prefix(_)
|
||||
)
|
||||
}) {
|
||||
return Err(format!("{field} cannot escape the project root"));
|
||||
}
|
||||
Ok(root.join(path))
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn temp_root(label: &str) -> PathBuf {
|
||||
std::env::temp_dir().join(format!("blacksite-{label}-{}", uuid::Uuid::new_v4()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn startup_arguments_parse_project_and_reject_unknown_flags() {
|
||||
let parsed =
|
||||
parse_startup_arguments(["--project".to_string(), "/tmp/project".to_string()]).unwrap();
|
||||
assert_eq!(parsed.project, Some(PathBuf::from("/tmp/project")));
|
||||
assert!(parse_startup_arguments(["--mystery".to_string()]).is_err());
|
||||
assert!(parse_startup_arguments(["--project".to_string()]).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sandbox_scaffold_can_be_inspected_and_reloaded() {
|
||||
let root = temp_root("sandbox");
|
||||
|
||||
let created = scaffold_sandbox_project(&root, "Prototype").unwrap();
|
||||
let reopened =
|
||||
inspect_project(&root, Some(Path::new("assets/levels/main.scn.ron"))).unwrap();
|
||||
|
||||
assert_eq!(created.project_id, reopened.project_id);
|
||||
assert_eq!(reopened.name, "Prototype");
|
||||
assert_eq!(reopened.project_kind, ProjectKind::Sandbox);
|
||||
assert_eq!(reopened.template_version, PROJECT_TEMPLATE_VERSION);
|
||||
assert!(reopened.capabilities.iter().any(|item| item == "audio"));
|
||||
let manifest = settings::load_project_settings_from_path(
|
||||
root.join(DEFAULT_PROJECT_PATH).to_string_lossy().as_ref(),
|
||||
);
|
||||
assert!(manifest.audio.validate().is_ok());
|
||||
assert!(manifest.audio.bus(settings::AUDIO_BUS_SFX_ID).is_some());
|
||||
assert_eq!(
|
||||
reopened.last_scene,
|
||||
Some(root.join("assets/levels/main.scn.ron"))
|
||||
);
|
||||
for directory in SANDBOX_DIRECTORIES {
|
||||
assert!(root.join(directory).is_dir(), "missing {directory}");
|
||||
}
|
||||
for profile in ["development.ron", "qa.ron", "release.ron"] {
|
||||
let text =
|
||||
std::fs::read_to_string(root.join("assets/build_profiles").join(profile)).unwrap();
|
||||
assert!(text.contains("assets/levels/main.scn.ron"), "{profile}");
|
||||
assert!(text.contains("output_dir"), "{profile}");
|
||||
}
|
||||
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recent_projects_filter_missing_invalid_and_duplicate_roots() {
|
||||
let valid = temp_root("recent-valid");
|
||||
let invalid = temp_root("recent-invalid");
|
||||
scaffold_sandbox_project(&valid, "Valid").unwrap();
|
||||
std::fs::create_dir_all(&invalid).unwrap();
|
||||
let preferences = UserPreferences {
|
||||
recent_projects: vec![
|
||||
valid.display().to_string(),
|
||||
"/definitely/missing/blacksite-project".to_string(),
|
||||
invalid.display().to_string(),
|
||||
valid.display().to_string(),
|
||||
],
|
||||
recent_levels: vec!["assets/levels/main.scn.ron".to_string()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let summaries = recent_project_summaries(&preferences);
|
||||
|
||||
assert_eq!(summaries.len(), 1);
|
||||
assert_eq!(summaries[0].name, "Valid");
|
||||
assert!(summaries[0].last_scene.is_some());
|
||||
std::fs::remove_dir_all(valid).unwrap();
|
||||
std::fs::remove_dir_all(invalid).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_inspection_rejects_invalid_audio_bus_graphs() {
|
||||
let root = temp_root("invalid-audio-buses");
|
||||
scaffold_sandbox_project(&root, "Invalid Audio").unwrap();
|
||||
let manifest_path = root.join(DEFAULT_PROJECT_PATH);
|
||||
let mut manifest =
|
||||
settings::load_project_settings_from_path(manifest_path.to_string_lossy().as_ref());
|
||||
manifest
|
||||
.audio
|
||||
.bus_mut(settings::AUDIO_BUS_SFX_ID)
|
||||
.unwrap()
|
||||
.parent = Some("missing".into());
|
||||
std::fs::write(
|
||||
&manifest_path,
|
||||
save_project_settings_to_string(&manifest).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let error = inspect_project(&root, None).unwrap_err();
|
||||
|
||||
assert!(error.contains("invalid audio settings"), "{error}");
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn sandbox_scaffold_refuses_nonempty_destination_and_path_escape() {
|
||||
let root = temp_root("sandbox-nonempty");
|
||||
std::fs::create_dir_all(&root).unwrap();
|
||||
std::fs::write(root.join("keep.txt"), "user data").unwrap();
|
||||
|
||||
assert!(scaffold_sandbox_project(&root, "Unsafe").is_err());
|
||||
assert!(safe_project_path(&root, "../outside", "test").is_err());
|
||||
assert_eq!(
|
||||
std::fs::read_to_string(root.join("keep.txt")).unwrap(),
|
||||
"user data"
|
||||
);
|
||||
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_default_level_must_use_the_audited_levels_tree() {
|
||||
let root = temp_root("default-level-contract");
|
||||
scaffold_sandbox_project(&root, "Contract").unwrap();
|
||||
std::fs::create_dir_all(root.join("assets/custom")).unwrap();
|
||||
std::fs::write(
|
||||
root.join("assets/custom/start.scn.ron"),
|
||||
format!(
|
||||
"(schema_version:{},resources:{{}},entities:{{}})",
|
||||
scene::CURRENT_SCENE_SCHEMA_VERSION
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
let mut manifest = settings::load_project_settings_from_path(
|
||||
root.join(DEFAULT_PROJECT_PATH).to_string_lossy().as_ref(),
|
||||
);
|
||||
manifest.default_level = "assets/custom/start.scn.ron".into();
|
||||
std::fs::write(
|
||||
root.join(DEFAULT_PROJECT_PATH),
|
||||
save_project_settings_to_string(&manifest).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let error = inspect_project(&root, None).unwrap_err();
|
||||
|
||||
assert!(error.contains("assets/levels"), "{error}");
|
||||
std::fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,9 @@
|
||||
//! 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 session;
|
||||
pub mod settings_ui;
|
||||
@@ -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());
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{ProjectSettings, ProjectSettingsIo, DEFAULT_PROJECT_PATH};
|
||||
use settings::{ProjectKind, ProjectSettings, ProjectSettingsIo, DEFAULT_PROJECT_PATH};
|
||||
|
||||
use crate::scene_io::SceneIo;
|
||||
|
||||
@@ -10,7 +10,7 @@ const USER_CONFIG_DIR: &str = ".config/bevy-fps";
|
||||
const USER_PREFS_FILE: &str = "editor_prefs.ron";
|
||||
|
||||
/// User-local editor preferences (not checked into the repo).
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, Resource)]
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Resource)]
|
||||
pub struct UserPreferences {
|
||||
pub recent_projects: Vec<String>,
|
||||
pub recent_levels: Vec<String>,
|
||||
@@ -31,16 +31,53 @@ pub struct UserPreferences {
|
||||
pub hierarchy_show_runtime: bool,
|
||||
#[serde(default)]
|
||||
pub hierarchy_sort_mode: crate::ui::hierarchy_state::HierarchySort,
|
||||
#[serde(default = "default_true")]
|
||||
pub scene_autosave_enabled: bool,
|
||||
#[serde(default = "default_autosave_interval_secs")]
|
||||
pub scene_autosave_interval_secs: u64,
|
||||
#[serde(default = "default_recovery_generations")]
|
||||
pub scene_recovery_generations: usize,
|
||||
}
|
||||
|
||||
fn default_true() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
const fn default_autosave_interval_secs() -> u64 {
|
||||
120
|
||||
}
|
||||
|
||||
const fn default_recovery_generations() -> usize {
|
||||
5
|
||||
}
|
||||
|
||||
impl Default for UserPreferences {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
recent_projects: Vec::new(),
|
||||
recent_levels: Vec::new(),
|
||||
last_project_root: None,
|
||||
dock_layout: None,
|
||||
save_before_play: false,
|
||||
hierarchy_filter: String::new(),
|
||||
hierarchy_expanded_paths: Vec::new(),
|
||||
hierarchy_show_generated: true,
|
||||
hierarchy_show_runtime: false,
|
||||
hierarchy_sort_mode: crate::ui::hierarchy_state::HierarchySort::default(),
|
||||
scene_autosave_enabled: true,
|
||||
scene_autosave_interval_secs: default_autosave_interval_secs(),
|
||||
scene_recovery_generations: default_recovery_generations(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Active project workspace metadata (mirrors manifest fields in `ProjectSettings`).
|
||||
#[derive(Resource, Debug, Clone)]
|
||||
pub struct ProjectWorkspace {
|
||||
pub root: String,
|
||||
pub project_id: String,
|
||||
pub project_kind: ProjectKind,
|
||||
pub last_opened_scene: Option<String>,
|
||||
pub settings_path: String,
|
||||
pub settings_dirty: bool,
|
||||
pub layout_dirty: bool,
|
||||
@@ -54,6 +91,9 @@ impl Default for ProjectWorkspace {
|
||||
.unwrap_or_else(|| ".".into());
|
||||
Self {
|
||||
root,
|
||||
project_id: String::new(),
|
||||
project_kind: ProjectKind::default(),
|
||||
last_opened_scene: None,
|
||||
settings_path: DEFAULT_PROJECT_PATH.into(),
|
||||
settings_dirty: false,
|
||||
layout_dirty: false,
|
||||
@@ -73,7 +113,13 @@ impl Plugin for ProjectIoPlugin {
|
||||
}
|
||||
|
||||
fn load_user_preferences(mut commands: Commands) {
|
||||
let prefs = read_user_preferences();
|
||||
let mut prefs = read_user_preferences();
|
||||
if let Ok(root) = std::env::current_dir().and_then(|root| root.canonicalize()) {
|
||||
remember_project_root(&mut prefs, &root);
|
||||
if let Err(error) = write_user_preferences(&prefs) {
|
||||
warn!("Failed to remember active project: {error}");
|
||||
}
|
||||
}
|
||||
commands.insert_resource(prefs);
|
||||
}
|
||||
|
||||
@@ -85,12 +131,13 @@ pub(crate) fn load_user_preferences_on_startup(commands: Commands) {
|
||||
fn sync_workspace_from_settings_system(
|
||||
settings: Res<ProjectSettings>,
|
||||
settings_io: Res<ProjectSettingsIo>,
|
||||
scene_io: Res<SceneIo>,
|
||||
mut workspace: ResMut<ProjectWorkspace>,
|
||||
) {
|
||||
if !settings_io.is_changed() && !settings.is_changed() {
|
||||
if !settings_io.is_changed() && !settings.is_changed() && !scene_io.is_changed() {
|
||||
return;
|
||||
}
|
||||
sync_workspace_from_settings(&mut workspace, &settings, &settings_io);
|
||||
sync_workspace_from_settings(&mut workspace, &settings, &settings_io, &scene_io);
|
||||
}
|
||||
|
||||
fn user_prefs_path() -> Option<std::path::PathBuf> {
|
||||
@@ -127,14 +174,26 @@ pub fn push_recent(list: &mut Vec<String>, entry: String, max: usize) {
|
||||
list.truncate(max);
|
||||
}
|
||||
|
||||
pub fn remember_project_root(preferences: &mut UserPreferences, root: &std::path::Path) {
|
||||
let root = root.display().to_string();
|
||||
push_recent(&mut preferences.recent_projects, root.clone(), 12);
|
||||
preferences.last_project_root = Some(root);
|
||||
}
|
||||
|
||||
pub fn sync_workspace_from_settings(
|
||||
workspace: &mut ProjectWorkspace,
|
||||
settings: &ProjectSettings,
|
||||
settings_io: &ProjectSettingsIo,
|
||||
scene_io: &SceneIo,
|
||||
) {
|
||||
workspace.project_id.clone_from(&settings.project_id);
|
||||
workspace.project_kind = settings.project_kind;
|
||||
workspace.last_opened_scene = scene_io
|
||||
.active_path
|
||||
.as_ref()
|
||||
.map(|path| path.display().to_string());
|
||||
workspace.settings_path = settings_io.path.clone();
|
||||
workspace.settings_dirty = settings_io.dirty;
|
||||
let _ = settings;
|
||||
}
|
||||
|
||||
pub fn window_title(
|
||||
@@ -160,3 +219,21 @@ pub fn window_title(
|
||||
}
|
||||
parts.join(" — ")
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn remembering_project_deduplicates_and_updates_last_root() {
|
||||
let mut preferences = UserPreferences {
|
||||
recent_projects: vec!["/old".into(), "/project".into()],
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
remember_project_root(&mut preferences, std::path::Path::new("/project"));
|
||||
|
||||
assert_eq!(preferences.last_project_root.as_deref(), Some("/project"));
|
||||
assert_eq!(preferences.recent_projects, vec!["/project", "/old"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
//! Versioned machine-local editor session persistence and crash boundary.
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use bevy::app::AppExit;
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
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::ui::{BrushDiagnosticsPanel, DiagnosticsPanel};
|
||||
use crate::viewport::rendering_diagnostics::RenderingDiagnosticsPanel;
|
||||
use crate::viewport::CameraBookmarks;
|
||||
|
||||
const SESSION_FILE: &str = "session.ron";
|
||||
const SESSION_SCHEMA_VERSION: u32 = 1;
|
||||
const SESSION_WRITE_INTERVAL_SECS: f32 = 2.0;
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct SessionPanelState {
|
||||
#[serde(default)]
|
||||
pub diagnostics: bool,
|
||||
#[serde(default)]
|
||||
pub brush_diagnostics: bool,
|
||||
#[serde(default)]
|
||||
pub rendering: bool,
|
||||
#[serde(default)]
|
||||
pub project_settings: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct CameraBookmarkRecord {
|
||||
pub scene: String,
|
||||
pub translation: [f32; 3],
|
||||
pub rotation: [f32; 4],
|
||||
pub scale: [f32; 3],
|
||||
}
|
||||
|
||||
impl CameraBookmarkRecord {
|
||||
fn from_transform(scene: String, transform: Transform) -> Self {
|
||||
Self {
|
||||
scene,
|
||||
translation: transform.translation.to_array(),
|
||||
rotation: transform.rotation.to_array(),
|
||||
scale: transform.scale.to_array(),
|
||||
}
|
||||
}
|
||||
|
||||
fn to_transform(&self) -> Transform {
|
||||
Transform {
|
||||
translation: Vec3::from_array(self.translation),
|
||||
rotation: Quat::from_array(self.rotation).normalize(),
|
||||
scale: Vec3::from_array(self.scale),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct EditorSessionDocument {
|
||||
#[serde(default)]
|
||||
pub schema_version: u32,
|
||||
#[serde(default)]
|
||||
pub clean_shutdown: bool,
|
||||
#[serde(default)]
|
||||
pub project_root: String,
|
||||
#[serde(default)]
|
||||
pub active_scene: Option<String>,
|
||||
#[serde(default)]
|
||||
pub dock_layout: Option<String>,
|
||||
#[serde(default)]
|
||||
pub hierarchy_expanded_paths: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub panels: SessionPanelState,
|
||||
#[serde(default)]
|
||||
pub camera_bookmarks: Vec<CameraBookmarkRecord>,
|
||||
}
|
||||
|
||||
impl Default for EditorSessionDocument {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
schema_version: SESSION_SCHEMA_VERSION,
|
||||
clean_shutdown: true,
|
||||
project_root: String::new(),
|
||||
active_scene: None,
|
||||
dock_layout: None,
|
||||
hierarchy_expanded_paths: Vec::new(),
|
||||
panels: SessionPanelState::default(),
|
||||
camera_bookmarks: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Resource, Debug, Default)]
|
||||
pub struct EditorSessionRuntime {
|
||||
pub prior_abnormal_shutdown: bool,
|
||||
pub resume_scene: Option<PathBuf>,
|
||||
pub resume_prompt_open: bool,
|
||||
save_elapsed_secs: f32,
|
||||
}
|
||||
|
||||
pub struct EditorSessionPlugin;
|
||||
|
||||
impl Plugin for EditorSessionPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.init_resource::<EditorSessionRuntime>()
|
||||
.add_systems(Startup, initialize_session)
|
||||
.add_systems(Update, persist_running_session)
|
||||
.add_systems(
|
||||
Last,
|
||||
persist_clean_session_on_exit.after(bevy::window::ExitSystems),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn session_resume_window(world: &mut World, ctx: &egui::Context) {
|
||||
let (open, scene) = {
|
||||
let runtime = world.resource::<EditorSessionRuntime>();
|
||||
(runtime.resume_prompt_open, runtime.resume_scene.clone())
|
||||
};
|
||||
if !open {
|
||||
return;
|
||||
}
|
||||
let Some(scene) = scene else {
|
||||
world
|
||||
.resource_mut::<EditorSessionRuntime>()
|
||||
.resume_prompt_open = false;
|
||||
return;
|
||||
};
|
||||
|
||||
egui::Window::new("Recover Editor Session")
|
||||
.collapsible(false)
|
||||
.resizable(false)
|
||||
.anchor(egui::Align2::CENTER_CENTER, egui::Vec2::ZERO)
|
||||
.show(ctx, |ui| {
|
||||
ui.label("The previous editor session did not close cleanly.");
|
||||
ui.small("The safe startup scene is active. Resume only the last authored scene; modal tools and dirty preview state are never restored.");
|
||||
ui.monospace(scene.display().to_string());
|
||||
ui.separator();
|
||||
ui.horizontal(|ui| {
|
||||
if ui.button("Resume Last Scene").clicked() {
|
||||
world.resource_mut::<SceneIo>().request =
|
||||
Some(SceneIoRequest::OpenPath(scene.clone()));
|
||||
world
|
||||
.resource_mut::<EditorSessionRuntime>()
|
||||
.resume_prompt_open = false;
|
||||
}
|
||||
if ui.button("Continue Safe").clicked() {
|
||||
world
|
||||
.resource_mut::<EditorSessionRuntime>()
|
||||
.resume_prompt_open = false;
|
||||
world
|
||||
.resource_mut::<SceneIo>()
|
||||
.set_status("Continued with safe startup after abnormal shutdown");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
fn session_path() -> Option<PathBuf> {
|
||||
default_state_root().map(|root| root.join(SESSION_FILE))
|
||||
}
|
||||
|
||||
fn read_session(path: &Path) -> Result<EditorSessionDocument, String> {
|
||||
let text = std::fs::read_to_string(path)
|
||||
.map_err(|error| format!("could not read {}: {error}", path.display()))?;
|
||||
let document: EditorSessionDocument =
|
||||
ron::from_str(&text).map_err(|error| format!("invalid session document: {error}"))?;
|
||||
normalize_session(document)
|
||||
}
|
||||
|
||||
fn normalize_session(mut document: EditorSessionDocument) -> Result<EditorSessionDocument, String> {
|
||||
match document.schema_version {
|
||||
0 => document.schema_version = SESSION_SCHEMA_VERSION,
|
||||
SESSION_SCHEMA_VERSION => {}
|
||||
version => {
|
||||
return Err(format!(
|
||||
"session schema {version} is newer than supported {SESSION_SCHEMA_VERSION}"
|
||||
));
|
||||
}
|
||||
}
|
||||
document.camera_bookmarks.retain(valid_bookmark);
|
||||
Ok(document)
|
||||
}
|
||||
|
||||
fn valid_bookmark(bookmark: &CameraBookmarkRecord) -> bool {
|
||||
bookmark
|
||||
.translation
|
||||
.iter()
|
||||
.chain(bookmark.rotation.iter())
|
||||
.chain(bookmark.scale.iter())
|
||||
.all(|value| value.is_finite())
|
||||
}
|
||||
|
||||
fn write_session(path: &Path, document: &EditorSessionDocument) -> Result<(), String> {
|
||||
let text = ron::ser::to_string_pretty(document, ron::ser::PrettyConfig::default())
|
||||
.map_err(|error| format!("could not serialize session: {error}"))?;
|
||||
atomic_write(path, text.as_bytes())
|
||||
}
|
||||
|
||||
fn initialize_session(world: &mut World) {
|
||||
let previous = session_path().and_then(|path| read_session(&path).ok());
|
||||
let prior_abnormal = previous
|
||||
.as_ref()
|
||||
.is_some_and(|document| !document.clean_shutdown);
|
||||
|
||||
if let Some(document) = previous.as_ref() {
|
||||
restore_non_destructive_session_state(world, document);
|
||||
if !prior_abnormal {
|
||||
restore_active_scene(world, document);
|
||||
}
|
||||
}
|
||||
|
||||
let resume_scene = previous
|
||||
.as_ref()
|
||||
.and_then(|document| document.active_scene.as_deref())
|
||||
.map(PathBuf::from)
|
||||
.filter(|path| path.exists());
|
||||
world.insert_resource(EditorSessionRuntime {
|
||||
prior_abnormal_shutdown: prior_abnormal,
|
||||
resume_prompt_open: prior_abnormal && resume_scene.is_some(),
|
||||
resume_scene,
|
||||
save_elapsed_secs: 0.0,
|
||||
});
|
||||
|
||||
if let Some(path) = session_path() {
|
||||
let document = capture_session(world, false);
|
||||
if let Err(error) = write_session(&path, &document) {
|
||||
warn!("Failed to write running session marker: {error}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn restore_active_scene(world: &mut World, document: &EditorSessionDocument) {
|
||||
let Some(path) = document.active_scene.as_deref().map(PathBuf::from) else {
|
||||
return;
|
||||
};
|
||||
if path.exists() {
|
||||
world.resource_mut::<SceneIo>().active_path = Some(path);
|
||||
}
|
||||
}
|
||||
|
||||
fn restore_non_destructive_session_state(world: &mut World, document: &EditorSessionDocument) {
|
||||
let poses = document
|
||||
.camera_bookmarks
|
||||
.iter()
|
||||
.map(|bookmark| (bookmark.scene.clone(), bookmark.to_transform()))
|
||||
.collect();
|
||||
world.resource_mut::<CameraBookmarks>().poses = poses;
|
||||
world.resource_mut::<DiagnosticsPanel>().open = document.panels.diagnostics;
|
||||
world.resource_mut::<BrushDiagnosticsPanel>().open = document.panels.brush_diagnostics;
|
||||
world.resource_mut::<RenderingDiagnosticsPanel>().open = document.panels.rendering;
|
||||
world.resource_mut::<ProjectSettingsPanel>().open = document.panels.project_settings;
|
||||
}
|
||||
|
||||
fn capture_session(world: &World, clean_shutdown: bool) -> EditorSessionDocument {
|
||||
let prefs = world.resource::<UserPreferences>();
|
||||
EditorSessionDocument {
|
||||
schema_version: SESSION_SCHEMA_VERSION,
|
||||
clean_shutdown,
|
||||
project_root: world.resource::<ProjectWorkspace>().root.clone(),
|
||||
active_scene: world
|
||||
.resource::<SceneIo>()
|
||||
.active_path
|
||||
.as_ref()
|
||||
.map(|path| path.display().to_string()),
|
||||
dock_layout: prefs.dock_layout.clone(),
|
||||
hierarchy_expanded_paths: prefs.hierarchy_expanded_paths.clone(),
|
||||
panels: SessionPanelState {
|
||||
diagnostics: world.resource::<DiagnosticsPanel>().open,
|
||||
brush_diagnostics: world.resource::<BrushDiagnosticsPanel>().open,
|
||||
rendering: world.resource::<RenderingDiagnosticsPanel>().open,
|
||||
project_settings: world.resource::<ProjectSettingsPanel>().open,
|
||||
},
|
||||
camera_bookmarks: world
|
||||
.resource::<CameraBookmarks>()
|
||||
.poses
|
||||
.iter()
|
||||
.map(|(scene, transform)| {
|
||||
CameraBookmarkRecord::from_transform(scene.clone(), *transform)
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn persist_running_session(world: &mut World) {
|
||||
let delta = world.resource::<Time>().delta_secs();
|
||||
let should_write = {
|
||||
let mut runtime = world.resource_mut::<EditorSessionRuntime>();
|
||||
runtime.save_elapsed_secs += delta;
|
||||
if runtime.save_elapsed_secs < SESSION_WRITE_INTERVAL_SECS {
|
||||
false
|
||||
} else {
|
||||
runtime.save_elapsed_secs = 0.0;
|
||||
true
|
||||
}
|
||||
};
|
||||
if !should_write {
|
||||
return;
|
||||
}
|
||||
let Some(path) = session_path() else {
|
||||
return;
|
||||
};
|
||||
if let Err(error) = write_session(&path, &capture_session(world, false)) {
|
||||
warn!("Failed to persist running editor session: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
fn persist_clean_session_on_exit(
|
||||
mut exits: MessageReader<AppExit>,
|
||||
scene_io: Res<SceneIo>,
|
||||
workspace: Res<ProjectWorkspace>,
|
||||
prefs: Res<UserPreferences>,
|
||||
bookmarks: Res<CameraBookmarks>,
|
||||
diagnostics: Res<DiagnosticsPanel>,
|
||||
brush_diagnostics: Res<BrushDiagnosticsPanel>,
|
||||
rendering: Res<RenderingDiagnosticsPanel>,
|
||||
project_settings: Res<ProjectSettingsPanel>,
|
||||
) {
|
||||
if exits.read().next().is_none() {
|
||||
return;
|
||||
}
|
||||
let Some(path) = session_path() else {
|
||||
return;
|
||||
};
|
||||
let document = EditorSessionDocument {
|
||||
schema_version: SESSION_SCHEMA_VERSION,
|
||||
clean_shutdown: true,
|
||||
project_root: workspace.root.clone(),
|
||||
active_scene: scene_io
|
||||
.active_path
|
||||
.as_ref()
|
||||
.map(|path| path.display().to_string()),
|
||||
dock_layout: prefs.dock_layout.clone(),
|
||||
hierarchy_expanded_paths: prefs.hierarchy_expanded_paths.clone(),
|
||||
panels: SessionPanelState {
|
||||
diagnostics: diagnostics.open,
|
||||
brush_diagnostics: brush_diagnostics.open,
|
||||
rendering: rendering.open,
|
||||
project_settings: project_settings.open,
|
||||
},
|
||||
camera_bookmarks: bookmarks
|
||||
.poses
|
||||
.iter()
|
||||
.map(|(scene, transform)| {
|
||||
CameraBookmarkRecord::from_transform(scene.clone(), *transform)
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
if let Err(error) = write_session(&path, &document) {
|
||||
warn!("Failed to persist clean editor shutdown: {error}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn legacy_unversioned_session_migrates_to_v1() {
|
||||
let legacy = r#"(
|
||||
clean_shutdown: true,
|
||||
project_root: "/project",
|
||||
active_scene: Some("assets/levels/test.scn.ron"),
|
||||
)"#;
|
||||
let document: EditorSessionDocument = ron::from_str(legacy).unwrap();
|
||||
|
||||
let migrated = normalize_session(document).unwrap();
|
||||
|
||||
assert_eq!(migrated.schema_version, SESSION_SCHEMA_VERSION);
|
||||
assert_eq!(migrated.project_root, "/project");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newer_session_schema_is_rejected() {
|
||||
let document = EditorSessionDocument {
|
||||
schema_version: SESSION_SCHEMA_VERSION + 1,
|
||||
..default()
|
||||
};
|
||||
|
||||
assert!(normalize_session(document)
|
||||
.unwrap_err()
|
||||
.contains("newer than supported"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn invalid_camera_pose_is_removed_during_migration() {
|
||||
let mut document = EditorSessionDocument::default();
|
||||
document.camera_bookmarks.push(CameraBookmarkRecord {
|
||||
scene: "scene".to_string(),
|
||||
translation: [f32::NAN, 0.0, 0.0],
|
||||
rotation: [0.0, 0.0, 0.0, 1.0],
|
||||
scale: [1.0; 3],
|
||||
});
|
||||
|
||||
assert!(normalize_session(document)
|
||||
.unwrap()
|
||||
.camera_bookmarks
|
||||
.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialized_session_contains_only_allowlisted_metadata() {
|
||||
let document = EditorSessionDocument {
|
||||
project_root: "/project".to_string(),
|
||||
active_scene: Some("assets/levels/test.scn.ron".to_string()),
|
||||
..default()
|
||||
};
|
||||
let text = ron::ser::to_string(&document).unwrap();
|
||||
|
||||
assert!(text.contains("active_scene"));
|
||||
for forbidden in ["scene_contents", "credential", "token", "environment"] {
|
||||
assert!(!text.to_ascii_lowercase().contains(forbidden));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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))
|
||||
@@ -210,6 +262,97 @@ fn draw_project_settings_form(
|
||||
);
|
||||
});
|
||||
|
||||
ui.collapsing("Audio Buses", |ui| {
|
||||
let bus_ids: Vec<String> = draft.audio.buses.iter().map(|bus| bus.id.clone()).collect();
|
||||
let mut remove_bus = None;
|
||||
for (index, bus) in draft.audio.buses.iter_mut().enumerate() {
|
||||
egui::Frame::new()
|
||||
.fill(egui::Color32::from_rgb(24, 26, 29))
|
||||
.stroke(egui::Stroke::new(1.0, egui::Color32::from_rgb(53, 57, 63)))
|
||||
.corner_radius(4.0)
|
||||
.inner_margin(8.0)
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.strong(&bus.label);
|
||||
ui.small(
|
||||
egui::RichText::new(format!("[{}]", bus.id))
|
||||
.color(egui::Color32::from_rgb(139, 146, 156)),
|
||||
);
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let required = matches!(
|
||||
bus.id.as_str(),
|
||||
settings::AUDIO_BUS_MASTER_ID
|
||||
| settings::AUDIO_BUS_MUSIC_ID
|
||||
| settings::AUDIO_BUS_SFX_ID
|
||||
);
|
||||
if ui
|
||||
.add_enabled(!required, egui::Button::new("Remove"))
|
||||
.clicked()
|
||||
{
|
||||
remove_bus = Some(index);
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
ui.label("Name");
|
||||
ui.add_sized([140.0, 20.0], egui::TextEdit::singleline(&mut bus.label));
|
||||
ui.checkbox(&mut bus.muted, "Mute");
|
||||
});
|
||||
ui.add(
|
||||
egui::Slider::new(
|
||||
&mut bus.gain_db,
|
||||
settings::AUDIO_GAIN_DB_MIN..=settings::AUDIO_GAIN_DB_MAX,
|
||||
)
|
||||
.text("Gain")
|
||||
.suffix(" dB"),
|
||||
);
|
||||
if bus.id != settings::AUDIO_BUS_MASTER_ID {
|
||||
let parent_label = bus
|
||||
.parent
|
||||
.as_deref()
|
||||
.and_then(|parent| bus_ids.iter().find(|id| id.as_str() == parent))
|
||||
.map(String::as_str)
|
||||
.unwrap_or("None");
|
||||
egui::ComboBox::from_id_salt(("audio_bus_parent", index))
|
||||
.selected_text(parent_label)
|
||||
.show_ui(ui, |ui| {
|
||||
for candidate in &bus_ids {
|
||||
if candidate != &bus.id {
|
||||
ui.selectable_value(
|
||||
&mut bus.parent,
|
||||
Some(candidate.clone()),
|
||||
candidate,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
if let Some(index) = remove_bus {
|
||||
draft.audio.buses.remove(index);
|
||||
}
|
||||
if ui.button("Add Bus").clicked() {
|
||||
let mut suffix = 1usize;
|
||||
let id = loop {
|
||||
let candidate = format!("bus_{suffix}");
|
||||
if draft.audio.bus(&candidate).is_none() {
|
||||
break candidate;
|
||||
}
|
||||
suffix += 1;
|
||||
};
|
||||
draft.audio.buses.push(settings::AudioBusSettings::new(
|
||||
id,
|
||||
"New Bus",
|
||||
Some(settings::AUDIO_BUS_MASTER_ID),
|
||||
));
|
||||
}
|
||||
if let Err(error) = draft.audio.validate() {
|
||||
ui.colored_label(egui::Color32::from_rgb(235, 105, 105), error.to_string());
|
||||
}
|
||||
});
|
||||
|
||||
ui.separator();
|
||||
ui.heading("Physics");
|
||||
ui.add(egui::Slider::new(&mut draft.physics.walk_speed, 1.0..=15.0).text("Walk speed"));
|
||||
@@ -231,31 +374,129 @@ fn draw_project_settings_form(
|
||||
);
|
||||
|
||||
ui.separator();
|
||||
if ui.button("Apply").clicked() {
|
||||
let settings_valid = draft.audio.validate().is_ok();
|
||||
if ui
|
||||
.add_enabled(settings_valid, egui::Button::new("Apply"))
|
||||
.clicked()
|
||||
{
|
||||
commit_project_settings(world, draft);
|
||||
*io_dirty = true;
|
||||
}
|
||||
if ui.button("Save to disk").clicked() {
|
||||
if ui
|
||||
.add_enabled(settings_valid, egui::Button::new("Save to disk"))
|
||||
.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();
|
||||
@@ -279,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>>,
|
||||
@@ -304,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();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Scene I/O, schema validation, and viewport render-target setup.
|
||||
|
||||
pub(crate) mod recovery;
|
||||
pub mod scene_io;
|
||||
pub mod scene_schema;
|
||||
pub mod scene_view;
|
||||
@@ -0,0 +1,334 @@
|
||||
//! Transactional scene persistence and user-local recovery snapshot storage.
|
||||
|
||||
use std::fs::{self, File, OpenOptions};
|
||||
use std::hash::Hasher;
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
const STATE_DIR: &str = "blacksite-editor";
|
||||
const RECOVERY_DIR: &str = "recovery";
|
||||
|
||||
pub(crate) fn atomic_write(path: &Path, bytes: &[u8]) -> Result<(), String> {
|
||||
atomic_write_with_pre_rename(path, bytes, || Ok(()))
|
||||
}
|
||||
|
||||
pub(crate) fn atomic_write_with_pre_rename<E>(
|
||||
path: &Path,
|
||||
bytes: &[u8],
|
||||
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| E::from(format!("could not create {}: {error}", parent.display())))?;
|
||||
|
||||
let file_name = path
|
||||
.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.unwrap_or("scene");
|
||||
let nonce = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_nanos();
|
||||
let temporary = parent.join(format!(".{file_name}.tmp-{}-{nonce}", std::process::id()));
|
||||
|
||||
let result = (|| {
|
||||
let mut file = OpenOptions::new()
|
||||
.create_new(true)
|
||||
.write(true)
|
||||
.open(&temporary)
|
||||
.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| E::from(format!("could not sync {}: {error}", temporary.display())))?;
|
||||
before_rename()?;
|
||||
fs::rename(&temporary, path).map_err(|error| {
|
||||
E::from(format!(
|
||||
"could not replace {} with {}: {error}",
|
||||
path.display(),
|
||||
temporary.display()
|
||||
))
|
||||
})?;
|
||||
sync_parent_directory(parent);
|
||||
Ok(())
|
||||
})();
|
||||
|
||||
if result.is_err() {
|
||||
let _ = fs::remove_file(&temporary);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn sync_parent_directory(parent: &Path) {
|
||||
if let Ok(directory) = File::open(parent) {
|
||||
let _ = directory.sync_all();
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn sync_parent_directory(_parent: &Path) {}
|
||||
|
||||
pub(crate) fn default_state_root() -> Option<PathBuf> {
|
||||
if let Some(path) = std::env::var_os("XDG_STATE_HOME") {
|
||||
return Some(PathBuf::from(path).join(STATE_DIR));
|
||||
}
|
||||
std::env::var_os("HOME")
|
||||
.map(PathBuf::from)
|
||||
.map(|home| home.join(".local/state").join(STATE_DIR))
|
||||
}
|
||||
|
||||
pub(crate) fn write_recovery_snapshot(
|
||||
state_root: &Path,
|
||||
project_root: &Path,
|
||||
scene_path: &Path,
|
||||
bytes: &[u8],
|
||||
max_generations: usize,
|
||||
) -> Result<PathBuf, String> {
|
||||
let directory = recovery_directory(state_root, project_root, scene_path);
|
||||
fs::create_dir_all(&directory)
|
||||
.map_err(|error| format!("could not create {}: {error}", directory.display()))?;
|
||||
let timestamp = SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap_or_default()
|
||||
.as_millis();
|
||||
let snapshot = directory.join(format!(
|
||||
"recovery-{timestamp:020}-{}.scn.ron",
|
||||
std::process::id()
|
||||
));
|
||||
atomic_write(&snapshot, bytes)?;
|
||||
prune_recovery_generations(&directory, max_generations.max(1))?;
|
||||
Ok(snapshot)
|
||||
}
|
||||
|
||||
pub(crate) fn latest_recovery_snapshot(
|
||||
state_root: &Path,
|
||||
project_root: &Path,
|
||||
scene_path: &Path,
|
||||
) -> Option<PathBuf> {
|
||||
let directory = recovery_directory(state_root, project_root, scene_path);
|
||||
let source_modified = fs::metadata(scene_path)
|
||||
.and_then(|metadata| metadata.modified())
|
||||
.unwrap_or(UNIX_EPOCH);
|
||||
recovery_files(&directory)
|
||||
.into_iter()
|
||||
.filter(|path| {
|
||||
fs::metadata(path)
|
||||
.and_then(|metadata| metadata.modified())
|
||||
.is_ok_and(|modified| modified > source_modified)
|
||||
})
|
||||
.max_by_key(|path| path.file_name().map(|name| name.to_os_string()))
|
||||
}
|
||||
|
||||
pub(crate) fn discard_recovery_snapshots(
|
||||
state_root: &Path,
|
||||
project_root: &Path,
|
||||
scene_path: &Path,
|
||||
) -> Result<(), String> {
|
||||
let directory = recovery_directory(state_root, project_root, scene_path);
|
||||
if !directory.exists() {
|
||||
return Ok(());
|
||||
}
|
||||
fs::remove_dir_all(&directory)
|
||||
.map_err(|error| format!("could not remove {}: {error}", directory.display()))
|
||||
}
|
||||
|
||||
fn recovery_directory(state_root: &Path, project_root: &Path, scene_path: &Path) -> PathBuf {
|
||||
state_root
|
||||
.join(RECOVERY_DIR)
|
||||
.join(stable_path_hash(project_root))
|
||||
.join(stable_path_hash(scene_path))
|
||||
}
|
||||
|
||||
fn stable_path_hash(path: &Path) -> String {
|
||||
let normalized = path.to_string_lossy().replace('\\', "/");
|
||||
let mut hasher = Fnv1a64::default();
|
||||
hasher.write(normalized.as_bytes());
|
||||
format!("{:016x}", hasher.finish())
|
||||
}
|
||||
|
||||
fn prune_recovery_generations(directory: &Path, max_generations: usize) -> Result<(), String> {
|
||||
let mut files = recovery_files(directory);
|
||||
files.sort_by_key(|path| path.file_name().map(|name| name.to_os_string()));
|
||||
let remove_count = files.len().saturating_sub(max_generations);
|
||||
for path in files.into_iter().take(remove_count) {
|
||||
fs::remove_file(&path)
|
||||
.map_err(|error| format!("could not prune {}: {error}", path.display()))?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn recovery_files(directory: &Path) -> Vec<PathBuf> {
|
||||
let Ok(entries) = fs::read_dir(directory) else {
|
||||
return Vec::new();
|
||||
};
|
||||
entries
|
||||
.filter_map(Result::ok)
|
||||
.map(|entry| entry.path())
|
||||
.filter(|path| {
|
||||
path.file_name()
|
||||
.and_then(|name| name.to_str())
|
||||
.is_some_and(|name| name.starts_with("recovery-") && name.ends_with(".scn.ron"))
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct Fnv1a64(u64);
|
||||
|
||||
impl Hasher for Fnv1a64 {
|
||||
fn finish(&self) -> u64 {
|
||||
if self.0 == 0 {
|
||||
0xcbf29ce484222325
|
||||
} else {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
fn write(&mut self, bytes: &[u8]) {
|
||||
let mut hash = self.finish();
|
||||
for byte in bytes {
|
||||
hash ^= u64::from(*byte);
|
||||
hash = hash.wrapping_mul(0x100000001b3);
|
||||
}
|
||||
self.0 = hash;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn temp_directory(label: &str) -> PathBuf {
|
||||
std::env::temp_dir().join(format!("blacksite-{label}-{}", uuid::Uuid::new_v4()))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn atomic_write_replaces_content_without_leaving_temporary_files() {
|
||||
let root = temp_directory("atomic-write");
|
||||
let path = root.join("scene.scn.ron");
|
||||
fs::create_dir_all(&root).unwrap();
|
||||
fs::write(&path, b"old").unwrap();
|
||||
|
||||
atomic_write(&path, b"new scene").unwrap();
|
||||
|
||||
assert_eq!(fs::read(&path).unwrap(), b"new scene");
|
||||
assert_eq!(fs::read_dir(&root).unwrap().count(), 1);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn interrupted_atomic_write_preserves_the_last_authored_scene() {
|
||||
let root = temp_directory("atomic-interruption");
|
||||
let path = root.join("scene.scn.ron");
|
||||
fs::create_dir_all(&root).unwrap();
|
||||
fs::write(&path, b"last known good scene").unwrap();
|
||||
|
||||
let result = atomic_write_with_pre_rename(&path, b"partial replacement", || {
|
||||
Err("simulated interruption before rename".to_string())
|
||||
});
|
||||
|
||||
assert_eq!(result.unwrap_err(), "simulated interruption before rename");
|
||||
assert_eq!(fs::read(&path).unwrap(), b"last known good scene");
|
||||
assert_eq!(fs::read_dir(&root).unwrap().count(), 1);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recovery_paths_are_stable_and_scene_specific() {
|
||||
let state = Path::new("/state");
|
||||
let project = Path::new("/project");
|
||||
let first = recovery_directory(state, project, Path::new("assets/levels/a.scn.ron"));
|
||||
let repeated = recovery_directory(state, project, Path::new("assets/levels/a.scn.ron"));
|
||||
let second = recovery_directory(state, project, Path::new("assets/levels/b.scn.ron"));
|
||||
|
||||
assert_eq!(first, repeated);
|
||||
assert_ne!(first, second);
|
||||
assert!(first.starts_with("/state/recovery"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn newer_recovery_generation_is_discovered_for_authored_scene() {
|
||||
let root = temp_directory("recovery-discovery");
|
||||
let project = Path::new("/project");
|
||||
let scene = root.join("assets/levels/test.scn.ron");
|
||||
fs::create_dir_all(scene.parent().unwrap()).unwrap();
|
||||
fs::write(&scene, b"authored").unwrap();
|
||||
std::thread::sleep(std::time::Duration::from_millis(10));
|
||||
|
||||
let snapshot = write_recovery_snapshot(&root, project, &scene, b"recovered", 5).unwrap();
|
||||
|
||||
assert_eq!(
|
||||
latest_recovery_snapshot(&root, project, &scene),
|
||||
Some(snapshot)
|
||||
);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recovery_generations_are_bounded() {
|
||||
let root = temp_directory("recovery-prune");
|
||||
let project = Path::new("/project");
|
||||
let scene = Path::new("assets/levels/test.scn.ron");
|
||||
let directory = recovery_directory(&root, project, scene);
|
||||
fs::create_dir_all(&directory).unwrap();
|
||||
for index in 0..5 {
|
||||
fs::write(
|
||||
directory.join(format!("recovery-{index:020}-1.scn.ron")),
|
||||
index.to_string(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
prune_recovery_generations(&directory, 3).unwrap();
|
||||
|
||||
let mut names: Vec<String> = recovery_files(&directory)
|
||||
.into_iter()
|
||||
.map(|path| path.file_name().unwrap().to_string_lossy().into_owned())
|
||||
.collect();
|
||||
names.sort();
|
||||
assert_eq!(
|
||||
names,
|
||||
vec![
|
||||
"recovery-00000000000000000002-1.scn.ron",
|
||||
"recovery-00000000000000000003-1.scn.ron",
|
||||
"recovery-00000000000000000004-1.scn.ron",
|
||||
]
|
||||
);
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn discard_removes_all_scene_generations() {
|
||||
let root = temp_directory("recovery-discard");
|
||||
let project = Path::new("/project");
|
||||
let scene = Path::new("assets/levels/test.scn.ron");
|
||||
let directory = recovery_directory(&root, project, scene);
|
||||
fs::create_dir_all(&directory).unwrap();
|
||||
fs::write(
|
||||
directory.join("recovery-00000000000000000001-1.scn.ron"),
|
||||
b"one",
|
||||
)
|
||||
.unwrap();
|
||||
fs::write(
|
||||
directory.join("recovery-00000000000000000002-1.scn.ron"),
|
||||
b"two",
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
discard_recovery_snapshots(&root, project, scene).unwrap();
|
||||
|
||||
assert!(!directory.exists());
|
||||
fs::remove_dir_all(root).unwrap();
|
||||
}
|
||||
}
|
||||
+2789
-227
File diff suppressed because it is too large.
Load diff
@@ -5,11 +5,12 @@ mod transform;
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::egui;
|
||||
use egui_phosphor_icons::icons;
|
||||
use shared::{ActorId, ActorKind, ActorName, LevelObject};
|
||||
use shared::{infer_actor_kind, ActorId, ActorKind, ActorName, HydratedPrefabMember, LevelObject};
|
||||
|
||||
use crate::ext::extensibility::ActorInspectorSectionRegistry;
|
||||
use crate::ui::inspector;
|
||||
use crate::ui::theme::{panel_heading, BORDER, TEXT_DIM, WIDGET_BG};
|
||||
use crate::ui::selection_ops::is_linked_read_only;
|
||||
use crate::ui::theme::{panel_heading, BORDER, SELECTION, TEXT, TEXT_DIM, WIDGET_BG};
|
||||
use crate::ui::widgets::phosphor_icon;
|
||||
|
||||
use transform::transform_inspector_ui;
|
||||
@@ -17,6 +18,8 @@ use transform::transform_inspector_ui;
|
||||
const COMPACT_ACTOR_HEADER_WIDTH: f32 = 360.0;
|
||||
|
||||
pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||
let linked_read_only = is_linked_read_only(world, entity);
|
||||
let prefab_member = world.get::<HydratedPrefabMember>(entity).is_some();
|
||||
let Some(entity_ref) = world.get_entity(entity).ok() else {
|
||||
ui.label("Entity no longer exists.");
|
||||
return;
|
||||
@@ -26,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()
|
||||
@@ -79,39 +81,71 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
|
||||
egui::ScrollArea::vertical()
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
transform_inspector_ui(world, ui, entity);
|
||||
if linked_read_only {
|
||||
ui.small(
|
||||
egui::RichText::new(if prefab_member {
|
||||
"Linked prefab member"
|
||||
} else {
|
||||
"Linked scene member"
|
||||
})
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
ui.add_space(4.0);
|
||||
}
|
||||
|
||||
match kind {
|
||||
ActorKind::StaticMesh
|
||||
| ActorKind::Brush
|
||||
| ActorKind::ImportedModel
|
||||
| ActorKind::Light
|
||||
| ActorKind::Empty
|
||||
| ActorKind::PrefabAnchor
|
||||
| ActorKind::PlayerSpawn
|
||||
| ActorKind::WeaponSpawn
|
||||
| ActorKind::TriggerVolume
|
||||
| ActorKind::PostProcessVolume
|
||||
| ActorKind::TeamSpawn
|
||||
| ActorKind::Objective => {
|
||||
inspector::authoring_inspector_ui(world, ui, entity);
|
||||
}
|
||||
}
|
||||
|
||||
world.resource_scope(|world, registry: Mut<ActorInspectorSectionRegistry>| {
|
||||
registry.draw_sections(world, ui, entity);
|
||||
if prefab_member {
|
||||
egui::ScrollArea::vertical()
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
crate::assets::prefab_overrides::prefab_member_inspector_ui(world, ui, entity);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
inspector::add_component_footer(world, ui, entity);
|
||||
});
|
||||
ui.add_enabled_ui(!linked_read_only, |ui| {
|
||||
egui::ScrollArea::vertical()
|
||||
.auto_shrink([false, false])
|
||||
.show(ui, |ui| {
|
||||
transform_inspector_ui(world, ui, entity);
|
||||
|
||||
match kind {
|
||||
ActorKind::StaticMesh
|
||||
| ActorKind::SkinnedMesh
|
||||
| ActorKind::Brush
|
||||
| ActorKind::Terrain
|
||||
| ActorKind::ImportedModel
|
||||
| ActorKind::Light
|
||||
| ActorKind::Empty
|
||||
| ActorKind::PrefabAnchor
|
||||
| ActorKind::PlayerSpawn
|
||||
| ActorKind::WeaponSpawn
|
||||
| ActorKind::TriggerVolume
|
||||
| ActorKind::PostProcessVolume
|
||||
| ActorKind::TeamSpawn
|
||||
| ActorKind::Objective
|
||||
| ActorKind::AudioSource
|
||||
| ActorKind::AudioListener
|
||||
| ActorKind::Navigation => {
|
||||
inspector::authoring_inspector_ui(world, ui, entity);
|
||||
}
|
||||
}
|
||||
|
||||
world.resource_scope(|world, registry: Mut<ActorInspectorSectionRegistry>| {
|
||||
registry.draw_sections(world, ui, entity);
|
||||
});
|
||||
|
||||
inspector::add_component_footer(world, ui, 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,
|
||||
@@ -119,14 +153,53 @@ fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
|
||||
ActorKind::TriggerVolume => icons::SELECTION,
|
||||
ActorKind::PostProcessVolume => icons::APERTURE,
|
||||
ActorKind::TeamSpawn | ActorKind::Objective => icons::FLAG,
|
||||
ActorKind::AudioSource => icons::SPEAKER_HIGH,
|
||||
ActorKind::AudioListener => icons::HEADPHONES,
|
||||
ActorKind::Navigation => icons::PATH,
|
||||
ActorKind::Empty => icons::CIRCLE,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn draw_multi_actor_inspector(world: &mut World, ui: &mut egui::Ui, entities: &[Entity]) {
|
||||
ui.heading(format!("{} objects selected", entities.len()));
|
||||
ui.label("Multi-edit: use the viewport gizmo for shared transform.");
|
||||
if entities.is_empty() {
|
||||
egui::Frame::new()
|
||||
.fill(WIDGET_BG)
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.corner_radius(egui::CornerRadius::same(4))
|
||||
.inner_margin(egui::Margin::symmetric(10, 10))
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(phosphor_icon(icons::SELECTION, 24.0).color(TEXT_DIM));
|
||||
ui.label(egui::RichText::new("No selection").color(TEXT_DIM).strong());
|
||||
});
|
||||
});
|
||||
return;
|
||||
}
|
||||
if entities.len() == 1 {
|
||||
draw_actor_inspector(world, ui, entities[0]);
|
||||
return;
|
||||
}
|
||||
|
||||
egui::Frame::new()
|
||||
.fill(WIDGET_BG)
|
||||
.stroke(egui::Stroke::new(1.0, BORDER))
|
||||
.corner_radius(egui::CornerRadius::same(4))
|
||||
.inner_margin(egui::Margin::symmetric(10, 10))
|
||||
.show(ui, |ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label(phosphor_icon(icons::SELECTION_ALL, 26.0).color(SELECTION));
|
||||
ui.vertical(|ui| {
|
||||
ui.label(
|
||||
egui::RichText::new(format!("{} objects selected", entities.len()))
|
||||
.color(TEXT)
|
||||
.strong(),
|
||||
);
|
||||
ui.label(
|
||||
egui::RichText::new("Shared transform gizmo")
|
||||
.color(TEXT_DIM)
|
||||
.small(),
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Loaded 100 of 313 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user