Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4aa61e394 | ||
|
|
0798aa5d57 | ||
|
|
0553a85220 | ||
|
|
cc1fa6ea3b |
No files matched your search
@@ -7,3 +7,6 @@ rustflags = ["-C", "link-arg=-fuse-ld=mold"]
|
|||||||
[alias]
|
[alias]
|
||||||
clean-target = "run -p xtask --bin clean-target --"
|
clean-target = "run -p xtask --bin clean-target --"
|
||||||
validate-levels = "run -p xtask --features validate-levels --bin validate-levels --"
|
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,101 @@
|
|||||||
|
# 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 source/listener/bus authoring and spatial preview passed production acceptance
|
||||||
|
in `#47`. Next: animation `#46`, navigation `#48`, source-control safety `#49`, then readiness
|
||||||
|
gate `#50`.
|
||||||
|
|
||||||
|
## 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,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,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.
|
||||||
@@ -41,34 +41,22 @@ jobs:
|
|||||||
run: rustup show
|
run: rustup show
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt --check
|
run: cargo fmt --all --check
|
||||||
|
|
||||||
- name: Check workspace
|
- name: Check workspace
|
||||||
run: cargo check --workspace
|
run: cargo check --workspace --all-targets
|
||||||
|
|
||||||
- name: Clippy
|
- name: Clippy workspace
|
||||||
run: cargo clippy --workspace
|
run: cargo clippy --workspace --all-targets -- -D warnings
|
||||||
|
|
||||||
- name: Clippy foundation crates
|
- name: Test workspace
|
||||||
run: cargo clippy -p game -p shared -- -D warnings
|
run: cargo test --workspace
|
||||||
|
|
||||||
- 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: Validate level scenes
|
- name: Validate level scenes
|
||||||
run: cargo validate-levels
|
run: cargo validate-levels
|
||||||
|
|
||||||
- name: Test scene schema crate
|
- name: Clippy launch feature matrix
|
||||||
run: cargo test -p scene
|
run: cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||||
|
|
||||||
- name: Check editor (dev)
|
|
||||||
run: cargo check -p editor --features dev
|
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
# Rust build output
|
# Rust build output
|
||||||
/target/
|
/target/
|
||||||
|
/dist/
|
||||||
|
|
||||||
# Local automation and assistant state
|
# Local automation and assistant state
|
||||||
/.agents/
|
/.agents/
|
||||||
@@ -13,6 +14,7 @@
|
|||||||
# Editor/runtime generated session state
|
# Editor/runtime generated session state
|
||||||
/assets/levels/.pie_session.scn.ron
|
/assets/levels/.pie_session.scn.ron
|
||||||
/assets/.trash/
|
/assets/.trash/
|
||||||
|
/.blacksite/backups/
|
||||||
|
|
||||||
# Backup, temporary, and log files
|
# Backup, temporary, and log files
|
||||||
**/*.rs.bk
|
**/*.rs.bk
|
||||||
|
|||||||
Vendored
+238
-35
@@ -4,48 +4,251 @@
|
|||||||
{
|
{
|
||||||
"type": "lldb",
|
"type": "lldb",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"name": "Debug editor",
|
"name": "Editor: Debug",
|
||||||
"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)",
|
|
||||||
"cargo": {
|
"cargo": {
|
||||||
"args": ["build", "--release", "-p", "editor"],
|
"args": ["build", "-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||||
"filter": { "name": "editor", "kind": "bin" }
|
"filter": { "name": "editor", "kind": "bin" },
|
||||||
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" },
|
||||||
|
"problemMatcher": "$rustc"
|
||||||
},
|
},
|
||||||
"args": [],
|
"args": [],
|
||||||
"env": {
|
"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",
|
"BEVY_FPS_HDR": "0",
|
||||||
"WGPU_VALIDATION": "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",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "cargo fmt (check)",
|
"label": "cargo fmt (workspace check)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "fmt",
|
"command": "fmt",
|
||||||
"args": ["--check"],
|
"args": ["--all", "--check"],
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "cargo check (workspace)",
|
"label": "cargo check (workspace all targets)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "check",
|
"command": "check",
|
||||||
"args": ["--workspace"],
|
"args": ["--workspace", "--all-targets"],
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "cargo clippy (workspace)",
|
"label": "cargo clippy (workspace strict)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "clippy",
|
"command": "clippy",
|
||||||
"args": ["--workspace"],
|
"args": ["--workspace", "--all-targets", "--", "-D", "warnings"],
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "cargo clippy (foundation strict)",
|
"label": "cargo test (workspace)",
|
||||||
"type": "cargo",
|
|
||||||
"command": "clippy",
|
|
||||||
"args": ["-p", "game", "-p", "shared", "--", "-D", "warnings"],
|
|
||||||
"problemMatcher": ["$rustc"],
|
|
||||||
"group": "build"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"label": "cargo test (foundation)",
|
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "test",
|
"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"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "test"
|
"group": "test"
|
||||||
},
|
},
|
||||||
@@ -45,7 +64,7 @@
|
|||||||
"label": "build game (debug)",
|
"label": "build game (debug)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "build",
|
"command": "build",
|
||||||
"args": ["-p", "game"],
|
"args": ["-p", "game", "--bin", "game"],
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
@@ -53,47 +72,50 @@
|
|||||||
"label": "build editor (debug)",
|
"label": "build editor (debug)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "build",
|
"command": "build",
|
||||||
"args": ["-p", "editor"],
|
"args": ["-p", "editor", "--bin", "editor"],
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": { "kind": "build", "isDefault": true }
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "build editor (dev fast-link)",
|
"label": "build editor (dev fast-link)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "build",
|
"command": "build",
|
||||||
"args": ["-p", "editor", "--features", "dev"],
|
"args": ["-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||||
"options": {
|
"options": {
|
||||||
"env": {
|
"cwd": "${workspaceFolder}",
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build"
|
"group": { "kind": "build", "isDefault": true }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "build game (dev fast-link)",
|
"label": "build game (dev fast-link)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "build",
|
"command": "build",
|
||||||
"args": ["-p", "game", "--features", "dev"],
|
"args": ["-p", "game", "--bin", "game", "--features", "dev"],
|
||||||
"options": {
|
"options": {
|
||||||
"env": {
|
"cwd": "${workspaceFolder}",
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "clean build editor (dev)",
|
"label": "clean dev-link crates",
|
||||||
"type": "shell",
|
"type": "cargo",
|
||||||
"command": "cargo clean -p editor && cargo build -p editor --features dev",
|
"command": "clean",
|
||||||
|
"args": ["-p", "editor", "-p", "game", "-p", "game_hot", "-p", "shared"],
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
"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"
|
"group": "build"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -102,9 +124,7 @@
|
|||||||
"command": "cargo clean-target",
|
"command": "cargo clean-target",
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
@@ -115,9 +135,7 @@
|
|||||||
"command": "cargo clean-target --apply",
|
"command": "cargo clean-target --apply",
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
@@ -128,9 +146,7 @@
|
|||||||
"command": "cargo clean-target --include-artifacts --days 3 --apply",
|
"command": "cargo clean-target --include-artifacts --days 3 --apply",
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": [],
|
"problemMatcher": [],
|
||||||
"group": "build"
|
"group": "build"
|
||||||
@@ -139,10 +155,11 @@
|
|||||||
"label": "run editor (dev fast-link)",
|
"label": "run editor (dev fast-link)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "run",
|
"command": "run",
|
||||||
"args": ["-p", "editor", "--features", "dev"],
|
"args": ["-p", "editor", "--bin", "editor", "--features", "dev"],
|
||||||
"options": {
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": {
|
||||||
"BEVY_FPS_HDR": "0",
|
"RUST_BACKTRACE": "1",
|
||||||
"WGPU_VALIDATION": "0",
|
"WGPU_VALIDATION": "0",
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
||||||
}
|
}
|
||||||
@@ -154,9 +171,83 @@
|
|||||||
"label": "run game (dev fast-link)",
|
"label": "run game (dev fast-link)",
|
||||||
"type": "cargo",
|
"type": "cargo",
|
||||||
"command": "run",
|
"command": "run",
|
||||||
"args": ["-p", "game", "--features", "dev"],
|
"args": ["-p", "game", "--bin", "game", "--features", "dev"],
|
||||||
"options": {
|
"options": {
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"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",
|
"BEVY_FPS_HDR": "0",
|
||||||
"WGPU_VALIDATION": "0",
|
"WGPU_VALIDATION": "0",
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
"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\"",
|
"command": "cargo watch -w crates/game_hot -w crates/sim -x \"build -p game_hot --features dylib\"",
|
||||||
"options": {
|
"options": {
|
||||||
"cwd": "${workspaceFolder}",
|
"cwd": "${workspaceFolder}",
|
||||||
"env": {
|
"env": { "CARGO_TARGET_DIR": "${workspaceFolder}/target" }
|
||||||
"CARGO_TARGET_DIR": "${workspaceFolder}/target"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"problemMatcher": ["$rustc"],
|
"problemMatcher": ["$rustc"],
|
||||||
"group": "build",
|
"group": "build",
|
||||||
"isBackground": true
|
"isBackground": true,
|
||||||
|
"detail": "Requires cargo-watch: cargo install cargo-watch --locked"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "verify foundation",
|
"label": "verify workspace",
|
||||||
"dependsOrder": "sequence",
|
"dependsOrder": "sequence",
|
||||||
"dependsOn": [
|
"dependsOn": [
|
||||||
"cargo fmt (check)",
|
"cargo fmt (workspace check)",
|
||||||
"cargo check (workspace)",
|
"cargo check (workspace all targets)",
|
||||||
"cargo clippy (workspace)",
|
"cargo clippy (workspace strict)",
|
||||||
"cargo clippy (foundation strict)",
|
"cargo test (workspace)",
|
||||||
"cargo test (foundation)",
|
"cargo clippy (launch feature matrix)",
|
||||||
|
"validate level scenes",
|
||||||
"build game (debug)",
|
"build game (debug)",
|
||||||
"build editor (debug)"
|
"build editor (debug)"
|
||||||
],
|
],
|
||||||
"problemMatcher": [],
|
"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]
|
[workspace]
|
||||||
members = [
|
members = [
|
||||||
|
"crates/blacksite_surface",
|
||||||
"crates/game",
|
"crates/game",
|
||||||
"crates/game_hot",
|
"crates/game_hot",
|
||||||
"crates/shared",
|
"crates/shared",
|
||||||
@@ -26,9 +27,17 @@ avian3d = { version = "0.7", default-features = false, features = [
|
|||||||
"collider-from-mesh",
|
"collider-from-mesh",
|
||||||
"serialize",
|
"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_core_pipeline = "0.19"
|
||||||
bevy_solari = "0.19"
|
bevy_solari = "0.19"
|
||||||
|
blacksite_surface = { path = "crates/blacksite_surface" }
|
||||||
bevy_ufbx = "0.18.1-rc.1"
|
bevy_ufbx = "0.18.1-rc.1"
|
||||||
bevy_egui = "0.40"
|
bevy_egui = "0.40"
|
||||||
bevy-inspector-egui = "0.37"
|
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 }
|
egui_phosphor_icons = { version = "0.3.1", default-features = false }
|
||||||
transform-gizmo-bevy = "0.9"
|
transform-gizmo-bevy = "0.9"
|
||||||
serde = { version = "1", features = ["derive"] }
|
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" }
|
shared = { path = "crates/shared" }
|
||||||
game = { path = "crates/game" }
|
game = { path = "crates/game" }
|
||||||
game_hot = { path = "crates/game_hot" }
|
game_hot = { path = "crates/game_hot" }
|
||||||
@@ -45,8 +57,12 @@ settings = { path = "crates/settings" }
|
|||||||
scene = { path = "crates/scene" }
|
scene = { path = "crates/scene" }
|
||||||
|
|
||||||
[patch.crates-io]
|
[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.
|
# Local Bevy 0.19 compatibility patch until upstream publishes a matching FBX loader.
|
||||||
bevy_ufbx = { path = "third_party/bevy_ufbx" }
|
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).
|
# Atmosphere-aware mesh view bind groups (WYSIWYG editor + transform gizmos).
|
||||||
transform-gizmo-bevy = { path = "third_party/transform-gizmo-bevy" }
|
transform-gizmo-bevy = { path = "third_party/transform-gizmo-bevy" }
|
||||||
|
|
||||||
@@ -73,3 +89,19 @@ opt-level = 3
|
|||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
codegen-units = 1
|
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
|
```bash
|
||||||
# Check everything
|
# Check everything
|
||||||
cargo fmt --check
|
cargo fmt --all --check
|
||||||
cargo check --workspace
|
cargo check --workspace --all-targets
|
||||||
cargo clippy --workspace
|
cargo clippy --workspace --all-targets -- -D warnings
|
||||||
cargo clippy -p game -p shared -p protocol -p sim -- -D warnings
|
cargo clippy -p editor -p game --bins --features dev,hot-reload -- -D warnings
|
||||||
cargo test -p game --lib
|
cargo test --workspace
|
||||||
cargo test -p sim
|
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
|
# Runtime game
|
||||||
cargo run -p game
|
cargo run -p game
|
||||||
@@ -37,6 +43,22 @@ cargo run -p editor
|
|||||||
cargo run -p editor --features dev
|
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)
|
### Hot reload (gameplay iteration)
|
||||||
|
|
||||||
`--features dev` turns on Bevy **dynamic linking** for faster rebuilds (recommended day-to-day).
|
`--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
|
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 |
|
| 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
|
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
|
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
|
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.
|
deep-stale variants.
|
||||||
|
|
||||||
### Launch Troubleshooting
|
### 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.
|
- 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.
|
- 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.
|
- 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.
|
- 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 && 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.
|
- 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
|
## Editor Controls
|
||||||
|
|
||||||
@@ -115,27 +137,36 @@ deep-stale variants.
|
|||||||
| `Ctrl+D` | Duplicate selection |
|
| `Ctrl+D` | Duplicate selection |
|
||||||
| `Ctrl+Z` / `Ctrl+Shift+Z` / `Ctrl+Y` | Undo / redo |
|
| `Ctrl+Z` / `Ctrl+Shift+Z` / `Ctrl+Y` | Undo / redo |
|
||||||
| `F2` in Hierarchy | Rename selection |
|
| `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 |
|
| `X` | Toggle world/local gizmo orientation |
|
||||||
| `B` | Enter Draw Brush mode |
|
| `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 |
|
| 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 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 |
|
| 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 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 |
|
| `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`) |
|
| 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 |
|
| 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/` |
|
| Asset Browser context/details actions | Apply textures/materials, regenerate thumbnails, reimport models, place assets/submeshes, or move file assets to `assets/.trash/` |
|
||||||
|
| 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 |
|
| `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 |
|
| `F7` | While paused in Play: advance one sim tick |
|
||||||
| Shift/Ctrl + click (Hierarchy) | Additive selection |
|
| Shift/Ctrl + click (Hierarchy) | Additive selection |
|
||||||
| Hierarchy context | Reparent to other selection / Unparent |
|
| Drag actor row onto another actor (Hierarchy) | Attach/reparent while preserving world placement; multi-selection keeps existing subtrees and commits one undo step |
|
||||||
| File menu | New, Open, Save, Save As, Import Assets, Export Selection, Save Selection As Prefab, Recent Scenes |
|
| Drag actor between rows / onto Scene Root (Hierarchy, Manual sort) | Reorder siblings / unparent to the root |
|
||||||
|
| Hierarchy lock | Excludes the actor from selection, gizmos, multi-drag, structural drops, and mutating context actions |
|
||||||
|
| Hierarchy context | Group selection, create authored local children below linked prefab roots, remove/reparent generated members through same-layer structural overrides, or unparent |
|
||||||
|
| File menu | New, Open, transactional Save/Save As, recovery restore/keep-copy/discard when available, Import Assets, Export Selection, Save Selection As Prefab (including linked-root variants), Recent Scenes |
|
||||||
|
| 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 component card | Collapse with caret, toggle active with status dot, or use triple-dot menu for reset/copy/paste/move/remove actions |
|
||||||
| Inspector footer → Add Component | Expands an inline search shelf for registered authoring, rendering, physics, gameplay, and volume components with descriptions, availability hints, and undo |
|
| Inspector footer → Add Component | 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) |
|
| 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.
|
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 +206,18 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
|
|||||||
## Scene Workflow
|
## Scene Workflow
|
||||||
|
|
||||||
- Levels are saved as native Bevy dynamic scenes under `assets/levels/`.
|
- 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`.
|
- 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
|
- The editable player start is an authored `PlayerSpawn`; moving it with the transform gizmo changes
|
||||||
where Play mode boots the runtime player.
|
where Play mode boots the runtime player.
|
||||||
- Project settings provide default ambient/sun lighting. A scene-authored directional `LightDesc`
|
- Project settings provide default ambient/sun lighting. A scene-authored directional `LightDesc`
|
||||||
@@ -189,9 +231,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
|
artifacts in `assets/meshes/generated/`. Renderer slots reference imported content-browser mesh
|
||||||
and material assets, while generated collision is stored separately in `ColliderDesc` plus
|
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
|
`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
|
details when you need full `WorldAssetRoot` scene data instead of normalized static slots.
|
||||||
model in the Asset Browser exposes normalized mesh/material/texture subassets; dragging a mesh
|
Expanding a model in the Asset Browser exposes normalized mesh/material/texture plus generated
|
||||||
subasset places that part through the same static mesh renderer path.
|
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
|
- 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,
|
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
|
face material/UV fields are undoable, and clip/intersect/merge/subtract provide conservative
|
||||||
@@ -229,7 +287,41 @@ Viewport shortcut keys require the pointer to be in the viewport and are suspend
|
|||||||
|
|
||||||
### Hierarchy scrolls during drag
|
### 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.
|
||||||
|
|
||||||
## Cursor / VSCode Setup
|
## Cursor / VSCode Setup
|
||||||
|
|
||||||
@@ -238,8 +330,8 @@ The `.vscode/` folder is preconfigured:
|
|||||||
- `extensions.json` recommends rust-analyzer, Even Better TOML, CodeLLDB, crates, and Error Lens.
|
- `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,
|
- `settings.json` runs `clippy` on save, enables proc-macro/build-script support, formats on save,
|
||||||
and excludes `target/` from search/watch.
|
and excludes `target/` from search/watch.
|
||||||
- `tasks.json` provides workspace check/clippy plus game/editor build/run tasks.
|
- `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` provides CodeLLDB launch configs for the editor and game.
|
- `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.
|
- `.github/workflows/ci.yml` mirrors local formatting, check, clippy, test, and binary build verification.
|
||||||
|
|
||||||
## Architecture Decisions
|
## Architecture Decisions
|
||||||
@@ -253,6 +345,7 @@ The `.vscode/` folder is preconfigured:
|
|||||||
- [ADR 0014: Unified Viewport Model](docs/adr/0014-unified-viewport-model.md)
|
- [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 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 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)
|
||||||
|
|
||||||
## Project Layout
|
## Project Layout
|
||||||
|
|
||||||
@@ -292,30 +385,44 @@ crates/
|
|||||||
- [x] CI workflow for format, check, clippy, tests, and binary builds
|
- [x] CI workflow for format, check, clippy, tests, and binary builds
|
||||||
- [x] ADRs for roadmap architecture and Bevy migration policy
|
- [x] ADRs for roadmap architecture and Bevy migration policy
|
||||||
- [x] Determinism harness: same inputs over same ticks produce the same state summary/hash
|
- [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] 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] 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] 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] Prefab instances (`PrefabInstance`) + save-as-prefab + unpack
|
- [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] 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] Gameplay authoring markers + visualizers (`WeaponSpawn`, `TriggerVolume`, etc.)
|
||||||
- [x] Command palette execution; PIE sim step (F7); `xtask validate-levels`
|
- [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] 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] `ActorInspectorSection` registry + game demo section (`game::editor_ext`)
|
||||||
- [x] Command palette: reset lighting, group selection, focus selection
|
- [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] 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)
|
- [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] 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] Asset browser model thumbnails (unified `assets/thumbnails/` pipeline; `ThumbnailState` cache; FBX via `FbxThumbnailSource`)
|
||||||
- [x] Material assets (`assets/materials/*.ron`, inspector picker, drag-drop to selection)
|
- [x] Shared Material/Material Instance assets, stable static/skinned renderer material slots, imported-source fallback, orphan preservation, and 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] Prefab instance overrides v2 (transform/material/child visibility apply-revert groups)
|
- [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] 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] 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] 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 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] 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
|
- [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 +435,27 @@ crates/
|
|||||||
untextured models), material sphere thumbnails, search/filter/sort controls, expandable model
|
untextured models), material sphere thumbnails, search/filter/sort controls, expandable model
|
||||||
subasset shelves, and a staged details pane. **File → Import Assets**
|
subasset shelves, and a staged details pane. **File → Import Assets**
|
||||||
accepts glTF/GLB and **FBX** (binary; copies sibling `.fbm` texture folders when present).
|
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
|
Model assets generate normalized model manifests under `assets/meshes/generated/`; drag/drop uses
|
||||||
uses `StaticMeshRenderer` by default with imported asset refs and optional separate static mesh
|
**Renderable Asset (Auto)**. Unrigged sources use `StaticMeshRenderer` with imported asset refs
|
||||||
collider components. Expanded mesh subassets generate independent thumbnails and can be placed independently. Asset details can switch
|
and optional separate static mesh colliders. Skin-bound or animated sources and their subasset placement use
|
||||||
placement to **Scene Instance** for `ModelRef`/`WorldAssetRoot` playback, shared material assets can be
|
`SkinnedMeshRenderer`, preserve the source joint hierarchy, and never create static slots or
|
||||||
edited from the browser, and delete actions move files to `assets/.trash/`. Skeletal animation
|
automatic triangle colliders. Expanded mesh subassets generate independent thumbnails. Asset details can switch
|
||||||
playback is not supported by the static mesh path yet.
|
placement to **Scene Instance** for generic `ModelRef`/`WorldAssetRoot` scenes, shared material assets can be
|
||||||
- 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.
|
edited from the browser, and delete actions move files to `assets/.trash/`. Animation authoring
|
||||||
- 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.
|
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/`. In the Asset Browser, select a Material and use **Create Instance** for sparse inherited variants. Static and skinned renderers own stable per-draw material slots, with explicit assignments taking precedence over imported source defaults; 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.
|
- 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,
|
- 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.
|
material graphs, lighting profiles) can be added without changing the scene format foundation.
|
||||||
|
|||||||
+366
-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"),
|
id: ("31963299-d4c1-45dc-8f67-2f469ca1ad6d"),
|
||||||
path: "assets/post_fx/chromatic_aberration.ron",
|
path: "assets/post_fx/chromatic_aberration.ron",
|
||||||
@@ -12,6 +48,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -28,6 +66,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -44,29 +84,46 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: Some("assets/meshes/generated/b98ef565-3500-49e7-9935-f685fa9b2594.static_mesh.ron"),
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
id: ("71071fc3-7a7f-454d-b9ab-93ebf0feccbe"),
|
id: ("113f74df-e39c-41d4-9b5b-e48efe541f7f"),
|
||||||
path: "assets/models/metal_stool_01_2k.gltf",
|
path: "assets/models/RobotExpressive.glb",
|
||||||
label: "metal_stool_01_2k",
|
label: "RobotExpressive",
|
||||||
kind_tag: "Model",
|
kind_tag: "Model",
|
||||||
import_settings: (
|
import_settings: (
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
generate_collider: true,
|
generate_collider: true,
|
||||||
lod0_only: true,
|
lod0_only: true,
|
||||||
placement_mode: SceneInstance,
|
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,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
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: [
|
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",
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
id: ("c4abe41c-ac88-4aec-8168-27e8a7c90583"),
|
id: ("c4abe41c-ac88-4aec-8168-27e8a7c90583"),
|
||||||
@@ -81,6 +138,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -97,6 +156,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -113,6 +174,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -120,7 +183,7 @@
|
|||||||
id: ("61802b85-fda9-4aff-94d9-fe5f0860c516"),
|
id: ("61802b85-fda9-4aff-94d9-fe5f0860c516"),
|
||||||
path: "assets/levels/rendering_showcase.scn.ron",
|
path: "assets/levels/rendering_showcase.scn.ron",
|
||||||
label: "rendering_showcase.scn",
|
label: "rendering_showcase.scn",
|
||||||
kind_tag: "Prefab",
|
kind_tag: "Level",
|
||||||
import_settings: (
|
import_settings: (
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
generate_collider: true,
|
generate_collider: true,
|
||||||
@@ -129,6 +192,26 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -136,7 +219,7 @@
|
|||||||
id: ("48bcef13-e6a6-4260-bb1b-c29787bd8c70"),
|
id: ("48bcef13-e6a6-4260-bb1b-c29787bd8c70"),
|
||||||
path: "assets/levels/editor_scene 3.scn.ron",
|
path: "assets/levels/editor_scene 3.scn.ron",
|
||||||
label: "editor_scene 3.scn",
|
label: "editor_scene 3.scn",
|
||||||
kind_tag: "Prefab",
|
kind_tag: "Level",
|
||||||
import_settings: (
|
import_settings: (
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
generate_collider: true,
|
generate_collider: true,
|
||||||
@@ -145,6 +228,26 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -152,7 +255,7 @@
|
|||||||
id: ("5a2307d0-48e5-40d3-a5c9-527c0cfd30f4"),
|
id: ("5a2307d0-48e5-40d3-a5c9-527c0cfd30f4"),
|
||||||
path: "assets/levels/editor_scene.scn.ron",
|
path: "assets/levels/editor_scene.scn.ron",
|
||||||
label: "editor_scene.scn",
|
label: "editor_scene.scn",
|
||||||
kind_tag: "Prefab",
|
kind_tag: "Level",
|
||||||
import_settings: (
|
import_settings: (
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
generate_collider: true,
|
generate_collider: true,
|
||||||
@@ -161,6 +264,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -168,6 +273,24 @@
|
|||||||
id: ("dc13ce01-c7ce-43c5-974c-0e659ae49ab9"),
|
id: ("dc13ce01-c7ce-43c5-974c-0e659ae49ab9"),
|
||||||
path: "assets/levels/editor_scene 2.scn.ron",
|
path: "assets/levels/editor_scene 2.scn.ron",
|
||||||
label: "editor_scene 2.scn",
|
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",
|
kind_tag: "Prefab",
|
||||||
import_settings: (
|
import_settings: (
|
||||||
scale: 1.0,
|
scale: 1.0,
|
||||||
@@ -177,6 +300,98 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -193,6 +408,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -209,6 +426,26 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -225,6 +462,26 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -241,6 +498,80 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -257,6 +588,8 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
),
|
),
|
||||||
dependencies: [],
|
dependencies: [],
|
||||||
),
|
),
|
||||||
@@ -273,6 +606,26 @@
|
|||||||
hierarchy_mode: SingleActor,
|
hierarchy_mode: SingleActor,
|
||||||
material_policy: SourceMaterials,
|
material_policy: SourceMaterials,
|
||||||
static_mesh_manifest_path: None,
|
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: [],
|
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,
|
(schema_version: 4,resources: {
|
||||||
resources: {},
|
},
|
||||||
entities: {
|
entities: {
|
||||||
4294968001: (
|
4294968001: (components: {
|
||||||
components: {
|
"bevy_ecs::name::Name": "Fog Volume",
|
||||||
"bevy_ecs::name::Name": "Fog Volume",
|
"bevy_transform::components::transform::Transform": (
|
||||||
"bevy_transform::components::transform::Transform": (
|
|
||||||
translation: (0.0, 2.0, 0.0),
|
translation: (0.0, 2.0, 0.0),
|
||||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||||
scale: (1.0, 1.0, 1.0),
|
scale: (1.0, 1.0, 1.0),
|
||||||
),
|
),
|
||||||
"shared::components::LevelObject": (),
|
"shared::components::ActorKind": PostProcessVolume,
|
||||||
"shared::components::ActorKind": PostProcessVolume,
|
"shared::components::LevelObject": (),
|
||||||
"shared::components::PostProcessVolumeDesc": (
|
"shared::components::PostProcessVolumeDesc": (
|
||||||
half_extents: (6.0, 3.0, 6.0),
|
half_extents: (6.0, 3.0, 6.0),
|
||||||
priority: 0,
|
priority: 0,
|
||||||
blend_distance: 2.0,
|
blend_distance: 2.0,
|
||||||
@@ -23,19 +22,17 @@
|
|||||||
profile: None,
|
profile: None,
|
||||||
label: Some("Foggy courtyard"),
|
label: Some("Foggy courtyard"),
|
||||||
),
|
),
|
||||||
},
|
}),
|
||||||
),
|
4294968002: (components: {
|
||||||
4294968002: (
|
"bevy_ecs::name::Name": "Dark Exposure Volume",
|
||||||
components: {
|
"bevy_transform::components::transform::Transform": (
|
||||||
"bevy_ecs::name::Name": "Dark Exposure Volume",
|
|
||||||
"bevy_transform::components::transform::Transform": (
|
|
||||||
translation: (14.0, 2.0, 0.0),
|
translation: (14.0, 2.0, 0.0),
|
||||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||||
scale: (1.0, 1.0, 1.0),
|
scale: (1.0, 1.0, 1.0),
|
||||||
),
|
),
|
||||||
"shared::components::LevelObject": (),
|
"shared::components::ActorKind": PostProcessVolume,
|
||||||
"shared::components::ActorKind": PostProcessVolume,
|
"shared::components::LevelObject": (),
|
||||||
"shared::components::PostProcessVolumeDesc": (
|
"shared::components::PostProcessVolumeDesc": (
|
||||||
half_extents: (4.0, 2.5, 4.0),
|
half_extents: (4.0, 2.5, 4.0),
|
||||||
priority: 5,
|
priority: 5,
|
||||||
blend_distance: 1.5,
|
blend_distance: 1.5,
|
||||||
@@ -47,19 +44,17 @@
|
|||||||
profile: Some("assets/rendering_profiles/cave_dark.ron"),
|
profile: Some("assets/rendering_profiles/cave_dark.ron"),
|
||||||
label: Some("Cave mouth"),
|
label: Some("Cave mouth"),
|
||||||
),
|
),
|
||||||
},
|
}),
|
||||||
),
|
4294968003: (components: {
|
||||||
4294968003: (
|
"bevy_ecs::name::Name": "Vignette FX Volume",
|
||||||
components: {
|
"bevy_transform::components::transform::Transform": (
|
||||||
"bevy_ecs::name::Name": "Vignette FX Volume",
|
|
||||||
"bevy_transform::components::transform::Transform": (
|
|
||||||
translation: (-12.0, 2.0, 0.0),
|
translation: (-12.0, 2.0, 0.0),
|
||||||
rotation: (0.0, 0.0, 0.0, 1.0),
|
rotation: (0.0, 0.0, 0.0, 1.0),
|
||||||
scale: (1.0, 1.0, 1.0),
|
scale: (1.0, 1.0, 1.0),
|
||||||
),
|
),
|
||||||
"shared::components::LevelObject": (),
|
"shared::components::ActorKind": PostProcessVolume,
|
||||||
"shared::components::ActorKind": PostProcessVolume,
|
"shared::components::LevelObject": (),
|
||||||
"shared::components::PostProcessVolumeDesc": (
|
"shared::components::PostProcessVolumeDesc": (
|
||||||
half_extents: (5.0, 2.0, 5.0),
|
half_extents: (5.0, 2.0, 5.0),
|
||||||
priority: 2,
|
priority: 2,
|
||||||
blend_distance: 2.0,
|
blend_distance: 2.0,
|
||||||
@@ -68,7 +63,6 @@
|
|||||||
profile: None,
|
profile: None,
|
||||||
label: Some("Vignette demo"),
|
label: Some("Vignette demo"),
|
||||||
),
|
),
|
||||||
},
|
}),
|
||||||
),
|
},
|
||||||
},
|
|
||||||
)
|
)
|
||||||
@@ -1,12 +1,40 @@
|
|||||||
(
|
(
|
||||||
|
schema_version: 1,
|
||||||
label: "Concrete",
|
label: "Concrete",
|
||||||
|
shader: None,
|
||||||
|
shader_ref: None,
|
||||||
|
render_state: (
|
||||||
|
alpha_mode: Opaque,
|
||||||
|
alpha_cutoff: 0.5,
|
||||||
|
double_sided: false,
|
||||||
|
),
|
||||||
material: (
|
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,
|
metallic: 0.0,
|
||||||
roughness: 0.85,
|
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,
|
base_color_texture: None,
|
||||||
|
emissive_texture: None,
|
||||||
normal_map_texture: None,
|
normal_map_texture: None,
|
||||||
metallic_roughness_texture: None,
|
metallic_roughness_texture: None,
|
||||||
material_asset_path: None,
|
material_asset_path: None,
|
||||||
|
parameters: [],
|
||||||
|
textures: [],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
@@ -1,15 +1,40 @@
|
|||||||
(
|
(
|
||||||
|
schema_version: 1,
|
||||||
label: "Emissive Panel",
|
label: "Emissive Panel",
|
||||||
|
shader: None,
|
||||||
|
shader_ref: None,
|
||||||
|
render_state: (
|
||||||
|
alpha_mode: Opaque,
|
||||||
|
alpha_cutoff: 0.5,
|
||||||
|
double_sided: false,
|
||||||
|
),
|
||||||
material: (
|
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,
|
metallic: 0.0,
|
||||||
roughness: 0.35,
|
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,
|
emissive_intensity: 2500.0,
|
||||||
base_color_texture: None,
|
base_color_texture: None,
|
||||||
emissive_texture: None,
|
emissive_texture: None,
|
||||||
normal_map_texture: None,
|
normal_map_texture: None,
|
||||||
metallic_roughness_texture: None,
|
metallic_roughness_texture: None,
|
||||||
material_asset_path: 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",
|
asset_id: "b98ef565-3500-49e7-9935-f685fa9b2594",
|
||||||
label: "painted_wooden_chair_02_2k",
|
label: "painted_wooden_chair_02_2k",
|
||||||
source: (
|
source: (
|
||||||
@@ -30,7 +30,7 @@
|
|||||||
),
|
),
|
||||||
parts: [
|
parts: [
|
||||||
(
|
(
|
||||||
id: "mesh:mesh1000",
|
id: "draw:scene0:node1:material0",
|
||||||
name: "painted_wooden_chair_02 / Material 0",
|
name: "painted_wooden_chair_02 / Material 0",
|
||||||
mesh_label: "Mesh1000",
|
mesh_label: "Mesh1000",
|
||||||
material_id: Some("material:material0"),
|
material_id: Some("material:material0"),
|
||||||
@@ -44,6 +44,7 @@
|
|||||||
source_node: Some("Node1"),
|
source_node: Some("Node1"),
|
||||||
source_mesh: Some("Mesh1"),
|
source_mesh: Some("Mesh1"),
|
||||||
source_material: Some("painted_wooden_chair_02"),
|
source_material: Some("painted_wooden_chair_02"),
|
||||||
|
skinned: false,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
warnings: [],
|
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,
|
version: 1,
|
||||||
|
project_id: "blacksite-foundation",
|
||||||
name: "Bevy FPS 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",
|
default_level: "assets/levels/editor_scene.scn.ron",
|
||||||
asset_roots: [
|
asset_roots: [
|
||||||
|
"assets/audio",
|
||||||
"assets/models",
|
"assets/models",
|
||||||
"assets/textures",
|
"assets/textures",
|
||||||
"assets/materials",
|
"assets/materials",
|
||||||
@@ -29,6 +34,31 @@
|
|||||||
shadow_first_cascade: 6.0,
|
shadow_first_cascade: 6.0,
|
||||||
shadow_max_distance: 220.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: (
|
physics: (
|
||||||
player_radius: 0.4,
|
player_radius: 0.4,
|
||||||
player_length: 1.0,
|
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,17 +1,72 @@
|
|||||||
(
|
(
|
||||||
|
schema_version: 1,
|
||||||
label: "Standard Lit",
|
label: "Standard Lit",
|
||||||
kind: StandardLit,
|
kind: StandardLit,
|
||||||
wgsl_path: None,
|
wgsl_path: None,
|
||||||
parameters: [
|
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: "base_color",
|
||||||
(name: "roughness", display_name: "Roughness", group: "Surface", property_type: Float(min: Some(0.0), max: Some(1.0))),
|
display_name: "Base Color",
|
||||||
(name: "emissive_color", display_name: "Emissive Color", group: "Emission", property_type: Color),
|
group: "Surface",
|
||||||
(name: "emissive_intensity", display_name: "Emissive Nits", group: "Emission", property_type: Float(min: Some(0.0), max: Some(20000.0))),
|
property_type: Color,
|
||||||
(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: "metallic",
|
||||||
(name: "emissive_texture", display_name: "Emissive Texture", group: "Textures", property_type: Texture),
|
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_values: [],
|
||||||
default_textures: [],
|
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,12 +1,36 @@
|
|||||||
(
|
(
|
||||||
|
schema_version: 1,
|
||||||
label: "Unlit",
|
label: "Unlit",
|
||||||
kind: Unlit,
|
kind: Unlit,
|
||||||
wgsl_path: None,
|
wgsl_path: None,
|
||||||
parameters: [
|
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: "base_color",
|
||||||
(name: "emissive_color", display_name: "Emissive Color", group: "Emission", property_type: Color),
|
display_name: "Base Color",
|
||||||
(name: "emissive_intensity", display_name: "Emissive Nits", group: "Emission", property_type: Float(min: Some(0.0), max: Some(20000.0))),
|
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_values: [],
|
||||||
default_textures: [],
|
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
|
edition.workspace = true
|
||||||
license.workspace = true
|
license.workspace = true
|
||||||
description = "In-process level editor for the Bevy FPS foundation"
|
description = "In-process level editor for the Bevy FPS foundation"
|
||||||
|
default-run = "editor"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
name = "editor"
|
name = "editor"
|
||||||
@@ -13,6 +14,10 @@ path = "src/lib.rs"
|
|||||||
name = "editor"
|
name = "editor"
|
||||||
path = "src/bin/main.rs"
|
path = "src/bin/main.rs"
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "project_launcher"
|
||||||
|
path = "src/bin/project_launcher.rs"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
dev = ["bevy/dynamic_linking", "game/dev"]
|
dev = ["bevy/dynamic_linking", "game/dev"]
|
||||||
hot-reload = ["game/hot-reload", "dep:hot-lib-reloader", "dep:notify"]
|
hot-reload = ["game/hot-reload", "dep:hot-lib-reloader", "dep:notify"]
|
||||||
@@ -28,6 +33,7 @@ egui_phosphor_icons.workspace = true
|
|||||||
bevy_ufbx.workspace = true
|
bevy_ufbx.workspace = true
|
||||||
ufbx = "0.9"
|
ufbx = "0.9"
|
||||||
game.workspace = true
|
game.workspace = true
|
||||||
|
polyanya.workspace = true
|
||||||
game_hot.workspace = true
|
game_hot.workspace = true
|
||||||
hot-lib-reloader = { version = "0.8.2", optional = true }
|
hot-lib-reloader = { version = "0.8.2", optional = true }
|
||||||
notify = { version = "6.1", optional = true }
|
notify = { version = "6.1", optional = true }
|
||||||
@@ -37,9 +43,11 @@ sim.workspace = true
|
|||||||
settings.workspace = true
|
settings.workspace = true
|
||||||
scene.workspace = true
|
scene.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
|
serde_json = "1"
|
||||||
transform-gizmo-bevy.workspace = true
|
transform-gizmo-bevy.workspace = true
|
||||||
rfd = "0.17.2"
|
rfd = "0.17.2"
|
||||||
ron = "0.8"
|
ron = "0.8"
|
||||||
uuid = { version = "1", features = ["v4", "serde"] }
|
uuid = { version = "1", features = ["v4", "serde"] }
|
||||||
walkdir = "2.5"
|
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 bevy::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::{HashMap, HashSet};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
/// Stable asset identity for dependency tracking and prefab references.
|
/// 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)]
|
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub enum ModelPlacementMode {
|
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]
|
#[default]
|
||||||
StaticAsset,
|
StaticAsset,
|
||||||
|
/// Instantiate the complete source scene as a generic imported model.
|
||||||
SceneInstance,
|
SceneInstance,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +63,12 @@ pub struct ImportSettings {
|
|||||||
pub material_policy: MaterialImportPolicy,
|
pub material_policy: MaterialImportPolicy,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub static_mesh_manifest_path: Option<String>,
|
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 {
|
impl Default for ImportSettings {
|
||||||
@@ -71,6 +81,8 @@ impl Default for ImportSettings {
|
|||||||
hierarchy_mode: ModelHierarchyMode::default(),
|
hierarchy_mode: ModelHierarchyMode::default(),
|
||||||
material_policy: MaterialImportPolicy::default(),
|
material_policy: MaterialImportPolicy::default(),
|
||||||
static_mesh_manifest_path: None,
|
static_mesh_manifest_path: None,
|
||||||
|
animation_manifest_path: None,
|
||||||
|
default_animation_clip_id: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,6 +127,11 @@ fn sync_registry_from_browser(
|
|||||||
.drain(..)
|
.drain(..)
|
||||||
.map(|record| (record.path.clone(), record))
|
.map(|record| (record.path.clone(), record))
|
||||||
.collect();
|
.collect();
|
||||||
|
let current_paths = assets
|
||||||
|
.assets
|
||||||
|
.iter()
|
||||||
|
.filter_map(|asset| asset.path.clone())
|
||||||
|
.collect::<HashSet<_>>();
|
||||||
|
|
||||||
let mut next_records = Vec::new();
|
let mut next_records = Vec::new();
|
||||||
let mut seen_paths = HashMap::new();
|
let mut seen_paths = HashMap::new();
|
||||||
@@ -129,7 +146,18 @@ fn sync_registry_from_browser(
|
|||||||
seen_paths.insert(path.clone(), ());
|
seen_paths.insert(path.clone(), ());
|
||||||
|
|
||||||
let kind_tag = format!("{:?}", asset.kind);
|
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.label = asset.label.clone();
|
||||||
prior.kind_tag = kind_tag;
|
prior.kind_tag = kind_tag;
|
||||||
prior
|
prior
|
||||||
@@ -144,9 +172,9 @@ fn sync_registry_from_browser(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
if record.kind_tag == "Model" {
|
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!(
|
warn!(
|
||||||
"Static mesh processor failed for {} (asset id {}): {error}",
|
"Model artifact refresh failed for {} (asset id {}): {error}",
|
||||||
record.path,
|
record.path,
|
||||||
record.id.as_string()
|
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> {
|
pub fn find_asset_by_path(registry: &AssetRegistry, path: &str) -> Option<AssetRecord> {
|
||||||
registry
|
registry
|
||||||
.records
|
.records
|
||||||
@@ -196,6 +252,34 @@ pub fn find_asset_mut_by_path<'a>(
|
|||||||
.find(|record| record.path == path)
|
.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(
|
pub fn update_import_settings(
|
||||||
registry: &mut AssetRegistry,
|
registry: &mut AssetRegistry,
|
||||||
path: &str,
|
path: &str,
|
||||||
@@ -240,3 +324,99 @@ pub fn load_registry() -> AssetRegistry {
|
|||||||
Err(_) => AssetRegistry::default(),
|
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::prelude::*;
|
||||||
use bevy_egui::egui;
|
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::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;
|
use crate::ui::inspector::property_row;
|
||||||
|
|
||||||
pub fn load_material_asset(catalog_path: &str) -> Result<MaterialAsset, String> {
|
pub fn load_material_asset(catalog_path: &str) -> Result<MaterialAsset, String> {
|
||||||
@@ -23,28 +26,108 @@ pub fn apply_material_asset_to_selection(
|
|||||||
world: &mut World,
|
world: &mut World,
|
||||||
asset: &EditorAsset,
|
asset: &EditorAsset,
|
||||||
selected: &bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities,
|
selected: &bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities,
|
||||||
) {
|
) -> Result<(), String> {
|
||||||
let Some(path) = asset.path.clone() else {
|
let path = asset
|
||||||
return;
|
.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) {
|
let material_ref = MaterialRef::new(
|
||||||
Ok(desc) => desc,
|
shared::EditorAssetRef::new(record.id.as_string(), sub_asset_id, asset.label.clone())
|
||||||
Err(err) => {
|
.with_source_path(path.clone()),
|
||||||
world.resource_mut::<crate::scene_io::SceneIo>().status = err;
|
);
|
||||||
return;
|
let desc = material_desc_from_asset(&path).ok();
|
||||||
}
|
let entities = crate::ui::helpers::selected_level_entities(world, selected);
|
||||||
};
|
let mut renderer_changes = 0usize;
|
||||||
for entity in crate::ui::helpers::selected_level_entities(world, selected) {
|
let mut legacy_changes = Vec::new();
|
||||||
|
for entity in entities {
|
||||||
if world.get::<LevelObject>(entity).is_none() {
|
if world.get::<LevelObject>(entity).is_none() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if world.get::<MaterialDesc>(entity).is_none() {
|
if let Some(mut renderer) = world.get::<shared::StaticMeshRenderer>(entity).cloned() {
|
||||||
world.entity_mut(entity).insert(desc.clone());
|
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 =
|
world.resource_mut::<crate::scene_io::SceneIo>().status =
|
||||||
format!("Applied material {}", asset.label);
|
format!("Applied shared material {}", asset.label);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
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(
|
pub fn material_asset_picker_ui(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//! Asset catalog, database, thumbnails, materials, and prefab overrides.
|
//! Asset catalog, database, thumbnails, materials, and prefab overrides.
|
||||||
|
|
||||||
|
pub mod animation;
|
||||||
pub mod asset_db;
|
pub mod asset_db;
|
||||||
mod catalog;
|
mod catalog;
|
||||||
mod import;
|
mod import;
|
||||||
@@ -11,6 +12,25 @@ pub mod thumbnails;
|
|||||||
|
|
||||||
pub use catalog::*;
|
pub use catalog::*;
|
||||||
pub use thumbnails::{
|
pub use thumbnails::{
|
||||||
draw_asset_cell_with, invalidate_on_catalog_refresh, kind_icon, prefetch_folder_thumbnails,
|
draw_asset_cell_with, gltf_skinned_primitive_labels, invalidate_on_catalog_refresh, kind_icon,
|
||||||
AssetThumbnailCache, ThumbnailCacheSnapshot, ThumbnailState, ThumbnailStudio, ThumbnailsPlugin,
|
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,
|
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 {
|
fn selection_availability(world: &World, selected: &SelectedEntities) -> OperatorAvailability {
|
||||||
if selected_level_entities(world, selected).is_empty() {
|
if selected_level_entities(world, selected).is_empty() {
|
||||||
@@ -26,6 +30,7 @@ pub fn place_asset_operator(world: &mut World, asset: EditorAsset, translation:
|
|||||||
&label,
|
&label,
|
||||||
OperatorAvailability::Ready,
|
OperatorAvailability::Ready,
|
||||||
move |world| {
|
move |world| {
|
||||||
|
validate_prefab_asset(world, &asset)?;
|
||||||
spawn_asset_at(world, &asset, translation)
|
spawn_asset_at(world, &asset, translation)
|
||||||
.map(|_| ())
|
.map(|_| ())
|
||||||
.ok_or_else(|| format!("Asset cannot be placed: {}", asset.label))
|
.ok_or_else(|| format!("Asset cannot be placed: {}", asset.label))
|
||||||
@@ -64,10 +69,7 @@ pub fn apply_texture_operator(
|
|||||||
"assets.apply_texture",
|
"assets.apply_texture",
|
||||||
&label,
|
&label,
|
||||||
availability,
|
availability,
|
||||||
move |world| {
|
move |world| apply_texture_to_selection(world, &asset, selected),
|
||||||
apply_texture_to_selection(world, &asset, selected);
|
|
||||||
Ok(())
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,9 +85,452 @@ pub fn apply_material_operator(
|
|||||||
"assets.apply_material",
|
"assets.apply_material",
|
||||||
&label,
|
&label,
|
||||||
availability,
|
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| {
|
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(())
|
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::{
|
use crate::asset_db::{
|
||||||
AssetRecord, ImportSettings, MaterialImportPolicy, ModelHierarchyMode, ModelPlacementMode,
|
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";
|
pub const STATIC_MESH_ARTIFACT_DIR: &str = "assets/meshes/generated";
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||||
@@ -80,6 +83,10 @@ pub struct StaticMeshPart {
|
|||||||
pub source_node: Option<String>,
|
pub source_node: Option<String>,
|
||||||
pub source_mesh: Option<String>,
|
pub source_mesh: Option<String>,
|
||||||
pub source_material: 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 {
|
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))
|
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 {
|
fn stable_sub_asset_slug(label: &str) -> String {
|
||||||
let mut slug = String::new();
|
let mut slug = String::new();
|
||||||
for ch in label.chars() {
|
for ch in label.chars() {
|
||||||
@@ -151,38 +169,106 @@ pub fn renderer_from_manifest(
|
|||||||
MaterialImportPolicy::SourceMaterials
|
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
|
slots: manifest
|
||||||
.parts
|
.parts
|
||||||
.iter()
|
.iter()
|
||||||
.map(|part| StaticMeshRendererEntry {
|
.filter(|part| !part.skinned && manifest.metadata.animation_count == 0)
|
||||||
id: ComponentInstanceId::new(part_effective_id(part)),
|
.map(|part| RendererMaterialSlot {
|
||||||
name: part.name.clone(),
|
id: ComponentInstanceId::new(material_slot_id(part)),
|
||||||
mesh: EditorAssetRef::new(
|
name: part.material_slot_name.clone(),
|
||||||
manifest.asset_id.clone(),
|
source_material: use_source_materials
|
||||||
part_effective_id(part),
|
|
||||||
part.name.clone(),
|
|
||||||
),
|
|
||||||
material: use_source_materials
|
|
||||||
.then(|| {
|
.then(|| {
|
||||||
part_effective_material_id(part).map(|id| {
|
part_effective_material_id(part).map(|id| {
|
||||||
EditorAssetRef::new(
|
MaterialRef::new(EditorAssetRef::new(
|
||||||
manifest.asset_id.clone(),
|
manifest.asset_id.clone(),
|
||||||
id,
|
id,
|
||||||
part.material_slot_name.clone(),
|
part.material_slot_name.clone(),
|
||||||
)
|
))
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.flatten(),
|
.flatten(),
|
||||||
local_transform: part.local_transform,
|
material: None,
|
||||||
visible: true,
|
|
||||||
cast_shadows: true,
|
|
||||||
receive_shadows: true,
|
|
||||||
})
|
})
|
||||||
.collect(),
|
.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 {
|
fn part_effective_id(part: &StaticMeshPart) -> String {
|
||||||
if part.id.trim().is_empty() {
|
if part.id.trim().is_empty() {
|
||||||
part_id_from_label(&part.mesh_label)
|
part_id_from_label(&part.mesh_label)
|
||||||
@@ -255,23 +341,23 @@ fn build_gltf_manifest(
|
|||||||
.or_else(|| gltf.document.scenes().next())
|
.or_else(|| gltf.document.scenes().next())
|
||||||
{
|
{
|
||||||
for node in scene.nodes() {
|
for node in scene.nodes() {
|
||||||
collect_gltf_node_parts(node, Mat4::IDENTITY, &mut parts);
|
collect_gltf_node_parts(node, Mat4::IDENTITY, "", &mut parts);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for mesh in gltf.document.meshes() {
|
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 {
|
if gltf.document.animations().count() > 0 {
|
||||||
warnings.push(
|
warnings.push(
|
||||||
"Animations are recorded as metadata; use Scene Instance placement for playback."
|
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer."
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if gltf.document.skins().count() > 0 {
|
if gltf.document.skins().count() > 0 {
|
||||||
warnings.push(
|
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(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -306,29 +392,44 @@ fn build_gltf_manifest(
|
|||||||
fn collect_gltf_node_parts(
|
fn collect_gltf_node_parts(
|
||||||
node: gltf::Node<'_>,
|
node: gltf::Node<'_>,
|
||||||
parent_transform: Mat4,
|
parent_transform: Mat4,
|
||||||
|
parent_path: &str,
|
||||||
parts: &mut Vec<StaticMeshPart>,
|
parts: &mut Vec<StaticMeshPart>,
|
||||||
) {
|
) {
|
||||||
let local = Mat4::from_cols_array_2d(&node.transform().matrix());
|
let local = Mat4::from_cols_array_2d(&node.transform().matrix());
|
||||||
let world_transform = parent_transform * local;
|
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() {
|
if let Some(mesh) = node.mesh() {
|
||||||
collect_gltf_mesh_parts(
|
collect_gltf_mesh_parts(
|
||||||
node.name().map(str::to_string),
|
node.name().map(str::to_string),
|
||||||
Some(node.index()),
|
Some(node.index()),
|
||||||
|
Some(node_path.clone()),
|
||||||
mesh,
|
mesh,
|
||||||
world_transform,
|
world_transform,
|
||||||
|
skinned,
|
||||||
parts,
|
parts,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
for child in node.children() {
|
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(
|
fn collect_gltf_mesh_parts(
|
||||||
node_name: Option<String>,
|
node_name: Option<String>,
|
||||||
node_index: Option<usize>,
|
node_index: Option<usize>,
|
||||||
|
node_path: Option<String>,
|
||||||
mesh: gltf::Mesh<'_>,
|
mesh: gltf::Mesh<'_>,
|
||||||
transform: Mat4,
|
transform: Mat4,
|
||||||
|
skinned: bool,
|
||||||
parts: &mut Vec<StaticMeshPart>,
|
parts: &mut Vec<StaticMeshPart>,
|
||||||
) {
|
) {
|
||||||
let mesh_index = mesh.index();
|
let mesh_index = mesh.index();
|
||||||
@@ -359,9 +460,11 @@ fn collect_gltf_mesh_parts(
|
|||||||
.clone()
|
.clone()
|
||||||
.or_else(|| mesh_name.clone())
|
.or_else(|| mesh_name.clone())
|
||||||
.unwrap_or_else(|| format!("Mesh {mesh_index}"));
|
.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 {
|
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}"),
|
name: format!("{name} / Primitive {primitive_index}"),
|
||||||
material_id: material_label
|
material_id: material_label
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -373,6 +476,7 @@ fn collect_gltf_mesh_parts(
|
|||||||
source_node,
|
source_node,
|
||||||
source_mesh: Some(format!("Mesh{mesh_index}")),
|
source_mesh: Some(format!("Mesh{mesh_index}")),
|
||||||
source_material: Some(material_name),
|
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() {
|
if mesh.num_vertices == 0 || mesh.faces.as_ref().is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let skinned = !mesh.skin_deformers.as_ref().is_empty();
|
||||||
|
|
||||||
let mut groups: Vec<(usize, Vec<u32>)> =
|
let mut groups: Vec<(usize, Vec<u32>)> =
|
||||||
group_faces_by_material(mesh).into_iter().collect();
|
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();
|
let mesh_label = FbxAssetLabel::Mesh(node_index * 1000 + material_index).to_string();
|
||||||
parts.push(StaticMeshPart {
|
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}"),
|
name: format!("{node_name} / Material {material_index}"),
|
||||||
material_id: material_label
|
material_id: material_label
|
||||||
.as_ref()
|
.as_ref()
|
||||||
@@ -440,19 +545,20 @@ fn build_fbx_manifest(
|
|||||||
source_node: Some(format!("Node{node_index}")),
|
source_node: Some(format!("Node{node_index}")),
|
||||||
source_mesh: Some(format!("Mesh{node_index}")),
|
source_mesh: Some(format!("Mesh{node_index}")),
|
||||||
source_material: Some(material_name),
|
source_material: Some(material_name),
|
||||||
|
skinned,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !scene.anim_stacks.as_ref().is_empty() {
|
if !scene.anim_stacks.as_ref().is_empty() {
|
||||||
warnings.push(
|
warnings.push(
|
||||||
"Animations are recorded as metadata; use Scene Instance placement for playback."
|
"Animations are recorded as metadata; animated placement uses SkinnedMeshRenderer."
|
||||||
.into(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if !scene.skin_deformers.as_ref().is_empty() {
|
if !scene.skin_deformers.as_ref().is_empty() {
|
||||||
warnings.push(
|
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(),
|
.into(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -554,6 +660,7 @@ fn resolve_dependency(source_path: &str, uri: &str) -> String {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::asset_db::AssetId;
|
||||||
|
|
||||||
fn test_manifest() -> StaticMeshManifest {
|
fn test_manifest() -> StaticMeshManifest {
|
||||||
StaticMeshManifest {
|
StaticMeshManifest {
|
||||||
@@ -597,6 +704,7 @@ mod tests {
|
|||||||
source_node: Some("Node0".into()),
|
source_node: Some("Node0".into()),
|
||||||
source_mesh: Some("Mesh0".into()),
|
source_mesh: Some("Mesh0".into()),
|
||||||
source_material: Some("Wood".into()),
|
source_material: Some("Wood".into()),
|
||||||
|
skinned: false,
|
||||||
}],
|
}],
|
||||||
warnings: Vec::new(),
|
warnings: Vec::new(),
|
||||||
}
|
}
|
||||||
@@ -645,4 +753,48 @@ mod tests {
|
|||||||
|
|
||||||
assert!(renderer.slots[0].material.is_none());
|
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 bevy_egui::{egui, EguiPrimaryContextPass, EguiTextureHandle, EguiUserTextures};
|
||||||
use egui_phosphor_icons::icons;
|
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::studio::{model_file_exists, ThumbnailStudio};
|
||||||
use super::ThumbnailJobSource;
|
use super::ThumbnailJobSource;
|
||||||
use crate::assets::{
|
use crate::assets::{
|
||||||
@@ -100,13 +100,12 @@ impl AssetThumbnailCache {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(texture_path) = gltf_base_color_texture_path(&model_path) {
|
if !self.model_source_ready(&key, &model_path) {
|
||||||
self.request_texture(key, texture_path, asset_server);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !model_file_exists(&model_path) {
|
if let Some(texture_path) = gltf_base_color_texture_path(&model_path) {
|
||||||
self.mark_studio_failed(&key, "file not found", false);
|
self.request_texture(key, texture_path, asset_server);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,6 +120,7 @@ impl AssetThumbnailCache {
|
|||||||
model_path: String,
|
model_path: String,
|
||||||
mesh_label: String,
|
mesh_label: String,
|
||||||
material_label: Option<String>,
|
material_label: Option<String>,
|
||||||
|
requires_scene_instance: bool,
|
||||||
studio: &mut ThumbnailStudio,
|
studio: &mut ThumbnailStudio,
|
||||||
) {
|
) {
|
||||||
if matches!(
|
if matches!(
|
||||||
@@ -130,18 +130,19 @@ impl AssetThumbnailCache {
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !model_file_exists(&model_path) {
|
if !self.model_source_ready(&key, &model_path) {
|
||||||
self.mark_studio_failed(&key, "file not found", false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if studio.enqueue_source(
|
let source = if requires_scene_instance {
|
||||||
key.clone(),
|
ThumbnailJobSource::Model { model_path }
|
||||||
|
} else {
|
||||||
ThumbnailJobSource::MeshSubAsset {
|
ThumbnailJobSource::MeshSubAsset {
|
||||||
model_path,
|
model_path,
|
||||||
mesh_label,
|
mesh_label,
|
||||||
material_label,
|
material_label,
|
||||||
},
|
}
|
||||||
) {
|
};
|
||||||
|
if studio.enqueue_source(key.clone(), source) {
|
||||||
self.studio_pending.insert(key);
|
self.studio_pending.insert(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,8 +161,7 @@ impl AssetThumbnailCache {
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if !model_file_exists(&model_path) {
|
if !self.model_source_ready(&key, &model_path) {
|
||||||
self.mark_studio_failed(&key, "file not found", false);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if studio.enqueue_source(
|
if studio.enqueue_source(
|
||||||
@@ -206,6 +206,18 @@ impl AssetThumbnailCache {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
pub(crate) fn complete_studio_thumbnail(
|
||||||
&mut self,
|
&mut self,
|
||||||
key: &str,
|
key: &str,
|
||||||
@@ -283,6 +295,7 @@ pub fn kind_icon(kind: &EditorAssetKind) -> egui_phosphor_icons::Icon {
|
|||||||
EditorAssetKind::Model => icons::CUBE_TRANSPARENT,
|
EditorAssetKind::Model => icons::CUBE_TRANSPARENT,
|
||||||
EditorAssetKind::Texture => icons::IMAGE,
|
EditorAssetKind::Texture => icons::IMAGE,
|
||||||
EditorAssetKind::Material => icons::PAINT_BRUSH,
|
EditorAssetKind::Material => icons::PAINT_BRUSH,
|
||||||
|
EditorAssetKind::AudioClip => icons::WAVEFORM,
|
||||||
EditorAssetKind::Level => icons::MAP_TRIFOLD,
|
EditorAssetKind::Level => icons::MAP_TRIFOLD,
|
||||||
EditorAssetKind::Prefab => icons::PACKAGE,
|
EditorAssetKind::Prefab => icons::PACKAGE,
|
||||||
EditorAssetKind::PostProcessVolume => icons::CAMERA,
|
EditorAssetKind::PostProcessVolume => icons::CAMERA,
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ pub use cache::{
|
|||||||
AssetThumbnailCache, AssetThumbnailsPlugin, ThumbnailCacheSnapshot, ThumbnailState,
|
AssetThumbnailCache, AssetThumbnailsPlugin, ThumbnailCacheSnapshot, ThumbnailState,
|
||||||
};
|
};
|
||||||
pub use job::{ThumbnailJob, ThumbnailJobSource};
|
pub use job::{ThumbnailJob, ThumbnailJobSource};
|
||||||
pub use sources::{FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource};
|
pub use sources::{
|
||||||
|
gltf_skinned_primitive_labels, FbxThumbnailSource, GltfThumbnailSource, ThumbnailModelSource,
|
||||||
|
};
|
||||||
pub use studio::{
|
pub use studio::{
|
||||||
model_file_exists, model_scene_asset_path, ThumbnailStudio, ThumbnailStudioPlugin,
|
model_file_exists, model_scene_asset_path, ThumbnailStudio, ThumbnailStudioPlugin,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//! glTF/GLB fast-path texture extraction for asset browser thumbnails.
|
//! glTF/GLB fast-path texture extraction for asset browser thumbnails.
|
||||||
|
|
||||||
|
use std::collections::HashSet;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
/// Returns an asset-server path for the first base-color texture referenced by a glTF/GLB file.
|
/// 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
|
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;
|
pub struct GltfThumbnailSource;
|
||||||
|
|
||||||
fn is_gltf_path(path: &Path) -> bool {
|
fn is_gltf_path(path: &Path) -> bool {
|
||||||
@@ -61,7 +123,9 @@ fn normalize_asset_path(path: &Path) -> Option<String> {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::time::{SystemTime, UNIX_EPOCH};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn normalize_asset_path_keeps_assets_prefix() {
|
fn normalize_asset_path_keeps_assets_prefix() {
|
||||||
@@ -79,4 +143,37 @@ mod tests {
|
|||||||
Some("assets/models/textures/chair_albedo.png".into())
|
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(crate) mod gltf;
|
||||||
|
|
||||||
pub use fbx::FbxThumbnailSource;
|
pub use fbx::FbxThumbnailSource;
|
||||||
pub use gltf::GltfThumbnailSource;
|
pub use gltf::{gltf_skinned_primitive_labels, GltfThumbnailSource};
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use bevy::mesh::VertexAttributeValues;
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::render_resource::TextureFormat;
|
use bevy::render::render_resource::TextureFormat;
|
||||||
use bevy_egui::EguiUserTextures;
|
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::cache::AssetThumbnailCache;
|
||||||
use super::job::{ThumbnailJob, ThumbnailJobSource};
|
use super::job::{ThumbnailJob, ThumbnailJobSource};
|
||||||
@@ -21,6 +21,10 @@ use crate::infra::EditorOnly;
|
|||||||
|
|
||||||
pub(crate) const THUMB_SIZE: u32 = 128;
|
pub(crate) const THUMB_SIZE: u32 = 128;
|
||||||
pub(crate) const THUMBNAIL_LAYER: usize = 31;
|
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 MESH_WARMUP_FRAMES: u8 = 12;
|
||||||
const POST_ATTACH_FRAMES: u8 = 8;
|
const POST_ATTACH_FRAMES: u8 = 8;
|
||||||
const RENDER_FRAMES: u8 = 3;
|
const RENDER_FRAMES: u8 = 3;
|
||||||
@@ -61,6 +65,25 @@ struct ActiveModelThumbnail {
|
|||||||
framed: bool,
|
framed: bool,
|
||||||
frames_remaining: u8,
|
frames_remaining: u8,
|
||||||
wait_frames: u32,
|
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;
|
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()),
|
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),
|
Transform::from_xyz(2.0, 1.4, 2.0).looking_at(Vec3::new(0.0, 0.5, 0.0), Vec3::Y),
|
||||||
Projection::Perspective(PerspectiveProjection {
|
Projection::Perspective(PerspectiveProjection {
|
||||||
fov: 40.0_f32.to_radians(),
|
fov: THUMBNAIL_VERTICAL_FOV,
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
@@ -229,6 +252,7 @@ fn process_thumbnail_studio(
|
|||||||
&mesh3d,
|
&mesh3d,
|
||||||
&mesh_storage,
|
&mesh_storage,
|
||||||
&mut camera_transforms,
|
&mut camera_transforms,
|
||||||
|
active.framing,
|
||||||
) {
|
) {
|
||||||
active.framed = true;
|
active.framed = true;
|
||||||
active.post_attach_frames = 0;
|
active.post_attach_frames = 0;
|
||||||
@@ -315,10 +339,14 @@ fn process_thumbnail_studio(
|
|||||||
ThumbnailStudioLayer,
|
ThumbnailStudioLayer,
|
||||||
RenderLayers::layer(THUMBNAIL_LAYER),
|
RenderLayers::layer(THUMBNAIL_LAYER),
|
||||||
Transform::default(),
|
Transform::default(),
|
||||||
|
Visibility::Visible,
|
||||||
|
InheritedVisibility::default(),
|
||||||
|
ViewVisibility::default(),
|
||||||
))
|
))
|
||||||
.id();
|
.id();
|
||||||
|
|
||||||
let label = job.source.label().to_string();
|
let label = job.source.label().to_string();
|
||||||
|
let framing = ThumbnailFraming::for_source(&job.source);
|
||||||
let content_spawned = spawn_thumbnail_job_content(
|
let content_spawned = spawn_thumbnail_job_content(
|
||||||
&mut commands,
|
&mut commands,
|
||||||
&mut mesh_storage,
|
&mut mesh_storage,
|
||||||
@@ -347,6 +375,7 @@ fn process_thumbnail_studio(
|
|||||||
framed: false,
|
framed: false,
|
||||||
frames_remaining: 0,
|
frames_remaining: 0,
|
||||||
wait_frames: 0,
|
wait_frames: 0,
|
||||||
|
framing,
|
||||||
},
|
},
|
||||||
"no renderable meshes",
|
"no renderable meshes",
|
||||||
true,
|
true,
|
||||||
@@ -366,6 +395,7 @@ fn process_thumbnail_studio(
|
|||||||
framed: false,
|
framed: false,
|
||||||
frames_remaining: 0,
|
frames_remaining: 0,
|
||||||
wait_frames: 0,
|
wait_frames: 0,
|
||||||
|
framing,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,7 +440,7 @@ fn spawn_thumbnail_job_content(
|
|||||||
commands,
|
commands,
|
||||||
mesh_storage,
|
mesh_storage,
|
||||||
root,
|
root,
|
||||||
asset_server.load(labeled_asset_path(
|
asset_server.load(standard_material_asset_path(
|
||||||
&asset_server_path(model_path),
|
&asset_server_path(model_path),
|
||||||
material_label,
|
material_label,
|
||||||
)),
|
)),
|
||||||
@@ -434,7 +464,7 @@ fn spawn_mesh_subasset_preview(
|
|||||||
let source_path = asset_server_path(model_path);
|
let source_path = asset_server_path(model_path);
|
||||||
let mesh: Handle<Mesh> = asset_server.load(labeled_asset_path(&source_path, mesh_label));
|
let mesh: Handle<Mesh> = asset_server.load(labeled_asset_path(&source_path, mesh_label));
|
||||||
let material = if let Some(material_label) = material_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 {
|
} else {
|
||||||
materials.add(StandardMaterial {
|
materials.add(StandardMaterial {
|
||||||
base_color: Color::srgb(0.72, 0.72, 0.75),
|
base_color: Color::srgb(0.72, 0.72, 0.75),
|
||||||
@@ -585,6 +615,7 @@ fn frame_thumbnail_scene(
|
|||||||
meshes: &Query<&Mesh3d>,
|
meshes: &Query<&Mesh3d>,
|
||||||
mesh_assets: &Assets<Mesh>,
|
mesh_assets: &Assets<Mesh>,
|
||||||
camera_transforms: &mut Query<&mut Transform, With<ThumbnailStudioCamera>>,
|
camera_transforms: &mut Query<&mut Transform, With<ThumbnailStudioCamera>>,
|
||||||
|
framing: ThumbnailFraming,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut entities = Vec::new();
|
let mut entities = Vec::new();
|
||||||
collect_descendants(root, children, &mut entities);
|
collect_descendants(root, children, &mut entities);
|
||||||
@@ -630,8 +661,7 @@ fn frame_thumbnail_scene(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let center = (min + max) * 0.5;
|
let center = (min + max) * 0.5;
|
||||||
let radius = (max - min).length().max(0.25) * 0.5;
|
let distance = thumbnail_camera_distance(min, max, framing);
|
||||||
let distance = radius / (20.0_f32.to_radians()).tan() * 1.35;
|
|
||||||
let eye = center + Vec3::new(1.0, 0.75, 1.0).normalize() * distance;
|
let eye = center + Vec3::new(1.0, 0.75, 1.0).normalize() * distance;
|
||||||
|
|
||||||
if let Ok(mut transform) = camera_transforms.single_mut() {
|
if let Ok(mut transform) = camera_transforms.single_mut() {
|
||||||
@@ -641,6 +671,20 @@ fn frame_thumbnail_scene(
|
|||||||
true
|
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>) {
|
fn collect_descendants(entity: Entity, children: &Query<&Children>, out: &mut Vec<Entity>) {
|
||||||
out.push(entity);
|
out.push(entity);
|
||||||
let Ok(child_list) = children.get(entity) else {
|
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 {
|
pub fn model_file_exists(catalog_path: &str) -> bool {
|
||||||
Path::new(catalog_path).is_file()
|
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.
|
//! In-process editor binary entry point.
|
||||||
|
|
||||||
fn main() {
|
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() {
|
if std::env::var_os("WGPU_VALIDATION").is_none() {
|
||||||
// SAFETY: called before any threads or GPU init.
|
// SAFETY: called before any threads or GPU init.
|
||||||
unsafe { std::env::set_var("WGPU_VALIDATION", "0") };
|
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 bevy::prelude::*;
|
||||||
use shared::{
|
use shared::{
|
||||||
ActorId, ActorKind, ActorName, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder,
|
ActorId, ActorKind, ActorName, AnimationControllerDesc, AudioListenerDesc, AudioSourceDesc,
|
||||||
LightDesc, MaterialDesc, MaterialOverride, ModelRef, ObjectiveMarker, PhysicsBody,
|
AuthoringComponentStates, BrushDesc, ColliderDesc, EditorVisibility, InspectorOrder, LightDesc,
|
||||||
PostProcessVolumeDesc, PrefabInstance, PrefabRef, Primitive, RigidBodyDesc, StaticMeshRenderer,
|
MaterialDesc, MaterialOverride, ModelRef, NavigationArea, NavigationBounds, NavigationLink,
|
||||||
|
NavigationObstacle, ObjectiveMarker, PhysicsBody, PostProcessVolumeDesc, PrefabInstance,
|
||||||
|
PrefabRef, Primitive, RigidBodyDesc, SceneComposition, SkinnedMeshRenderer, StaticMeshRenderer,
|
||||||
TeamSpawn, TriggerVolume, WeaponSpawn,
|
TeamSpawn, TriggerVolume, WeaponSpawn,
|
||||||
};
|
};
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -15,12 +19,16 @@ pub struct EditorEntitySnapshot {
|
|||||||
pub primitive: Option<Primitive>,
|
pub primitive: Option<Primitive>,
|
||||||
pub brush: Option<BrushDesc>,
|
pub brush: Option<BrushDesc>,
|
||||||
pub static_mesh_renderer: Option<StaticMeshRenderer>,
|
pub static_mesh_renderer: Option<StaticMeshRenderer>,
|
||||||
|
pub skinned_mesh_renderer: Option<SkinnedMeshRenderer>,
|
||||||
pub material: Option<MaterialDesc>,
|
pub material: Option<MaterialDesc>,
|
||||||
pub material_override: Option<MaterialOverride>,
|
pub material_override: Option<MaterialOverride>,
|
||||||
pub rigid_body: Option<RigidBodyDesc>,
|
pub rigid_body: Option<RigidBodyDesc>,
|
||||||
pub collider: Option<ColliderDesc>,
|
pub collider: Option<ColliderDesc>,
|
||||||
pub physics: Option<PhysicsBody>,
|
pub physics: Option<PhysicsBody>,
|
||||||
pub light: Option<LightDesc>,
|
pub light: Option<LightDesc>,
|
||||||
|
pub animation_controller: Option<AnimationControllerDesc>,
|
||||||
|
pub audio_source: Option<AudioSourceDesc>,
|
||||||
|
pub audio_listener: Option<AudioListenerDesc>,
|
||||||
pub player_spawn: bool,
|
pub player_spawn: bool,
|
||||||
pub model: Option<ModelRef>,
|
pub model: Option<ModelRef>,
|
||||||
pub prefab: Option<PrefabRef>,
|
pub prefab: Option<PrefabRef>,
|
||||||
@@ -30,11 +38,52 @@ pub struct EditorEntitySnapshot {
|
|||||||
pub post_process_volume: Option<PostProcessVolumeDesc>,
|
pub post_process_volume: Option<PostProcessVolumeDesc>,
|
||||||
pub team_spawn: Option<TeamSpawn>,
|
pub team_spawn: Option<TeamSpawn>,
|
||||||
pub objective: Option<ObjectiveMarker>,
|
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 hierarchy_sibling_index: i32,
|
||||||
pub editor_visibility: EditorVisibility,
|
pub editor_visibility: EditorVisibility,
|
||||||
|
pub inspector_order: Option<InspectorOrder>,
|
||||||
|
pub component_states: Option<AuthoringComponentStates>,
|
||||||
pub children: Vec<EditorEntitySnapshot>,
|
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)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct SiblingChange {
|
pub struct SiblingChange {
|
||||||
pub entity: Entity,
|
pub entity: Entity,
|
||||||
@@ -42,6 +91,17 @@ pub struct SiblingChange {
|
|||||||
pub new_parent: Option<Entity>,
|
pub new_parent: Option<Entity>,
|
||||||
pub old_index: i32,
|
pub old_index: i32,
|
||||||
pub new_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)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -77,6 +137,11 @@ pub enum EditorCommand {
|
|||||||
old: Option<MaterialDesc>,
|
old: Option<MaterialDesc>,
|
||||||
new: MaterialDesc,
|
new: MaterialDesc,
|
||||||
},
|
},
|
||||||
|
SetMaterialGroup {
|
||||||
|
entities: Vec<Entity>,
|
||||||
|
olds: Vec<Option<MaterialDesc>>,
|
||||||
|
news: Vec<MaterialDesc>,
|
||||||
|
},
|
||||||
SetMaterialOverride {
|
SetMaterialOverride {
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
old: Option<MaterialOverride>,
|
old: Option<MaterialOverride>,
|
||||||
@@ -87,6 +152,21 @@ pub enum EditorCommand {
|
|||||||
old: Option<LightDesc>,
|
old: Option<LightDesc>,
|
||||||
new: 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 {
|
SetPhysics {
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
old: Option<PhysicsBody>,
|
old: Option<PhysicsBody>,
|
||||||
@@ -137,6 +217,11 @@ pub enum EditorCommand {
|
|||||||
old: Option<PostProcessVolumeDesc>,
|
old: Option<PostProcessVolumeDesc>,
|
||||||
new: PostProcessVolumeDesc,
|
new: PostProcessVolumeDesc,
|
||||||
},
|
},
|
||||||
|
SetNavigation {
|
||||||
|
entity: Entity,
|
||||||
|
old: NavigationComponentState,
|
||||||
|
new: NavigationComponentState,
|
||||||
|
},
|
||||||
SetTransformGroup {
|
SetTransformGroup {
|
||||||
entities: Vec<Entity>,
|
entities: Vec<Entity>,
|
||||||
olds: Vec<Transform>,
|
olds: Vec<Transform>,
|
||||||
@@ -165,6 +250,35 @@ pub enum EditorCommand {
|
|||||||
old: Option<InspectorOrder>,
|
old: Option<InspectorOrder>,
|
||||||
new: 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 {
|
AddComponent {
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
snapshot: EditorEntitySnapshot,
|
snapshot: EditorEntitySnapshot,
|
||||||
@@ -173,6 +287,7 @@ pub enum EditorCommand {
|
|||||||
entity: Entity,
|
entity: Entity,
|
||||||
snapshot: EditorEntitySnapshot,
|
snapshot: EditorEntitySnapshot,
|
||||||
},
|
},
|
||||||
|
ComponentTransaction(ComponentTransaction),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditorCommand {
|
impl EditorCommand {
|
||||||
@@ -185,8 +300,12 @@ impl EditorCommand {
|
|||||||
EditorCommand::Rename { .. } => "Rename",
|
EditorCommand::Rename { .. } => "Rename",
|
||||||
EditorCommand::SetTransform { .. } => "Move",
|
EditorCommand::SetTransform { .. } => "Move",
|
||||||
EditorCommand::SetMaterial { .. } => "Set Material",
|
EditorCommand::SetMaterial { .. } => "Set Material",
|
||||||
|
EditorCommand::SetMaterialGroup { .. } => "Apply Material to Selection",
|
||||||
EditorCommand::SetMaterialOverride { .. } => "Set Material Override",
|
EditorCommand::SetMaterialOverride { .. } => "Set Material Override",
|
||||||
EditorCommand::SetLight { .. } => "Set Light",
|
EditorCommand::SetLight { .. } => "Set Light",
|
||||||
|
EditorCommand::SetAnimationController { .. } => "Set Animation Controller",
|
||||||
|
EditorCommand::SetAudioSource { .. } => "Set Audio Source",
|
||||||
|
EditorCommand::SetAudioListener { .. } => "Set Audio Listener",
|
||||||
EditorCommand::SetPhysics { .. } => "Set Physics",
|
EditorCommand::SetPhysics { .. } => "Set Physics",
|
||||||
EditorCommand::SetRigidBody { .. } => "Set Rigid Body",
|
EditorCommand::SetRigidBody { .. } => "Set Rigid Body",
|
||||||
EditorCommand::SetCollider { .. } => "Set Collider",
|
EditorCommand::SetCollider { .. } => "Set Collider",
|
||||||
@@ -196,14 +315,25 @@ impl EditorCommand {
|
|||||||
EditorCommand::ApplyBrushCsg { .. } => "Brush CSG",
|
EditorCommand::ApplyBrushCsg { .. } => "Brush CSG",
|
||||||
EditorCommand::SetStaticMeshRenderer { .. } => "Set Static Mesh Renderer",
|
EditorCommand::SetStaticMeshRenderer { .. } => "Set Static Mesh Renderer",
|
||||||
EditorCommand::SetPostProcessVolume { .. } => "Set Post Process Volume",
|
EditorCommand::SetPostProcessVolume { .. } => "Set Post Process Volume",
|
||||||
|
EditorCommand::SetNavigation { .. } => "Set Navigation",
|
||||||
EditorCommand::SetTransformGroup { .. } => "Move Selection",
|
EditorCommand::SetTransformGroup { .. } => "Move Selection",
|
||||||
EditorCommand::Reparent { .. } => "Reparent",
|
EditorCommand::Reparent { .. } => "Reparent",
|
||||||
EditorCommand::SetActorKind { .. } => "Set Actor Kind",
|
EditorCommand::SetActorKind { .. } => "Set Actor Kind",
|
||||||
EditorCommand::ReorderSibling { .. } => "Reorder Hierarchy",
|
EditorCommand::ReorderSibling { .. } => "Reorder Hierarchy",
|
||||||
EditorCommand::SetEditorVisibility { .. } => "Set Visibility",
|
EditorCommand::SetEditorVisibility { .. } => "Set Visibility",
|
||||||
EditorCommand::SetInspectorOrder { .. } => "Set Component Order",
|
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::AddComponent { .. } => "Add Component",
|
||||||
EditorCommand::RemoveComponent { .. } => "Remove Component",
|
EditorCommand::RemoveComponent { .. } => "Remove Component",
|
||||||
|
EditorCommand::ComponentTransaction(transaction) => transaction.label,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2039
-30
File diff suppressed because it is too large.
Load diff
@@ -22,7 +22,10 @@ pub use ext::extensibility;
|
|||||||
pub use ext::hot_reload;
|
pub use ext::hot_reload;
|
||||||
pub use play::net_editor;
|
pub use play::net_editor;
|
||||||
pub use play::state;
|
pub use play::state;
|
||||||
|
pub use project::diagnostics_bundle;
|
||||||
|
pub use project::launcher;
|
||||||
pub use project::project_io;
|
pub use project::project_io;
|
||||||
|
pub use project::session;
|
||||||
pub use project::settings_ui;
|
pub use project::settings_ui;
|
||||||
pub use scene::scene_io;
|
pub use scene::scene_io;
|
||||||
pub use scene::scene_schema;
|
pub use scene::scene_schema;
|
||||||
@@ -43,7 +46,8 @@ use bevy::app::PluginGroupBuilder;
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_egui::EguiPlugin;
|
use bevy_egui::EguiPlugin;
|
||||||
use game::{
|
use game::{
|
||||||
launch, GameInputEnabled, GameInputFocused, GamePlugin, GameRenderBootstrap, SimEnabled,
|
launch, GameInputEnabled, GameInputFocused, GamePlugin, GameRenderBootstrap,
|
||||||
|
GameSceneBootstrap, SimEnabled,
|
||||||
};
|
};
|
||||||
use transform_gizmo_bevy::prelude::TransformGizmoPlugin;
|
use transform_gizmo_bevy::prelude::TransformGizmoPlugin;
|
||||||
|
|
||||||
@@ -58,6 +62,7 @@ use gizmos::EditorGizmoPlugin;
|
|||||||
use history::EditorHistoryPlugin;
|
use history::EditorHistoryPlugin;
|
||||||
use infra::EditorInfraPlugin;
|
use infra::EditorInfraPlugin;
|
||||||
use operators::OperatorPlugin;
|
use operators::OperatorPlugin;
|
||||||
|
use play::audio_preview::AudioPreviewPlugin;
|
||||||
use play::PlaySessionPlugin;
|
use play::PlaySessionPlugin;
|
||||||
use project_io::ProjectIoPlugin;
|
use project_io::ProjectIoPlugin;
|
||||||
use render_view::RenderViewPlugin;
|
use render_view::RenderViewPlugin;
|
||||||
@@ -65,6 +70,7 @@ use scene_io::SceneIoPlugin;
|
|||||||
use scene_view::SceneViewPlugin;
|
use scene_view::SceneViewPlugin;
|
||||||
use selection::EditorSelectionPlugin;
|
use selection::EditorSelectionPlugin;
|
||||||
use selection_outline::SelectionOutlinePlugin;
|
use selection_outline::SelectionOutlinePlugin;
|
||||||
|
use session::EditorSessionPlugin;
|
||||||
use settings_ui::SettingsUiPlugin;
|
use settings_ui::SettingsUiPlugin;
|
||||||
use state::EditorStatePlugin;
|
use state::EditorStatePlugin;
|
||||||
use ui::EditorUiPlugin;
|
use ui::EditorUiPlugin;
|
||||||
@@ -97,6 +103,7 @@ impl PluginGroup for EditorPluginGroup {
|
|||||||
.add(BrushEditPlugin)
|
.add(BrushEditPlugin)
|
||||||
.add(BrushToolPlugin)
|
.add(BrushToolPlugin)
|
||||||
.add(EditorCameraPlugin)
|
.add(EditorCameraPlugin)
|
||||||
|
.add(AudioPreviewPlugin)
|
||||||
.add(ActorIconsPlugin)
|
.add(ActorIconsPlugin)
|
||||||
.add(EditorSelectionPlugin)
|
.add(EditorSelectionPlugin)
|
||||||
.add(SelectionOutlinePlugin)
|
.add(SelectionOutlinePlugin)
|
||||||
@@ -105,6 +112,7 @@ impl PluginGroup for EditorPluginGroup {
|
|||||||
.add(EditorHistoryPlugin)
|
.add(EditorHistoryPlugin)
|
||||||
.add(SceneIoPlugin)
|
.add(SceneIoPlugin)
|
||||||
.add(EditorUiPlugin)
|
.add(EditorUiPlugin)
|
||||||
|
.add(EditorSessionPlugin)
|
||||||
.add(brp::BrpPlugin);
|
.add(brp::BrpPlugin);
|
||||||
#[cfg(feature = "hot-reload")]
|
#[cfg(feature = "hot-reload")]
|
||||||
let group = group.add(hot_reload::HotReloadPlugin);
|
let group = group.add(hot_reload::HotReloadPlugin);
|
||||||
@@ -121,6 +129,9 @@ pub fn configure_editor_app(app: &mut App) {
|
|||||||
.insert_resource(GameRenderBootstrap {
|
.insert_resource(GameRenderBootstrap {
|
||||||
defer_player_camera_fx: true,
|
defer_player_camera_fx: true,
|
||||||
})
|
})
|
||||||
|
.insert_resource(GameSceneBootstrap {
|
||||||
|
defer_default_level: true,
|
||||||
|
})
|
||||||
.add_plugins(GamePlugin)
|
.add_plugins(GamePlugin)
|
||||||
.add_plugins(MeshPickingPlugin)
|
.add_plugins(MeshPickingPlugin)
|
||||||
.add_plugins(TransformGizmoPlugin)
|
.add_plugins(TransformGizmoPlugin)
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ use bevy::prelude::*;
|
|||||||
|
|
||||||
use crate::history::EditorHistory;
|
use crate::history::EditorHistory;
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub(crate) mod test_harness;
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum OperatorPhase {
|
pub enum OperatorPhase {
|
||||||
Idle,
|
Idle,
|
||||||
@@ -227,12 +230,19 @@ fn set_operator_status(world: &mut World, status: OperatorStatus) {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::history::EditorHistory;
|
||||||
|
use crate::operators::test_harness::OperatorInvariantHarness;
|
||||||
|
use crate::scene_io::SceneIo;
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
struct Counter(i32);
|
struct Counter(i32);
|
||||||
|
|
||||||
|
#[derive(Component)]
|
||||||
|
struct PreviewHelper;
|
||||||
|
|
||||||
struct CounterOperator {
|
struct CounterOperator {
|
||||||
before: i32,
|
before: i32,
|
||||||
|
helper: Option<Entity>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl EditorOperator for CounterOperator {
|
impl EditorOperator for CounterOperator {
|
||||||
@@ -246,6 +256,7 @@ mod tests {
|
|||||||
|
|
||||||
fn begin(&mut self, world: &mut World) -> Result<(), String> {
|
fn begin(&mut self, world: &mut World) -> Result<(), String> {
|
||||||
self.before = world.resource::<Counter>().0;
|
self.before = world.resource::<Counter>().0;
|
||||||
|
self.helper = Some(world.spawn(PreviewHelper).id());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,34 +265,50 @@ mod tests {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn commit(&mut self, _world: &mut World) -> Result<(), String> {
|
fn commit(&mut self, world: &mut World) -> Result<(), String> {
|
||||||
|
self.remove_helper(world);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cancel(&mut self, world: &mut World) {
|
fn cancel(&mut self, world: &mut World) {
|
||||||
world.resource_mut::<Counter>().0 = self.before;
|
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]
|
#[test]
|
||||||
fn operator_commit_keeps_previewed_change() {
|
fn operator_commit_keeps_previewed_change() {
|
||||||
let mut world = World::new();
|
let mut world = test_world();
|
||||||
world.init_resource::<ActiveOperator>();
|
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||||
world.init_resource::<Counter>();
|
|
||||||
|
|
||||||
let mut operator = CounterOperator { before: 0 };
|
let mut operator = CounterOperator {
|
||||||
|
before: 0,
|
||||||
|
helper: None,
|
||||||
|
};
|
||||||
|
|
||||||
assert!(run_operator(&mut world, &mut operator));
|
assert!(run_operator(&mut world, &mut operator));
|
||||||
assert_eq!(world.resource::<Counter>().0, 1);
|
assert_eq!(world.resource::<Counter>().0, 1);
|
||||||
assert_eq!(
|
harness.assert_committed(&mut world, 0, 0);
|
||||||
world
|
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||||
.resource::<ActiveOperator>()
|
|
||||||
.status
|
|
||||||
.as_ref()
|
|
||||||
.unwrap()
|
|
||||||
.phase,
|
|
||||||
OperatorPhase::Committed
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -314,22 +341,38 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut world = World::new();
|
let mut world = test_world();
|
||||||
world.init_resource::<ActiveOperator>();
|
let harness = OperatorInvariantHarness::capture(&mut world);
|
||||||
world.init_resource::<Counter>();
|
|
||||||
|
|
||||||
let mut operator = FailingCounterOperator(CounterOperator { before: 0 });
|
let mut operator = FailingCounterOperator(CounterOperator {
|
||||||
|
before: 0,
|
||||||
|
helper: None,
|
||||||
|
});
|
||||||
|
|
||||||
assert!(!run_operator(&mut world, &mut operator));
|
assert!(!run_operator(&mut world, &mut operator));
|
||||||
assert_eq!(world.resource::<Counter>().0, 0);
|
assert_eq!(world.resource::<Counter>().0, 0);
|
||||||
assert_eq!(
|
harness.assert_canceled(&mut world);
|
||||||
world
|
harness.assert_no_helpers::<PreviewHelper>(&mut world);
|
||||||
.resource::<ActiveOperator>()
|
}
|
||||||
.status
|
|
||||||
.as_ref()
|
#[test]
|
||||||
.unwrap()
|
fn blocked_operator_never_begins_or_mutates_world() {
|
||||||
.phase,
|
let mut world = test_world();
|
||||||
OperatorPhase::Canceled
|
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.
|
//! Play-in-editor session, editor mode state, and net editor profiles.
|
||||||
|
|
||||||
|
pub mod audio_preview;
|
||||||
pub mod net_editor;
|
pub mod net_editor;
|
||||||
mod session;
|
mod session;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ use bevy::window::WindowRef;
|
|||||||
use game::player::PlayerCamera;
|
use game::player::PlayerCamera;
|
||||||
use protocol::PlayerInputIntent;
|
use protocol::PlayerInputIntent;
|
||||||
use settings::SimTuning;
|
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 sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
|
||||||
|
|
||||||
use crate::render_target::ViewportRenderTarget;
|
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()));
|
.unwrap_or_else(|| SimTuning::from_physics(&settings::PhysicsSettings::default()));
|
||||||
|
|
||||||
let spawn = world
|
let spawn = world
|
||||||
.query_filtered::<(&Transform, Option<&InspectorOrder>), With<PlayerSpawn>>()
|
.query_filtered::<(
|
||||||
|
&Transform,
|
||||||
|
Option<&AuthoringComponentStates>,
|
||||||
|
Option<&InspectorOrder>,
|
||||||
|
), With<PlayerSpawn>>()
|
||||||
.iter(world)
|
.iter(world)
|
||||||
.filter(|(_, order)| inspector_component_active(*order, COMPONENT_PLAYER_SPAWN))
|
.filter(|(_, states, legacy_order)| {
|
||||||
.map(|(transform, _)| transform)
|
authoring_component_active(*states, *legacy_order, COMPONENT_PLAYER_SPAWN)
|
||||||
|
})
|
||||||
|
.map(|(transform, _, _)| transform)
|
||||||
.next()
|
.next()
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or_else(default_player_spawn);
|
.unwrap_or_else(default_player_spawn);
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ use protocol::PlayerInputIntent;
|
|||||||
use sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
|
use sim::{Crouching, Grounded, JumpState, Player, PlayerVelocity};
|
||||||
|
|
||||||
use crate::camera::EditorCamera;
|
use crate::camera::EditorCamera;
|
||||||
use crate::scene_io::SceneIo;
|
|
||||||
|
|
||||||
/// Editor/game mode. `Playing` runs the real game sim; use [`PlayPossession`] for camera control.
|
/// Editor/game mode. `Playing` runs the real game sim; use [`PlayPossession`] for camera control.
|
||||||
#[derive(States, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
|
#[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) {
|
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);
|
let snapshot = snapshot_player_sim(world);
|
||||||
world.resource_mut::<PlayModeSnapshot>().player = Some(snapshot);
|
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() {
|
if let Some(snapshot) = world.resource_mut::<PlayModeSnapshot>().player.take() {
|
||||||
restore_player_sim(world, &snapshot);
|
restore_player_sim(world, &snapshot);
|
||||||
}
|
}
|
||||||
if let Some(mut scene_io) = world.get_resource_mut::<SceneIo>() {
|
world.resource_mut::<SimEnabled>().0 = false;
|
||||||
scene_io.dirty = true;
|
game::animation::reset_authored_animation_runtime(world);
|
||||||
}
|
game::audio::reset_authored_audio_runtime(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn snapshot_player_sim(world: &mut World) -> PlayerSimSnapshot {
|
fn snapshot_player_sim(world: &mut World) -> PlayerSimSnapshot {
|
||||||
|
|||||||
@@ -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,847 @@
|
|||||||
|
//! 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::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())
|
||||||
|
.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);
|
||||||
|
if ui.button("Browse Existing...").clicked() {
|
||||||
|
if let Some(root) = rfd::FileDialog::new().pick_folder() {
|
||||||
|
open_project_from_launcher(world, state, root);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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.button("Choose Empty Folder...").clicked() {
|
||||||
|
state.sandbox_destination = rfd::FileDialog::new().pick_folder();
|
||||||
|
}
|
||||||
|
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,7 @@
|
|||||||
//! Project workspace I/O, settings UI, and recent-level sync.
|
//! Project workspace I/O, settings UI, and recent-level sync.
|
||||||
|
|
||||||
|
pub mod diagnostics_bundle;
|
||||||
|
pub mod launcher;
|
||||||
pub mod project_io;
|
pub mod project_io;
|
||||||
|
pub mod session;
|
||||||
pub mod settings_ui;
|
pub mod settings_ui;
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::{ProjectSettings, ProjectSettingsIo, DEFAULT_PROJECT_PATH};
|
use settings::{ProjectKind, ProjectSettings, ProjectSettingsIo, DEFAULT_PROJECT_PATH};
|
||||||
|
|
||||||
use crate::scene_io::SceneIo;
|
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";
|
const USER_PREFS_FILE: &str = "editor_prefs.ron";
|
||||||
|
|
||||||
/// User-local editor preferences (not checked into the repo).
|
/// 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 struct UserPreferences {
|
||||||
pub recent_projects: Vec<String>,
|
pub recent_projects: Vec<String>,
|
||||||
pub recent_levels: Vec<String>,
|
pub recent_levels: Vec<String>,
|
||||||
@@ -31,16 +31,53 @@ pub struct UserPreferences {
|
|||||||
pub hierarchy_show_runtime: bool,
|
pub hierarchy_show_runtime: bool,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub hierarchy_sort_mode: crate::ui::hierarchy_state::HierarchySort,
|
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 {
|
fn default_true() -> bool {
|
||||||
true
|
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`).
|
/// Active project workspace metadata (mirrors manifest fields in `ProjectSettings`).
|
||||||
#[derive(Resource, Debug, Clone)]
|
#[derive(Resource, Debug, Clone)]
|
||||||
pub struct ProjectWorkspace {
|
pub struct ProjectWorkspace {
|
||||||
pub root: String,
|
pub root: String,
|
||||||
|
pub project_id: String,
|
||||||
|
pub project_kind: ProjectKind,
|
||||||
|
pub last_opened_scene: Option<String>,
|
||||||
pub settings_path: String,
|
pub settings_path: String,
|
||||||
pub settings_dirty: bool,
|
pub settings_dirty: bool,
|
||||||
pub layout_dirty: bool,
|
pub layout_dirty: bool,
|
||||||
@@ -54,6 +91,9 @@ impl Default for ProjectWorkspace {
|
|||||||
.unwrap_or_else(|| ".".into());
|
.unwrap_or_else(|| ".".into());
|
||||||
Self {
|
Self {
|
||||||
root,
|
root,
|
||||||
|
project_id: String::new(),
|
||||||
|
project_kind: ProjectKind::default(),
|
||||||
|
last_opened_scene: None,
|
||||||
settings_path: DEFAULT_PROJECT_PATH.into(),
|
settings_path: DEFAULT_PROJECT_PATH.into(),
|
||||||
settings_dirty: false,
|
settings_dirty: false,
|
||||||
layout_dirty: false,
|
layout_dirty: false,
|
||||||
@@ -73,7 +113,13 @@ impl Plugin for ProjectIoPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn load_user_preferences(mut commands: Commands) {
|
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);
|
commands.insert_resource(prefs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,12 +131,13 @@ pub(crate) fn load_user_preferences_on_startup(commands: Commands) {
|
|||||||
fn sync_workspace_from_settings_system(
|
fn sync_workspace_from_settings_system(
|
||||||
settings: Res<ProjectSettings>,
|
settings: Res<ProjectSettings>,
|
||||||
settings_io: Res<ProjectSettingsIo>,
|
settings_io: Res<ProjectSettingsIo>,
|
||||||
|
scene_io: Res<SceneIo>,
|
||||||
mut workspace: ResMut<ProjectWorkspace>,
|
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;
|
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> {
|
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);
|
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(
|
pub fn sync_workspace_from_settings(
|
||||||
workspace: &mut ProjectWorkspace,
|
workspace: &mut ProjectWorkspace,
|
||||||
settings: &ProjectSettings,
|
settings: &ProjectSettings,
|
||||||
settings_io: &ProjectSettingsIo,
|
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_path = settings_io.path.clone();
|
||||||
workspace.settings_dirty = settings_io.dirty;
|
workspace.settings_dirty = settings_io.dirty;
|
||||||
let _ = settings;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_title(
|
pub fn window_title(
|
||||||
@@ -160,3 +219,21 @@ pub fn window_title(
|
|||||||
}
|
}
|
||||||
parts.join(" — ")
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -210,6 +210,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.separator();
|
||||||
ui.heading("Physics");
|
ui.heading("Physics");
|
||||||
ui.add(egui::Slider::new(&mut draft.physics.walk_speed, 1.0..=15.0).text("Walk speed"));
|
ui.add(egui::Slider::new(&mut draft.physics.walk_speed, 1.0..=15.0).text("Walk speed"));
|
||||||
@@ -231,11 +322,18 @@ fn draw_project_settings_form(
|
|||||||
);
|
);
|
||||||
|
|
||||||
ui.separator();
|
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);
|
commit_project_settings(world, draft);
|
||||||
*io_dirty = true;
|
*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);
|
commit_project_settings(world, draft);
|
||||||
let settings = world.resource::<ProjectSettings>().clone();
|
let settings = world.resource::<ProjectSettings>().clone();
|
||||||
let mut io = world.resource_mut::<ProjectSettingsIo>();
|
let mut io = world.resource_mut::<ProjectSettingsIo>();
|
||||||
@@ -279,7 +377,11 @@ fn apply_project_settings_changes(
|
|||||||
settings: Res<ProjectSettings>,
|
settings: Res<ProjectSettings>,
|
||||||
tuning: ResMut<settings::SimTuning>,
|
tuning: ResMut<settings::SimTuning>,
|
||||||
scene_suns: Query<
|
scene_suns: Query<
|
||||||
(&shared::LightDesc, Option<&shared::InspectorOrder>),
|
(
|
||||||
|
&shared::LightDesc,
|
||||||
|
Option<&shared::AuthoringComponentStates>,
|
||||||
|
Option<&shared::InspectorOrder>,
|
||||||
|
),
|
||||||
With<shared::LevelObject>,
|
With<shared::LevelObject>,
|
||||||
>,
|
>,
|
||||||
project_suns: Query<(&mut DirectionalLight, &mut Visibility), With<shared::ProjectSun>>,
|
project_suns: Query<(&mut DirectionalLight, &mut Visibility), With<shared::ProjectSun>>,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
//! Scene I/O, schema validation, and viewport render-target setup.
|
//! Scene I/O, schema validation, and viewport render-target setup.
|
||||||
|
|
||||||
|
pub(crate) mod recovery;
|
||||||
pub mod scene_io;
|
pub mod scene_io;
|
||||||
pub mod scene_schema;
|
pub mod scene_schema;
|
||||||
pub mod scene_view;
|
pub mod scene_view;
|
||||||
@@ -0,0 +1,328 @@
|
|||||||
|
//! 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(()))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn atomic_write_with_pre_rename(
|
||||||
|
path: &Path,
|
||||||
|
bytes: &[u8],
|
||||||
|
before_rename: impl FnOnce() -> Result<(), String>,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let parent = path
|
||||||
|
.parent()
|
||||||
|
.filter(|parent| !parent.as_os_str().is_empty())
|
||||||
|
.unwrap_or_else(|| Path::new("."));
|
||||||
|
fs::create_dir_all(parent)
|
||||||
|
.map_err(|error| format!("could not create {}: {error}", parent.display()))?;
|
||||||
|
|
||||||
|
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| format!("could not create {}: {error}", temporary.display()))?;
|
||||||
|
file.write_all(bytes)
|
||||||
|
.map_err(|error| format!("could not write {}: {error}", temporary.display()))?;
|
||||||
|
file.sync_all()
|
||||||
|
.map_err(|error| format!("could not sync {}: {error}", temporary.display()))?;
|
||||||
|
before_rename()?;
|
||||||
|
fs::rename(&temporary, path).map_err(|error| {
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
+2306
-130
File diff suppressed because it is too large.
Load diff
@@ -5,11 +5,12 @@ mod transform;
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy_egui::egui;
|
use bevy_egui::egui;
|
||||||
use egui_phosphor_icons::icons;
|
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::ext::extensibility::ActorInspectorSectionRegistry;
|
||||||
use crate::ui::inspector;
|
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 crate::ui::widgets::phosphor_icon;
|
||||||
|
|
||||||
use transform::transform_inspector_ui;
|
use transform::transform_inspector_ui;
|
||||||
@@ -17,6 +18,8 @@ use transform::transform_inspector_ui;
|
|||||||
const COMPACT_ACTOR_HEADER_WIDTH: f32 = 360.0;
|
const COMPACT_ACTOR_HEADER_WIDTH: f32 = 360.0;
|
||||||
|
|
||||||
pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
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 {
|
let Some(entity_ref) = world.get_entity(entity).ok() else {
|
||||||
ui.label("Entity no longer exists.");
|
ui.label("Entity no longer exists.");
|
||||||
return;
|
return;
|
||||||
@@ -26,9 +29,8 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let kind = entity_ref
|
let kind = infer_actor_kind(entity_ref)
|
||||||
.get::<ActorKind>()
|
.or_else(|| entity_ref.get::<ActorKind>().copied())
|
||||||
.copied()
|
|
||||||
.unwrap_or(ActorKind::Empty);
|
.unwrap_or(ActorKind::Empty);
|
||||||
|
|
||||||
egui::Frame::new()
|
egui::Frame::new()
|
||||||
@@ -79,39 +81,69 @@ pub fn draw_actor_inspector(world: &mut World, ui: &mut egui::Ui, entity: Entity
|
|||||||
});
|
});
|
||||||
ui.add_space(6.0);
|
ui.add_space(6.0);
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
if linked_read_only {
|
||||||
.auto_shrink([false, false])
|
ui.small(
|
||||||
.show(ui, |ui| {
|
egui::RichText::new(if prefab_member {
|
||||||
transform_inspector_ui(world, ui, entity);
|
"Linked prefab member"
|
||||||
|
} else {
|
||||||
|
"Linked scene member"
|
||||||
|
})
|
||||||
|
.color(TEXT_DIM),
|
||||||
|
);
|
||||||
|
ui.add_space(4.0);
|
||||||
|
}
|
||||||
|
|
||||||
match kind {
|
if prefab_member {
|
||||||
ActorKind::StaticMesh
|
egui::ScrollArea::vertical()
|
||||||
| ActorKind::Brush
|
.auto_shrink([false, false])
|
||||||
| ActorKind::ImportedModel
|
.show(ui, |ui| {
|
||||||
| ActorKind::Light
|
crate::assets::prefab_overrides::prefab_member_inspector_ui(world, ui, entity);
|
||||||
| 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);
|
|
||||||
});
|
});
|
||||||
|
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::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 {
|
fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
|
||||||
match kind {
|
match kind {
|
||||||
ActorKind::StaticMesh | ActorKind::Brush | ActorKind::ImportedModel => icons::CUBE,
|
ActorKind::StaticMesh
|
||||||
|
| ActorKind::SkinnedMesh
|
||||||
|
| ActorKind::Brush
|
||||||
|
| ActorKind::ImportedModel => icons::CUBE,
|
||||||
ActorKind::Light => icons::LIGHTBULB,
|
ActorKind::Light => icons::LIGHTBULB,
|
||||||
ActorKind::PrefabAnchor => icons::PACKAGE,
|
ActorKind::PrefabAnchor => icons::PACKAGE,
|
||||||
ActorKind::PlayerSpawn => icons::PERSON_SIMPLE_RUN,
|
ActorKind::PlayerSpawn => icons::PERSON_SIMPLE_RUN,
|
||||||
@@ -119,14 +151,53 @@ fn actor_icon(kind: ActorKind) -> egui_phosphor_icons::Icon {
|
|||||||
ActorKind::TriggerVolume => icons::SELECTION,
|
ActorKind::TriggerVolume => icons::SELECTION,
|
||||||
ActorKind::PostProcessVolume => icons::APERTURE,
|
ActorKind::PostProcessVolume => icons::APERTURE,
|
||||||
ActorKind::TeamSpawn | ActorKind::Objective => icons::FLAG,
|
ActorKind::TeamSpawn | ActorKind::Objective => icons::FLAG,
|
||||||
|
ActorKind::AudioSource => icons::SPEAKER_HIGH,
|
||||||
|
ActorKind::AudioListener => icons::HEADPHONES,
|
||||||
|
ActorKind::Navigation => icons::PATH,
|
||||||
ActorKind::Empty => icons::CIRCLE,
|
ActorKind::Empty => icons::CIRCLE,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn draw_multi_actor_inspector(world: &mut World, ui: &mut egui::Ui, entities: &[Entity]) {
|
pub fn draw_multi_actor_inspector(world: &mut World, ui: &mut egui::Ui, entities: &[Entity]) {
|
||||||
ui.heading(format!("{} objects selected", entities.len()));
|
if entities.is_empty() {
|
||||||
ui.label("Multi-edit: use the viewport gizmo for shared transform.");
|
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 {
|
if entities.len() == 1 {
|
||||||
draw_actor_inspector(world, ui, entities[0]);
|
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
@@ -3,7 +3,7 @@
|
|||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use shared::MaterialAsset;
|
use shared::{MaterialAsset, MaterialInstanceAsset};
|
||||||
|
|
||||||
use crate::asset_db::ImportSettings;
|
use crate::asset_db::ImportSettings;
|
||||||
use crate::assets::{AssetSelection, ASSETS_ROOT, BUILTINS_FOLDER};
|
use crate::assets::{AssetSelection, ASSETS_ROOT, BUILTINS_FOLDER};
|
||||||
@@ -28,6 +28,7 @@ pub(crate) enum AssetKindFilter {
|
|||||||
Model,
|
Model,
|
||||||
Texture,
|
Texture,
|
||||||
Material,
|
Material,
|
||||||
|
Audio,
|
||||||
Level,
|
Level,
|
||||||
Prefab,
|
Prefab,
|
||||||
Builtin,
|
Builtin,
|
||||||
@@ -47,6 +48,7 @@ pub struct AssetBrowserUiState {
|
|||||||
pub(crate) pending_delete: Option<AssetDeleteRequest>,
|
pub(crate) pending_delete: Option<AssetDeleteRequest>,
|
||||||
pub(crate) import_draft: Option<ImportSettingsDraft>,
|
pub(crate) import_draft: Option<ImportSettingsDraft>,
|
||||||
pub(crate) material_draft: Option<MaterialAssetDraft>,
|
pub(crate) material_draft: Option<MaterialAssetDraft>,
|
||||||
|
pub(crate) material_instance_draft: Option<MaterialInstanceAssetDraft>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@@ -70,6 +72,13 @@ pub(crate) struct MaterialAssetDraft {
|
|||||||
pub(crate) error: Option<String>,
|
pub(crate) error: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct MaterialInstanceAssetDraft {
|
||||||
|
pub(crate) path: String,
|
||||||
|
pub(crate) asset: MaterialInstanceAsset,
|
||||||
|
pub(crate) error: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for AssetBrowserUiState {
|
impl Default for AssetBrowserUiState {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
let mut expanded_folders = HashSet::new();
|
let mut expanded_folders = HashSet::new();
|
||||||
@@ -88,6 +97,7 @@ impl Default for AssetBrowserUiState {
|
|||||||
pending_delete: None,
|
pending_delete: None,
|
||||||
import_draft: None,
|
import_draft: None,
|
||||||
material_draft: None,
|
material_draft: None,
|
||||||
|
material_instance_draft: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,283 @@
|
|||||||
|
//! Audio source/listener authoring cards and transient audition controls.
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use bevy_egui::egui;
|
||||||
|
use egui_phosphor_icons::icons;
|
||||||
|
use settings::{AUDIO_GAIN_DB_MAX, AUDIO_GAIN_DB_MIN};
|
||||||
|
use shared::{
|
||||||
|
AudioListenerDesc, AudioRolloff, AudioSourceDesc, COMPONENT_AUDIO_LISTENER_DESC,
|
||||||
|
COMPONENT_AUDIO_SOURCE_DESC,
|
||||||
|
};
|
||||||
|
|
||||||
|
use crate::assets::{audio_clip_ref_for_asset, EditorAsset, EditorAssetKind, EditorAssets};
|
||||||
|
use crate::history::{set_audio_listener_with_history, set_audio_source_with_history};
|
||||||
|
use crate::play::audio_preview::{audition_audio_source, stop_audio_preview, AudioPreviewState};
|
||||||
|
use crate::ui::inspector::{
|
||||||
|
apply_component_card_response, component_card, component_card_context, property_row,
|
||||||
|
ComponentCardOptions,
|
||||||
|
};
|
||||||
|
use crate::ui::theme::{SELECTION, TEXT_DIM};
|
||||||
|
|
||||||
|
pub fn audio_source_inspector_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||||
|
let Some(mut source) = world.get::<AudioSourceDesc>(entity).cloned() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let original = source.clone();
|
||||||
|
let audio_assets: Vec<EditorAsset> = world
|
||||||
|
.resource::<EditorAssets>()
|
||||||
|
.assets
|
||||||
|
.iter()
|
||||||
|
.filter(|asset| matches!(asset.kind, EditorAssetKind::AudioClip))
|
||||||
|
.cloned()
|
||||||
|
.collect();
|
||||||
|
let dragged_audio = world
|
||||||
|
.resource::<EditorAssets>()
|
||||||
|
.dragging_selection()
|
||||||
|
.and_then(|selection| {
|
||||||
|
world
|
||||||
|
.resource::<EditorAssets>()
|
||||||
|
.asset_for_selection(selection)
|
||||||
|
})
|
||||||
|
.filter(|asset| matches!(asset.kind, EditorAssetKind::AudioClip))
|
||||||
|
.cloned();
|
||||||
|
let buses = world
|
||||||
|
.resource::<settings::ProjectSettings>()
|
||||||
|
.audio
|
||||||
|
.buses
|
||||||
|
.clone();
|
||||||
|
let previewing = world.resource::<AudioPreviewState>().source == Some(entity);
|
||||||
|
let diagnostics = world
|
||||||
|
.resource::<game::audio::AudioRuntimeDiagnostics>()
|
||||||
|
.clone();
|
||||||
|
let mut pending_clip: Option<EditorAsset> = None;
|
||||||
|
let mut clear_clip = false;
|
||||||
|
let mut audition = false;
|
||||||
|
let mut stop = false;
|
||||||
|
|
||||||
|
let card = component_card_context(
|
||||||
|
world,
|
||||||
|
entity,
|
||||||
|
ComponentCardOptions::removable(
|
||||||
|
COMPONENT_AUDIO_SOURCE_DESC,
|
||||||
|
"Audio Source",
|
||||||
|
icons::SPEAKER_HIGH,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
let card_response = component_card(ui, &card, |ui| {
|
||||||
|
let clip_response = property_row(ui, "Clip", |ui| {
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
let selected_text = source
|
||||||
|
.clip
|
||||||
|
.as_ref()
|
||||||
|
.map(|clip| clip.label.as_str())
|
||||||
|
.filter(|label| !label.trim().is_empty())
|
||||||
|
.unwrap_or("None");
|
||||||
|
egui::ComboBox::from_id_salt(("audio_clip", entity))
|
||||||
|
.selected_text(selected_text)
|
||||||
|
.width(150.0)
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
for asset in &audio_assets {
|
||||||
|
let selected = source.clip.as_ref().is_some_and(|clip| {
|
||||||
|
clip.source_path.as_deref() == asset.path.as_deref()
|
||||||
|
});
|
||||||
|
if ui.selectable_label(selected, &asset.label).clicked() {
|
||||||
|
pending_clip = Some(asset.clone());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ui
|
||||||
|
.add_enabled(source.clip.is_some(), egui::Button::new(icons::X.as_str()))
|
||||||
|
.on_hover_text("Clear clip")
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
clear_clip = true;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.response
|
||||||
|
});
|
||||||
|
if dragged_audio.is_some() && clip_response.hovered() {
|
||||||
|
ui.painter().rect_stroke(
|
||||||
|
clip_response.rect.expand(3.0),
|
||||||
|
3.0,
|
||||||
|
egui::Stroke::new(1.5, SELECTION),
|
||||||
|
egui::StrokeKind::Outside,
|
||||||
|
);
|
||||||
|
if ui.input(|input| input.pointer.any_released()) {
|
||||||
|
pending_clip = dragged_audio.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property_row(ui, "Playback", |ui| {
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
source.clip.is_some() && !previewing,
|
||||||
|
egui::Button::new(format!("{} Audition", icons::PLAY.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
audition = true;
|
||||||
|
}
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
previewing,
|
||||||
|
egui::Button::new(format!("{} Stop", icons::STOP.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
stop = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
property_row(ui, "Gain", |ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::Slider::new(&mut source.gain_db, AUDIO_GAIN_DB_MIN..=AUDIO_GAIN_DB_MAX)
|
||||||
|
.suffix(" dB"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
property_row(ui, "Pitch", |ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut source.pitch)
|
||||||
|
.range(0.25..=4.0)
|
||||||
|
.speed(0.01),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
property_row(ui, "Mode", |ui| {
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
ui.checkbox(&mut source.autoplay, "Autoplay");
|
||||||
|
ui.checkbox(&mut source.looping, "Loop");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
property_row(ui, "Spatial blend", |ui| {
|
||||||
|
ui.add(egui::Slider::new(&mut source.spatial_blend, 0.0..=1.0));
|
||||||
|
});
|
||||||
|
property_row(ui, "Min distance", |ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut source.attenuation.min_distance)
|
||||||
|
.range(0.01..=10_000.0)
|
||||||
|
.speed(0.1)
|
||||||
|
.suffix(" m"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
property_row(ui, "Max distance", |ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut source.attenuation.max_distance)
|
||||||
|
.range(0.02..=100_000.0)
|
||||||
|
.speed(0.25)
|
||||||
|
.suffix(" m"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
property_row(ui, "Rolloff", |ui| {
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
egui::ComboBox::from_id_salt(("audio_rolloff", entity))
|
||||||
|
.selected_text(format!("{:?}", source.attenuation.rolloff))
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
for (rolloff, label) in [
|
||||||
|
(AudioRolloff::Linear, "Linear"),
|
||||||
|
(AudioRolloff::Inverse, "Inverse"),
|
||||||
|
(AudioRolloff::Exponential, "Exponential"),
|
||||||
|
] {
|
||||||
|
ui.selectable_value(&mut source.attenuation.rolloff, rolloff, label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut source.attenuation.rolloff_factor)
|
||||||
|
.range(0.01..=8.0)
|
||||||
|
.speed(0.05),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
property_row(ui, "Bus", |ui| {
|
||||||
|
egui::ComboBox::from_id_salt(("audio_bus", entity))
|
||||||
|
.selected_text(
|
||||||
|
buses
|
||||||
|
.iter()
|
||||||
|
.find(|bus| bus.id == source.bus)
|
||||||
|
.map(|bus| bus.label.as_str())
|
||||||
|
.unwrap_or(source.bus.as_str()),
|
||||||
|
)
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
for bus in &buses {
|
||||||
|
ui.selectable_value(&mut source.bus, bus.id.clone(), &bus.label);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
ui.small(
|
||||||
|
egui::RichText::new(&diagnostics.message)
|
||||||
|
.color(TEXT_DIM)
|
||||||
|
.italics(),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
if clear_clip {
|
||||||
|
source.clip = None;
|
||||||
|
}
|
||||||
|
if let Some(asset) = pending_clip {
|
||||||
|
match audio_clip_ref_for_asset(world, &asset) {
|
||||||
|
Ok(clip) => {
|
||||||
|
source.clip = Some(clip);
|
||||||
|
world.resource_mut::<EditorAssets>().clear_drag();
|
||||||
|
}
|
||||||
|
Err(error) => {
|
||||||
|
world.resource_mut::<crate::scene_io::SceneIo>().status =
|
||||||
|
format!("Audio clip assignment failed: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
source.attenuation.max_distance = source
|
||||||
|
.attenuation
|
||||||
|
.max_distance
|
||||||
|
.max(source.attenuation.min_distance + 0.01);
|
||||||
|
if source != original {
|
||||||
|
set_audio_source_with_history(world, entity, source);
|
||||||
|
}
|
||||||
|
if stop {
|
||||||
|
stop_audio_preview(world);
|
||||||
|
} else if audition {
|
||||||
|
if let Err(error) = audition_audio_source(world, entity) {
|
||||||
|
world.resource_mut::<crate::scene_io::SceneIo>().status =
|
||||||
|
format!("Audio audition failed: {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
apply_component_card_response(world, entity, card_response);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn audio_listener_inspector_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity) {
|
||||||
|
let Some(mut listener) = world.get::<AudioListenerDesc>(entity).copied() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let original = listener;
|
||||||
|
let card = component_card_context(
|
||||||
|
world,
|
||||||
|
entity,
|
||||||
|
ComponentCardOptions::removable(
|
||||||
|
COMPONENT_AUDIO_LISTENER_DESC,
|
||||||
|
"Audio Listener",
|
||||||
|
icons::HEADPHONES,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
let card_response = component_card(ui, &card, |ui| {
|
||||||
|
property_row(ui, "Enabled", |ui| {
|
||||||
|
ui.checkbox(&mut listener.enabled, "Receive spatial audio");
|
||||||
|
});
|
||||||
|
property_row(ui, "Priority", |ui| {
|
||||||
|
ui.add(egui::DragValue::new(&mut listener.priority).speed(1));
|
||||||
|
});
|
||||||
|
property_row(ui, "Ear gap", |ui| {
|
||||||
|
ui.add(
|
||||||
|
egui::DragValue::new(&mut listener.ear_gap)
|
||||||
|
.range(0.01..=2.0)
|
||||||
|
.speed(0.01)
|
||||||
|
.suffix(" m"),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
ui.small(
|
||||||
|
egui::RichText::new("Highest priority enabled listener wins; actor ID breaks ties.")
|
||||||
|
.color(TEXT_DIM),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
if listener != original {
|
||||||
|
set_audio_listener_with_history(world, entity, listener);
|
||||||
|
}
|
||||||
|
apply_component_card_response(world, entity, card_response);
|
||||||
|
}
|
||||||
@@ -0,0 +1,619 @@
|
|||||||
|
//! Non-blocking build/package jobs backed by the headless package command.
|
||||||
|
|
||||||
|
use std::collections::VecDeque;
|
||||||
|
use std::io::{BufRead, BufReader};
|
||||||
|
use std::path::{Path, PathBuf};
|
||||||
|
use std::process::{Command, Stdio};
|
||||||
|
use std::sync::atomic::{AtomicBool, Ordering};
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use bevy::prelude::*;
|
||||||
|
use bevy_egui::egui;
|
||||||
|
use egui_phosphor_icons::icons;
|
||||||
|
|
||||||
|
use crate::project_io::ProjectWorkspace;
|
||||||
|
use crate::scene_io::SceneIo;
|
||||||
|
|
||||||
|
const MAX_LOG_LINES: usize = 1_500;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
|
enum BuildResult {
|
||||||
|
Succeeded(PathBuf),
|
||||||
|
Failed(String),
|
||||||
|
Cancelled,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct BuildJob {
|
||||||
|
log: Arc<Mutex<VecDeque<String>>>,
|
||||||
|
result: Arc<Mutex<Option<BuildResult>>>,
|
||||||
|
cancel: Arc<AtomicBool>,
|
||||||
|
run_after: bool,
|
||||||
|
worker: Option<std::thread::JoinHandle<()>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for BuildJob {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.cancel.store(true, Ordering::Release);
|
||||||
|
if let Some(worker) = self.worker.take() {
|
||||||
|
let _ = worker.join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Resource, Debug)]
|
||||||
|
pub struct BuildPanel {
|
||||||
|
profiles: Vec<String>,
|
||||||
|
selected_profile: String,
|
||||||
|
job: Option<BuildJob>,
|
||||||
|
last_result: Option<BuildResult>,
|
||||||
|
last_output: Option<PathBuf>,
|
||||||
|
last_log: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for BuildPanel {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
profiles: Vec::new(),
|
||||||
|
selected_profile: "development".into(),
|
||||||
|
job: None,
|
||||||
|
last_result: None,
|
||||||
|
last_output: None,
|
||||||
|
last_log: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BuildPanel {
|
||||||
|
pub fn is_running(&self) -> bool {
|
||||||
|
self.job.is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn has_output(&self) -> bool {
|
||||||
|
self.last_output.is_some()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for BuildPanel {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Some(job) = &self.job {
|
||||||
|
job.cancel.store(true, Ordering::Release);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn request_build(world: &mut World, run_after: bool) {
|
||||||
|
refresh_profiles(world);
|
||||||
|
if world.resource::<BuildPanel>().is_running() {
|
||||||
|
world
|
||||||
|
.resource_mut::<SceneIo>()
|
||||||
|
.set_status("A package build is already running");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if world.resource::<SceneIo>().has_unsaved_tabs() {
|
||||||
|
world
|
||||||
|
.resource_mut::<SceneIo>()
|
||||||
|
.set_status("Save all modified scene tabs before building a package");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let engine_root = engine_workspace_root();
|
||||||
|
let root = PathBuf::from(&world.resource::<ProjectWorkspace>().root);
|
||||||
|
let profile = world.resource::<BuildPanel>().selected_profile.clone();
|
||||||
|
let mut panel = world.resource_mut::<BuildPanel>();
|
||||||
|
panel.last_result = None;
|
||||||
|
panel.last_log.clear();
|
||||||
|
panel.job = Some(spawn_build_job(
|
||||||
|
engine_root,
|
||||||
|
root,
|
||||||
|
profile.clone(),
|
||||||
|
run_after,
|
||||||
|
));
|
||||||
|
world
|
||||||
|
.resource_mut::<SceneIo>()
|
||||||
|
.set_status(format!("Building {profile} package..."));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn cancel_build(world: &mut World) {
|
||||||
|
if let Some(job) = world.resource::<BuildPanel>().job.as_ref() {
|
||||||
|
job.cancel.store(true, Ordering::Release);
|
||||||
|
world
|
||||||
|
.resource_mut::<SceneIo>()
|
||||||
|
.set_status("Cancelling package build...");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn reveal_last_output(world: &mut World) {
|
||||||
|
let output = world.resource::<BuildPanel>().last_output.clone();
|
||||||
|
let status = match output {
|
||||||
|
Some(path) if path.is_dir() => match Command::new("xdg-open").arg(&path).spawn() {
|
||||||
|
Ok(child) => {
|
||||||
|
reap_child(child);
|
||||||
|
format!("Revealed {}", path.display())
|
||||||
|
}
|
||||||
|
Err(error) => format!("Could not reveal {}: {error}", path.display()),
|
||||||
|
},
|
||||||
|
_ => "No completed package output is available".into(),
|
||||||
|
};
|
||||||
|
world.resource_mut::<SceneIo>().set_status(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn tick_build_job(world: &mut World) {
|
||||||
|
let completed = world.resource::<BuildPanel>().job.as_ref().and_then(|job| {
|
||||||
|
job.result
|
||||||
|
.lock()
|
||||||
|
.ok()?
|
||||||
|
.clone()
|
||||||
|
.map(|result| (result, job.run_after))
|
||||||
|
});
|
||||||
|
let Some((result, run_after)) = completed else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let status = match &result {
|
||||||
|
BuildResult::Succeeded(path) => {
|
||||||
|
world.resource_mut::<BuildPanel>().last_output = Some(path.clone());
|
||||||
|
if run_after {
|
||||||
|
launch_package(path)
|
||||||
|
.map(|_| format!("Package built and launched from {}", path.display()))
|
||||||
|
.unwrap_or_else(|error| error)
|
||||||
|
} else {
|
||||||
|
format!("Package ready at {}", path.display())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BuildResult::Failed(error) => format!("Package build failed: {error}"),
|
||||||
|
BuildResult::Cancelled => "Package build cancelled".into(),
|
||||||
|
};
|
||||||
|
let completed_log = world
|
||||||
|
.resource::<BuildPanel>()
|
||||||
|
.job
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|job| {
|
||||||
|
job.log
|
||||||
|
.lock()
|
||||||
|
.ok()
|
||||||
|
.map(|log| log.iter().cloned().collect::<Vec<_>>())
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
let mut panel = world.resource_mut::<BuildPanel>();
|
||||||
|
panel.last_result = Some(result);
|
||||||
|
panel.last_log = completed_log;
|
||||||
|
panel.job = None;
|
||||||
|
world.resource_mut::<SceneIo>().set_status(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn build_ui(world: &mut World, ui: &mut egui::Ui) {
|
||||||
|
if world.resource::<BuildPanel>().profiles.is_empty() {
|
||||||
|
refresh_profiles(world);
|
||||||
|
}
|
||||||
|
let running = world.resource::<BuildPanel>().is_running();
|
||||||
|
let profiles = world.resource::<BuildPanel>().profiles.clone();
|
||||||
|
let mut selected = world.resource::<BuildPanel>().selected_profile.clone();
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label("Profile");
|
||||||
|
egui::ComboBox::from_id_salt("build_profile")
|
||||||
|
.selected_text(&selected)
|
||||||
|
.show_ui(ui, |ui| {
|
||||||
|
for profile in &profiles {
|
||||||
|
ui.selectable_value(&mut selected, profile.clone(), profile);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
!running,
|
||||||
|
egui::Button::new(format!("{} Build", icons::HAMMER.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
world.resource_mut::<BuildPanel>().selected_profile = selected.clone();
|
||||||
|
request_build(world, false);
|
||||||
|
}
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
!running,
|
||||||
|
egui::Button::new(format!("{} Build and Run", icons::PLAY.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
world.resource_mut::<BuildPanel>().selected_profile = selected.clone();
|
||||||
|
request_build(world, true);
|
||||||
|
}
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
running,
|
||||||
|
egui::Button::new(format!("{} Cancel", icons::X.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
cancel_build(world);
|
||||||
|
}
|
||||||
|
let can_reveal = world.resource::<BuildPanel>().last_output.is_some();
|
||||||
|
if ui
|
||||||
|
.add_enabled(
|
||||||
|
can_reveal,
|
||||||
|
egui::Button::new(format!("{} Reveal Output", icons::FOLDER_OPEN.as_str())),
|
||||||
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
reveal_last_output(world);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
world.resource_mut::<BuildPanel>().selected_profile = selected;
|
||||||
|
ui.separator();
|
||||||
|
if running {
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.spinner();
|
||||||
|
ui.label("Compiler and packager are running in the background");
|
||||||
|
});
|
||||||
|
} else if let Some(result) = world.resource::<BuildPanel>().last_result.clone() {
|
||||||
|
let (label, color) = match result {
|
||||||
|
BuildResult::Succeeded(path) => (
|
||||||
|
format!("Ready: {}", path.display()),
|
||||||
|
egui::Color32::from_rgb(125, 210, 145),
|
||||||
|
),
|
||||||
|
BuildResult::Failed(error) => (
|
||||||
|
format!("Failed: {error}"),
|
||||||
|
egui::Color32::from_rgb(255, 137, 129),
|
||||||
|
),
|
||||||
|
BuildResult::Cancelled => ("Cancelled".into(), egui::Color32::from_rgb(255, 190, 110)),
|
||||||
|
};
|
||||||
|
ui.colored_label(color, label);
|
||||||
|
} else {
|
||||||
|
ui.label("No package build has run in this session");
|
||||||
|
}
|
||||||
|
let lines = {
|
||||||
|
let panel = world.resource::<BuildPanel>();
|
||||||
|
panel
|
||||||
|
.job
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|job| {
|
||||||
|
job.log
|
||||||
|
.lock()
|
||||||
|
.ok()
|
||||||
|
.map(|log| log.iter().cloned().collect::<Vec<_>>())
|
||||||
|
})
|
||||||
|
.unwrap_or_else(|| panel.last_log.clone())
|
||||||
|
};
|
||||||
|
egui::ScrollArea::vertical()
|
||||||
|
.id_salt("build_output_log")
|
||||||
|
.stick_to_bottom(true)
|
||||||
|
.show(ui, |ui| {
|
||||||
|
for line in lines {
|
||||||
|
ui.monospace(line);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn refresh_profiles(world: &mut World) {
|
||||||
|
let root = PathBuf::from(&world.resource::<ProjectWorkspace>().root);
|
||||||
|
let mut profiles = fs_profiles(&root.join("assets/build_profiles"));
|
||||||
|
if profiles.is_empty() {
|
||||||
|
profiles.push("development".into());
|
||||||
|
}
|
||||||
|
let mut panel = world.resource_mut::<BuildPanel>();
|
||||||
|
if !profiles.contains(&panel.selected_profile) {
|
||||||
|
panel.selected_profile = profiles[0].clone();
|
||||||
|
}
|
||||||
|
panel.profiles = profiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
fn fs_profiles(root: &Path) -> Vec<String> {
|
||||||
|
let mut profiles = std::fs::read_dir(root)
|
||||||
|
.into_iter()
|
||||||
|
.flatten()
|
||||||
|
.flatten()
|
||||||
|
.filter_map(|entry| {
|
||||||
|
let path = entry.path();
|
||||||
|
(path.extension().and_then(|extension| extension.to_str()) == Some("ron"))
|
||||||
|
.then(|| path.file_stem()?.to_str().map(str::to_string))?
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
profiles.sort();
|
||||||
|
profiles
|
||||||
|
}
|
||||||
|
|
||||||
|
fn spawn_build_job(
|
||||||
|
engine_root: PathBuf,
|
||||||
|
project_root: PathBuf,
|
||||||
|
profile: String,
|
||||||
|
run_after: bool,
|
||||||
|
) -> BuildJob {
|
||||||
|
let log = Arc::new(Mutex::new(VecDeque::new()));
|
||||||
|
let result = Arc::new(Mutex::new(None));
|
||||||
|
let cancel = Arc::new(AtomicBool::new(false));
|
||||||
|
let thread_log = Arc::clone(&log);
|
||||||
|
let thread_result = Arc::clone(&result);
|
||||||
|
let thread_cancel = Arc::clone(&cancel);
|
||||||
|
let worker = std::thread::spawn(move || {
|
||||||
|
let mut command = Command::new("cargo");
|
||||||
|
command
|
||||||
|
.current_dir(&engine_root)
|
||||||
|
.args([
|
||||||
|
"package-project",
|
||||||
|
"--project",
|
||||||
|
&project_root.to_string_lossy(),
|
||||||
|
"--profile",
|
||||||
|
&profile,
|
||||||
|
])
|
||||||
|
.stdout(Stdio::piped())
|
||||||
|
.stderr(Stdio::piped());
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::process::CommandExt;
|
||||||
|
command.process_group(0);
|
||||||
|
}
|
||||||
|
let mut child = match command.spawn() {
|
||||||
|
Ok(child) => child,
|
||||||
|
Err(error) => {
|
||||||
|
set_result(
|
||||||
|
&thread_result,
|
||||||
|
BuildResult::Failed(format!("could not start Cargo: {error}")),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let output_path = Arc::new(Mutex::new(None));
|
||||||
|
let stdout_thread = child.stdout.take().map(|stdout| {
|
||||||
|
stream_output(
|
||||||
|
stdout,
|
||||||
|
Arc::clone(&thread_log),
|
||||||
|
Some(Arc::clone(&output_path)),
|
||||||
|
)
|
||||||
|
});
|
||||||
|
let stderr_thread = child
|
||||||
|
.stderr
|
||||||
|
.take()
|
||||||
|
.map(|stderr| stream_output(stderr, Arc::clone(&thread_log), None));
|
||||||
|
let mut poll_error = None;
|
||||||
|
let status = loop {
|
||||||
|
if thread_cancel.load(Ordering::Acquire) {
|
||||||
|
terminate_process_tree(&mut child);
|
||||||
|
let _ = child.wait();
|
||||||
|
break None;
|
||||||
|
}
|
||||||
|
match child.try_wait() {
|
||||||
|
Ok(Some(status)) => break Some(status),
|
||||||
|
Ok(None) => std::thread::sleep(Duration::from_millis(100)),
|
||||||
|
Err(error) => {
|
||||||
|
terminate_process_tree(&mut child);
|
||||||
|
let _ = child.wait();
|
||||||
|
poll_error = Some(format!("could not poll build process: {error}"));
|
||||||
|
break None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if let Some(thread) = stdout_thread {
|
||||||
|
let _ = thread.join();
|
||||||
|
}
|
||||||
|
if let Some(thread) = stderr_thread {
|
||||||
|
let _ = thread.join();
|
||||||
|
}
|
||||||
|
let final_result = match (poll_error, status) {
|
||||||
|
(Some(error), _) => BuildResult::Failed(error),
|
||||||
|
(None, None) => BuildResult::Cancelled,
|
||||||
|
(None, Some(status)) if !status.success() => {
|
||||||
|
BuildResult::Failed(format!("packager exited with {status}"))
|
||||||
|
}
|
||||||
|
(None, Some(_)) => output_path
|
||||||
|
.lock()
|
||||||
|
.ok()
|
||||||
|
.and_then(|path| path.clone())
|
||||||
|
.map(BuildResult::Succeeded)
|
||||||
|
.unwrap_or_else(|| {
|
||||||
|
BuildResult::Failed("packager did not report an output directory".into())
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
set_result(&thread_result, final_result);
|
||||||
|
});
|
||||||
|
BuildJob {
|
||||||
|
log,
|
||||||
|
result,
|
||||||
|
cancel,
|
||||||
|
run_after,
|
||||||
|
worker: Some(worker),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn engine_workspace_root() -> PathBuf {
|
||||||
|
Path::new(env!("CARGO_MANIFEST_DIR"))
|
||||||
|
.parent()
|
||||||
|
.and_then(Path::parent)
|
||||||
|
.expect("editor crate must live under <workspace>/crates/editor")
|
||||||
|
.to_path_buf()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn terminate_process_tree(child: &mut std::process::Child) {
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
let process_group = format!("-{}", child.id());
|
||||||
|
let _ = Command::new("kill")
|
||||||
|
.args(["-TERM", "--", &process_group])
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.status();
|
||||||
|
std::thread::sleep(Duration::from_millis(150));
|
||||||
|
let _ = Command::new("kill")
|
||||||
|
.args(["-KILL", "--", &process_group])
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.status();
|
||||||
|
}
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
let _ = Command::new("taskkill")
|
||||||
|
.args(["/PID", &child.id().to_string(), "/T", "/F"])
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.status();
|
||||||
|
}
|
||||||
|
let _ = child.kill();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stream_output(
|
||||||
|
stream: impl std::io::Read + Send + 'static,
|
||||||
|
log: Arc<Mutex<VecDeque<String>>>,
|
||||||
|
output_path: Option<Arc<Mutex<Option<PathBuf>>>>,
|
||||||
|
) -> std::thread::JoinHandle<()> {
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
for line in BufReader::new(stream).lines().map_while(Result::ok) {
|
||||||
|
if let Some(path) = line.strip_prefix("package-project: ready at ") {
|
||||||
|
if let Some(output_path) = &output_path {
|
||||||
|
if let Ok(mut output_path) = output_path.lock() {
|
||||||
|
*output_path = Some(PathBuf::from(path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Ok(mut log) = log.lock() {
|
||||||
|
log.push_back(line);
|
||||||
|
while log.len() > MAX_LOG_LINES {
|
||||||
|
log.pop_front();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_result(result: &Arc<Mutex<Option<BuildResult>>>, value: BuildResult) {
|
||||||
|
if let Ok(mut result) = result.lock() {
|
||||||
|
*result = Some(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn launch_package(output: &Path) -> Result<(), String> {
|
||||||
|
let metadata_path = output.join("build-metadata.json");
|
||||||
|
let metadata = std::fs::read_to_string(&metadata_path)
|
||||||
|
.map_err(|error| format!("Could not read {}: {error}", metadata_path.display()))?;
|
||||||
|
let metadata: serde_json::Value = serde_json::from_str(&metadata)
|
||||||
|
.map_err(|error| format!("Invalid {}: {error}", metadata_path.display()))?;
|
||||||
|
let target = metadata
|
||||||
|
.get("target")
|
||||||
|
.and_then(serde_json::Value::as_str)
|
||||||
|
.ok_or_else(|| format!("Package target is missing from {}", metadata_path.display()))?;
|
||||||
|
validate_launch_target(target, std::env::consts::ARCH, std::env::consts::OS)?;
|
||||||
|
|
||||||
|
let native_name = if cfg!(windows) {
|
||||||
|
"blacksite.exe"
|
||||||
|
} else {
|
||||||
|
"blacksite"
|
||||||
|
};
|
||||||
|
let foreign_name = if cfg!(windows) {
|
||||||
|
"blacksite"
|
||||||
|
} else {
|
||||||
|
"blacksite.exe"
|
||||||
|
};
|
||||||
|
let executable = output.join(native_name);
|
||||||
|
if !executable.is_file() {
|
||||||
|
let foreign = output.join(foreign_name);
|
||||||
|
if foreign.is_file() {
|
||||||
|
return Err(format!(
|
||||||
|
"Package {} targets a different operating system and cannot run on this host",
|
||||||
|
foreign.display()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
return Err(format!(
|
||||||
|
"Package executable is missing at {}",
|
||||||
|
executable.display()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
let child = Command::new(&executable)
|
||||||
|
.current_dir(output)
|
||||||
|
.spawn()
|
||||||
|
.map_err(|error| format!("Could not launch {}: {error}", executable.display()))?;
|
||||||
|
reap_child(child);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn validate_launch_target(target: &str, host_arch: &str, host_os: &str) -> Result<(), String> {
|
||||||
|
let segments = target.split('-').collect::<Vec<_>>();
|
||||||
|
let target_os = if segments.contains(&"windows") {
|
||||||
|
"windows"
|
||||||
|
} else if segments.contains(&"linux") && !segments.contains(&"android") {
|
||||||
|
"linux"
|
||||||
|
} else {
|
||||||
|
return Err(format!(
|
||||||
|
"Package target `{target}` is not a runnable desktop target"
|
||||||
|
));
|
||||||
|
};
|
||||||
|
let target_arch = segments.first().copied().unwrap_or_default();
|
||||||
|
let target_arch = normalize_architecture(target_arch);
|
||||||
|
let host_arch = normalize_architecture(host_arch);
|
||||||
|
if target_os != host_os || target_arch != host_arch {
|
||||||
|
return Err(format!(
|
||||||
|
"Package targets {target_arch}-{target_os}, but this host is {host_arch}-{host_os}"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn normalize_architecture(architecture: &str) -> &str {
|
||||||
|
match architecture {
|
||||||
|
"i386" | "i486" | "i586" | "i686" | "x86" => "x86",
|
||||||
|
architecture if architecture.starts_with("armv") => "arm",
|
||||||
|
architecture => architecture,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reap_child(mut child: std::process::Child) {
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let _ = child.wait();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn profile_scan_is_sorted_and_uses_file_stems() {
|
||||||
|
let root =
|
||||||
|
std::env::temp_dir().join(format!("blacksite-build-profiles-{}", std::process::id()));
|
||||||
|
let _ = std::fs::remove_dir_all(&root);
|
||||||
|
std::fs::create_dir_all(&root).unwrap();
|
||||||
|
std::fs::write(root.join("release.ron"), "()").unwrap();
|
||||||
|
std::fs::write(root.join("development.ron"), "()").unwrap();
|
||||||
|
std::fs::write(root.join("ignore.txt"), "").unwrap();
|
||||||
|
assert_eq!(fs_profiles(&root), vec!["development", "release"]);
|
||||||
|
std::fs::remove_dir_all(root).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn engine_workspace_contains_the_game_package() {
|
||||||
|
let root = engine_workspace_root();
|
||||||
|
assert!(root.join("Cargo.toml").is_file());
|
||||||
|
assert!(root.join("crates/game/Cargo.toml").is_file());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn cancellation_terminates_the_compiler_process_group() {
|
||||||
|
use std::os::unix::process::CommandExt;
|
||||||
|
use std::time::Instant;
|
||||||
|
|
||||||
|
let mut command = Command::new("sh");
|
||||||
|
command
|
||||||
|
.args(["-c", "(trap '' TERM; sleep 30) & wait"])
|
||||||
|
.stdout(Stdio::null())
|
||||||
|
.stderr(Stdio::null())
|
||||||
|
.process_group(0);
|
||||||
|
let mut child = command.spawn().unwrap();
|
||||||
|
let started = Instant::now();
|
||||||
|
terminate_process_tree(&mut child);
|
||||||
|
let status = child.wait().unwrap();
|
||||||
|
assert!(!status.success());
|
||||||
|
assert!(started.elapsed() < Duration::from_secs(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn package_launch_rejects_same_os_cross_architecture_targets() {
|
||||||
|
assert!(validate_launch_target("x86_64-unknown-linux-gnu", "x86_64", "linux").is_ok());
|
||||||
|
assert!(
|
||||||
|
validate_launch_target("aarch64-unknown-linux-gnu", "x86_64", "linux")
|
||||||
|
.unwrap_err()
|
||||||
|
.contains("aarch64-linux")
|
||||||
|
);
|
||||||
|
assert!(
|
||||||
|
validate_launch_target("x86_64-pc-windows-msvc", "x86_64", "linux")
|
||||||
|
.unwrap_err()
|
||||||
|
.contains("windows")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,12 +1,21 @@
|
|||||||
//! Editor-visible component registry for actor inspector palettes.
|
//! Editor-visible component registry for actor inspector palettes.
|
||||||
|
|
||||||
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
|
use bevy::ecs::reflect::ReflectComponent;
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
|
use bevy::reflect::std_traits::ReflectDefault;
|
||||||
|
use bevy::reflect::GetTypeRegistration;
|
||||||
|
use bevy_egui::egui;
|
||||||
use egui_phosphor_icons::icons;
|
use egui_phosphor_icons::icons;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum EditorComponentCategory {
|
pub enum EditorComponentCategory {
|
||||||
Authoring,
|
Authoring,
|
||||||
Rendering,
|
Rendering,
|
||||||
|
Animation,
|
||||||
|
Audio,
|
||||||
|
Navigation,
|
||||||
Physics,
|
Physics,
|
||||||
Gameplay,
|
Gameplay,
|
||||||
Volumes,
|
Volumes,
|
||||||
@@ -15,6 +24,8 @@ pub enum EditorComponentCategory {
|
|||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct EditorComponentDescriptor {
|
pub struct EditorComponentDescriptor {
|
||||||
|
/// Stable editor/protocol identity. This must not be a Rust type path.
|
||||||
|
pub id: &'static str,
|
||||||
pub type_name: &'static str,
|
pub type_name: &'static str,
|
||||||
pub display_name: &'static str,
|
pub display_name: &'static str,
|
||||||
pub category: EditorComponentCategory,
|
pub category: EditorComponentCategory,
|
||||||
@@ -33,6 +44,266 @@ pub struct EditorComponentDescriptor {
|
|||||||
#[derive(Resource, Debug, Clone)]
|
#[derive(Resource, Debug, Clone)]
|
||||||
pub struct EditorComponentRegistry {
|
pub struct EditorComponentRegistry {
|
||||||
pub descriptors: Vec<EditorComponentDescriptor>,
|
pub descriptors: Vec<EditorComponentDescriptor>,
|
||||||
|
inspectors: HashMap<&'static str, ComponentInspectorFn>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub type ComponentInspectorFn = fn(&mut World, &mut egui::Ui, Entity);
|
||||||
|
|
||||||
|
impl EditorComponentRegistry {
|
||||||
|
/// Registers a statically linked component extension.
|
||||||
|
///
|
||||||
|
/// Stable ids and reflected type paths are both unique. Returning an error
|
||||||
|
/// here prevents a game/editor extension from silently shadowing a built-in.
|
||||||
|
pub fn register(&mut self, descriptor: EditorComponentDescriptor) -> Result<(), String> {
|
||||||
|
if self
|
||||||
|
.descriptors
|
||||||
|
.iter()
|
||||||
|
.any(|existing| existing.id == descriptor.id)
|
||||||
|
{
|
||||||
|
return Err(format!(
|
||||||
|
"duplicate authoring component id `{}`",
|
||||||
|
descriptor.id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if self
|
||||||
|
.descriptors
|
||||||
|
.iter()
|
||||||
|
.any(|existing| existing.type_name == descriptor.type_name)
|
||||||
|
{
|
||||||
|
return Err(format!(
|
||||||
|
"component type `{}` is already registered",
|
||||||
|
descriptor.type_name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
self.descriptors.push(descriptor);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn register_with_inspector(
|
||||||
|
&mut self,
|
||||||
|
descriptor: EditorComponentDescriptor,
|
||||||
|
inspector: ComponentInspectorFn,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
let type_name = descriptor.type_name;
|
||||||
|
self.register(descriptor)?;
|
||||||
|
self.inspectors.insert(type_name, inspector);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn inspector(&self, type_name: &str) -> Option<ComponentInspectorFn> {
|
||||||
|
self.inspectors.get(type_name).copied()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Hard lifecycle requirements keyed by stable component IDs. Keeping this
|
||||||
|
/// lookup in the registry removes requirement policy from inspector code.
|
||||||
|
pub fn required_component_ids(
|
||||||
|
&self,
|
||||||
|
descriptor: &EditorComponentDescriptor,
|
||||||
|
) -> &'static [&'static str] {
|
||||||
|
match descriptor.id {
|
||||||
|
shared::AUTHORING_COMPONENT_ANIMATION_CONTROLLER => {
|
||||||
|
&[shared::AUTHORING_COMPONENT_SKINNED_MESH_RENDERER]
|
||||||
|
}
|
||||||
|
_ => &[],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn present_dependents(
|
||||||
|
&self,
|
||||||
|
world: &World,
|
||||||
|
entity: Entity,
|
||||||
|
required_id: &str,
|
||||||
|
) -> Vec<&EditorComponentDescriptor> {
|
||||||
|
self.descriptors
|
||||||
|
.iter()
|
||||||
|
.filter(|descriptor| {
|
||||||
|
self.required_component_ids(descriptor)
|
||||||
|
.contains(&required_id)
|
||||||
|
&& self.component_present(world, entity, descriptor.type_name)
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn by_id(&self, id: &str) -> Option<&EditorComponentDescriptor> {
|
||||||
|
self.descriptors
|
||||||
|
.iter()
|
||||||
|
.find(|descriptor| descriptor.id == id)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn by_type_name(&self, type_name: &str) -> Option<&EditorComponentDescriptor> {
|
||||||
|
self.descriptors
|
||||||
|
.iter()
|
||||||
|
.find(|descriptor| descriptor.type_name == type_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stable_id_for_type<'a>(&self, type_name: &'a str) -> &'a str {
|
||||||
|
self.by_type_name(type_name)
|
||||||
|
.map(|descriptor| descriptor.id)
|
||||||
|
.unwrap_or(type_name)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ensure_component_order(&self, order: &mut shared::InspectorOrder, present: &[&str]) {
|
||||||
|
for type_name in present {
|
||||||
|
let component_id = self.stable_id_for_type(type_name);
|
||||||
|
if !order
|
||||||
|
.component_ids
|
||||||
|
.iter()
|
||||||
|
.any(|existing| existing == component_id)
|
||||||
|
{
|
||||||
|
order.component_ids.push(component_id.to_string());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order.component_type_names.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn ordered_components<'a>(
|
||||||
|
&self,
|
||||||
|
order: &shared::InspectorOrder,
|
||||||
|
present: &[&'a str],
|
||||||
|
) -> Vec<&'a str> {
|
||||||
|
let mut ordered = Vec::new();
|
||||||
|
for component_id in &order.component_ids {
|
||||||
|
if let Some(type_name) = present
|
||||||
|
.iter()
|
||||||
|
.find(|type_name| self.stable_id_for_type(type_name) == component_id)
|
||||||
|
{
|
||||||
|
ordered.push(*type_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for legacy_type_name in &order.component_type_names {
|
||||||
|
if let Some(type_name) = present
|
||||||
|
.iter()
|
||||||
|
.find(|type_name| **type_name == legacy_type_name)
|
||||||
|
{
|
||||||
|
if !ordered.contains(type_name) {
|
||||||
|
ordered.push(*type_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for type_name in present {
|
||||||
|
if !ordered.contains(type_name) {
|
||||||
|
ordered.push(*type_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ordered
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn move_component(
|
||||||
|
&self,
|
||||||
|
order: &mut shared::InspectorOrder,
|
||||||
|
type_name: &str,
|
||||||
|
offset: isize,
|
||||||
|
present: &[&str],
|
||||||
|
) -> bool {
|
||||||
|
self.ensure_component_order(order, present);
|
||||||
|
let component_id = self.stable_id_for_type(type_name);
|
||||||
|
let Some(index) = order
|
||||||
|
.component_ids
|
||||||
|
.iter()
|
||||||
|
.position(|existing| existing == component_id)
|
||||||
|
else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let target =
|
||||||
|
(index as isize + offset).clamp(0, order.component_ids.len() as isize - 1) as usize;
|
||||||
|
if index == target {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
let item = order.component_ids.remove(index);
|
||||||
|
order.component_ids.insert(target, item);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn component_present(&self, world: &World, entity: Entity, type_name: &str) -> bool {
|
||||||
|
let Ok(entity_ref) = world.get_entity(entity) else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let Some(app_registry) = world.get_resource::<AppTypeRegistry>() else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
let type_registry = app_registry.read();
|
||||||
|
type_registry
|
||||||
|
.get_with_type_path(type_name)
|
||||||
|
.and_then(|registration| registration.data::<ReflectComponent>())
|
||||||
|
.is_some_and(|component| component.contains(entity_ref))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Validates registry metadata against Bevy reflection before the first
|
||||||
|
/// inspector frame. This is also the contract test used by extensions.
|
||||||
|
pub fn validate(&self, world: &World) -> Result<(), Vec<String>> {
|
||||||
|
let Some(app_registry) = world.get_resource::<AppTypeRegistry>() else {
|
||||||
|
return Err(vec!["AppTypeRegistry is unavailable".to_string()]);
|
||||||
|
};
|
||||||
|
let type_registry = app_registry.read();
|
||||||
|
let mut errors = Vec::new();
|
||||||
|
let mut ids = HashSet::new();
|
||||||
|
let mut type_names = HashSet::new();
|
||||||
|
for descriptor in &self.descriptors {
|
||||||
|
if descriptor.id.trim().is_empty() {
|
||||||
|
errors.push(format!(
|
||||||
|
"{} has an empty stable id",
|
||||||
|
descriptor.display_name
|
||||||
|
));
|
||||||
|
} else if !ids.insert(descriptor.id) {
|
||||||
|
errors.push(format!("duplicate stable id `{}`", descriptor.id));
|
||||||
|
}
|
||||||
|
if !type_names.insert(descriptor.type_name) {
|
||||||
|
errors.push(format!(
|
||||||
|
"duplicate reflected type `{}`",
|
||||||
|
descriptor.type_name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
match type_registry.get_with_type_path(descriptor.type_name) {
|
||||||
|
Some(registration) if registration.data::<ReflectComponent>().is_none() => errors
|
||||||
|
.push(format!(
|
||||||
|
"`{}` is registered without ReflectComponent",
|
||||||
|
descriptor.type_name
|
||||||
|
)),
|
||||||
|
None => errors.push(format!(
|
||||||
|
"reflected component `{}` is not registered",
|
||||||
|
descriptor.type_name
|
||||||
|
)),
|
||||||
|
Some(registration)
|
||||||
|
if descriptor.addable && registration.data::<ReflectDefault>().is_none() =>
|
||||||
|
{
|
||||||
|
errors.push(format!(
|
||||||
|
"addable component `{}` has no reflected Default",
|
||||||
|
descriptor.type_name
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Some(_) => {}
|
||||||
|
}
|
||||||
|
for relation in descriptor
|
||||||
|
.recommended
|
||||||
|
.iter()
|
||||||
|
.chain(descriptor.conflicts_with.iter())
|
||||||
|
{
|
||||||
|
if !self
|
||||||
|
.descriptors
|
||||||
|
.iter()
|
||||||
|
.any(|candidate| candidate.type_name == *relation)
|
||||||
|
{
|
||||||
|
errors.push(format!(
|
||||||
|
"{} references unregistered component `{relation}`",
|
||||||
|
descriptor.id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for required_id in self.required_component_ids(descriptor) {
|
||||||
|
if self.by_id(required_id).is_none() {
|
||||||
|
errors.push(format!(
|
||||||
|
"{} requires unknown stable component id `{required_id}`",
|
||||||
|
descriptor.id
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if errors.is_empty() {
|
||||||
|
Ok(())
|
||||||
|
} else {
|
||||||
|
Err(errors)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for EditorComponentRegistry {
|
impl Default for EditorComponentRegistry {
|
||||||
@@ -40,6 +311,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
Self {
|
Self {
|
||||||
descriptors: vec![
|
descriptors: vec![
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_STATIC_MESH_RENDERER,
|
||||||
type_name: "shared::components::StaticMeshRenderer",
|
type_name: "shared::components::StaticMeshRenderer",
|
||||||
display_name: "Static Mesh Renderer",
|
display_name: "Static Mesh Renderer",
|
||||||
category: EditorComponentCategory::Rendering,
|
category: EditorComponentCategory::Rendering,
|
||||||
@@ -54,11 +326,35 @@ impl Default for EditorComponentRegistry {
|
|||||||
conflicts_with: &[
|
conflicts_with: &[
|
||||||
"shared::components::Primitive",
|
"shared::components::Primitive",
|
||||||
"shared::components::BrushDesc",
|
"shared::components::BrushDesc",
|
||||||
|
"shared::animation::SkinnedMeshRenderer",
|
||||||
],
|
],
|
||||||
hydration_effect:
|
hydration_effect:
|
||||||
"Hydrates into generated mesh children and material bindings.",
|
"Hydrates into generated mesh children and material bindings.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_SKINNED_MESH_RENDERER,
|
||||||
|
type_name: "shared::animation::SkinnedMeshRenderer",
|
||||||
|
display_name: "Skinned Mesh Renderer",
|
||||||
|
category: EditorComponentCategory::Rendering,
|
||||||
|
addable: false,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::PERSON_SIMPLE_RUN.as_str(),
|
||||||
|
description:
|
||||||
|
"Renders rigged geometry while preserving its imported joints and skin bindings.",
|
||||||
|
search_terms: &["mesh", "renderer", "skinned", "skeletal", "rigged", "joints"],
|
||||||
|
recommended: &["shared::animation::AnimationControllerDesc"],
|
||||||
|
conflicts_with: &[
|
||||||
|
"shared::components::Primitive",
|
||||||
|
"shared::components::BrushDesc",
|
||||||
|
"shared::components::StaticMeshRenderer",
|
||||||
|
],
|
||||||
|
hydration_effect:
|
||||||
|
"Hydrates through a dedicated scene root containing Bevy skinned meshes and joints.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_BRUSH,
|
||||||
type_name: "shared::components::BrushDesc",
|
type_name: "shared::components::BrushDesc",
|
||||||
display_name: "Brush",
|
display_name: "Brush",
|
||||||
category: EditorComponentCategory::Authoring,
|
category: EditorComponentCategory::Authoring,
|
||||||
@@ -73,10 +369,12 @@ impl Default for EditorComponentRegistry {
|
|||||||
conflicts_with: &[
|
conflicts_with: &[
|
||||||
"shared::components::Primitive",
|
"shared::components::Primitive",
|
||||||
"shared::components::StaticMeshRenderer",
|
"shared::components::StaticMeshRenderer",
|
||||||
|
"shared::animation::SkinnedMeshRenderer",
|
||||||
],
|
],
|
||||||
hydration_effect: "Hydrates into generated brush mesh children.",
|
hydration_effect: "Hydrates into generated brush mesh children.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_MATERIAL,
|
||||||
type_name: "shared::components::MaterialDesc",
|
type_name: "shared::components::MaterialDesc",
|
||||||
display_name: "Authoring Material",
|
display_name: "Authoring Material",
|
||||||
category: EditorComponentCategory::Rendering,
|
category: EditorComponentCategory::Rendering,
|
||||||
@@ -92,6 +390,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into Bevy material assets for renderable actors.",
|
hydration_effect: "Hydrates into Bevy material assets for renderable actors.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_RIGID_BODY,
|
||||||
type_name: "shared::components::RigidBodyDesc",
|
type_name: "shared::components::RigidBodyDesc",
|
||||||
display_name: "Rigid Body",
|
display_name: "Rigid Body",
|
||||||
category: EditorComponentCategory::Physics,
|
category: EditorComponentCategory::Physics,
|
||||||
@@ -107,6 +406,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into runtime Avian rigid-body state.",
|
hydration_effect: "Hydrates into runtime Avian rigid-body state.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_COLLIDER,
|
||||||
type_name: "shared::components::ColliderDesc",
|
type_name: "shared::components::ColliderDesc",
|
||||||
display_name: "Collider",
|
display_name: "Collider",
|
||||||
category: EditorComponentCategory::Physics,
|
category: EditorComponentCategory::Physics,
|
||||||
@@ -122,6 +422,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into runtime Avian collider state.",
|
hydration_effect: "Hydrates into runtime Avian collider state.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_LIGHT,
|
||||||
type_name: "shared::components::LightDesc",
|
type_name: "shared::components::LightDesc",
|
||||||
display_name: "Light",
|
display_name: "Light",
|
||||||
category: EditorComponentCategory::Rendering,
|
category: EditorComponentCategory::Rendering,
|
||||||
@@ -137,6 +438,58 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into runtime Bevy light components.",
|
hydration_effect: "Hydrates into runtime Bevy light components.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_ANIMATION_CONTROLLER,
|
||||||
|
type_name: "shared::animation::AnimationControllerDesc",
|
||||||
|
display_name: "Animation Controller",
|
||||||
|
category: EditorComponentCategory::Animation,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::FILM_SLATE.as_str(),
|
||||||
|
description: "Authors named animation states for an imported model rig.",
|
||||||
|
search_terms: &["animation", "controller", "state", "clip", "skeleton", "rig"],
|
||||||
|
recommended: &["shared::animation::SkinnedMeshRenderer"],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect:
|
||||||
|
"Hydrates into a Bevy animation graph and player bound to the imported model.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_AUDIO_SOURCE,
|
||||||
|
type_name: "shared::components::AudioSourceDesc",
|
||||||
|
display_name: "Audio Source",
|
||||||
|
category: EditorComponentCategory::Audio,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::SPEAKER_HIGH.as_str(),
|
||||||
|
description: "Plays a routed 2D or spatial audio clip from this actor.",
|
||||||
|
search_terms: &["audio", "sound", "clip", "speaker", "spatial"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &["shared::components::AudioListenerDesc"],
|
||||||
|
hydration_effect:
|
||||||
|
"Hydrates into runtime Bevy audio voices with bus and attenuation control.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_AUDIO_LISTENER,
|
||||||
|
type_name: "shared::components::AudioListenerDesc",
|
||||||
|
display_name: "Audio Listener",
|
||||||
|
category: EditorComponentCategory::Audio,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::HEADPHONES.as_str(),
|
||||||
|
description: "Receives spatial audio at this actor transform.",
|
||||||
|
search_terms: &["audio", "sound", "listener", "ears", "spatial"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &["shared::components::AudioSourceDesc"],
|
||||||
|
hydration_effect:
|
||||||
|
"The highest-priority enabled listener becomes the runtime listener.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_PRIMITIVE,
|
||||||
type_name: "shared::components::Primitive",
|
type_name: "shared::components::Primitive",
|
||||||
display_name: "Primitive",
|
display_name: "Primitive",
|
||||||
category: EditorComponentCategory::Authoring,
|
category: EditorComponentCategory::Authoring,
|
||||||
@@ -151,11 +504,13 @@ impl Default for EditorComponentRegistry {
|
|||||||
conflicts_with: &[
|
conflicts_with: &[
|
||||||
"shared::components::StaticMeshRenderer",
|
"shared::components::StaticMeshRenderer",
|
||||||
"shared::components::BrushDesc",
|
"shared::components::BrushDesc",
|
||||||
|
"shared::animation::SkinnedMeshRenderer",
|
||||||
],
|
],
|
||||||
hydration_effect:
|
hydration_effect:
|
||||||
"Hydrates into generated primitive render and collision data.",
|
"Hydrates into generated primitive render and collision data.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_PLAYER_SPAWN,
|
||||||
type_name: "shared::components::PlayerSpawn",
|
type_name: "shared::components::PlayerSpawn",
|
||||||
display_name: "Player Spawn",
|
display_name: "Player Spawn",
|
||||||
category: EditorComponentCategory::Gameplay,
|
category: EditorComponentCategory::Gameplay,
|
||||||
@@ -172,6 +527,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
"Used by PIE/session startup; no saved runtime player is created.",
|
"Used by PIE/session startup; no saved runtime player is created.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_WEAPON_SPAWN,
|
||||||
type_name: "shared::components::WeaponSpawn",
|
type_name: "shared::components::WeaponSpawn",
|
||||||
display_name: "Weapon Spawn",
|
display_name: "Weapon Spawn",
|
||||||
category: EditorComponentCategory::Gameplay,
|
category: EditorComponentCategory::Gameplay,
|
||||||
@@ -187,6 +543,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into gameplay spawn metadata.",
|
hydration_effect: "Hydrates into gameplay spawn metadata.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_TRIGGER_VOLUME,
|
||||||
type_name: "shared::components::TriggerVolume",
|
type_name: "shared::components::TriggerVolume",
|
||||||
display_name: "Trigger Volume",
|
display_name: "Trigger Volume",
|
||||||
category: EditorComponentCategory::Volumes,
|
category: EditorComponentCategory::Volumes,
|
||||||
@@ -202,6 +559,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into gameplay trigger queries and visualizers.",
|
hydration_effect: "Hydrates into gameplay trigger queries and visualizers.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_TEAM_SPAWN,
|
||||||
type_name: "shared::components::TeamSpawn",
|
type_name: "shared::components::TeamSpawn",
|
||||||
display_name: "Team Spawn",
|
display_name: "Team Spawn",
|
||||||
category: EditorComponentCategory::Gameplay,
|
category: EditorComponentCategory::Gameplay,
|
||||||
@@ -217,6 +575,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into gameplay spawn metadata.",
|
hydration_effect: "Hydrates into gameplay spawn metadata.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_OBJECTIVE,
|
||||||
type_name: "shared::components::ObjectiveMarker",
|
type_name: "shared::components::ObjectiveMarker",
|
||||||
display_name: "Objective Marker",
|
display_name: "Objective Marker",
|
||||||
category: EditorComponentCategory::Gameplay,
|
category: EditorComponentCategory::Gameplay,
|
||||||
@@ -232,6 +591,7 @@ impl Default for EditorComponentRegistry {
|
|||||||
hydration_effect: "Hydrates into gameplay objective metadata.",
|
hydration_effect: "Hydrates into gameplay objective metadata.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_POST_PROCESS_VOLUME,
|
||||||
type_name: "shared::components::PostProcessVolumeDesc",
|
type_name: "shared::components::PostProcessVolumeDesc",
|
||||||
display_name: "Post-Process Volume",
|
display_name: "Post-Process Volume",
|
||||||
category: EditorComponentCategory::Volumes,
|
category: EditorComponentCategory::Volumes,
|
||||||
@@ -248,6 +608,215 @@ impl Default for EditorComponentRegistry {
|
|||||||
"Affects active camera rendering when the camera is inside the volume.",
|
"Affects active camera rendering when the camera is inside the volume.",
|
||||||
},
|
},
|
||||||
EditorComponentDescriptor {
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_NAVIGATION_BOUNDS,
|
||||||
|
type_name: "shared::navigation::NavigationBounds",
|
||||||
|
display_name: "Navigation Bounds",
|
||||||
|
category: EditorComponentCategory::Navigation,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::PATH.as_str(),
|
||||||
|
description: "Defines the world region and agent profile for a navigation bake.",
|
||||||
|
search_terms: &["navigation", "navmesh", "bounds", "agent", "bake"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[
|
||||||
|
"shared::navigation::NavigationObstacle",
|
||||||
|
"shared::navigation::NavigationArea",
|
||||||
|
"shared::navigation::NavigationLink",
|
||||||
|
],
|
||||||
|
hydration_effect: "Feeds the generated navigation artifact; no render component is hydrated.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_NAVIGATION_OBSTACLE,
|
||||||
|
type_name: "shared::navigation::NavigationObstacle",
|
||||||
|
display_name: "Navigation Obstacle",
|
||||||
|
category: EditorComponentCategory::Navigation,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::SELECTION_SLASH.as_str(),
|
||||||
|
description: "Carves an axis-aligned blocked volume from overlapping bakes.",
|
||||||
|
search_terms: &["navigation", "navmesh", "obstacle", "block", "carve"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[
|
||||||
|
"shared::navigation::NavigationBounds",
|
||||||
|
"shared::navigation::NavigationArea",
|
||||||
|
"shared::navigation::NavigationLink",
|
||||||
|
],
|
||||||
|
hydration_effect: "Contributes a deterministic unwalkable volume during bake.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_NAVIGATION_AREA,
|
||||||
|
type_name: "shared::navigation::NavigationArea",
|
||||||
|
display_name: "Navigation Area",
|
||||||
|
category: EditorComponentCategory::Navigation,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::POLYGON.as_str(),
|
||||||
|
description: "Labels a walkable or blocked navigation area and traversal cost.",
|
||||||
|
search_terms: &["navigation", "navmesh", "area", "cost", "walkable"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[
|
||||||
|
"shared::navigation::NavigationBounds",
|
||||||
|
"shared::navigation::NavigationObstacle",
|
||||||
|
"shared::navigation::NavigationLink",
|
||||||
|
],
|
||||||
|
hydration_effect: "Stores area metadata and blocked-volume contribution in the bake artifact.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_NAVIGATION_LINK,
|
||||||
|
type_name: "shared::navigation::NavigationLink",
|
||||||
|
display_name: "Navigation Link",
|
||||||
|
category: EditorComponentCategory::Navigation,
|
||||||
|
addable: true,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::LINK.as_str(),
|
||||||
|
description: "Connects otherwise isolated navigation regions with an explicit traversal.",
|
||||||
|
search_terms: &["navigation", "navmesh", "link", "jump", "door", "ladder"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[
|
||||||
|
"shared::navigation::NavigationBounds",
|
||||||
|
"shared::navigation::NavigationObstacle",
|
||||||
|
"shared::navigation::NavigationArea",
|
||||||
|
],
|
||||||
|
hydration_effect: "Adds a validated directed or bidirectional runtime path connection.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: shared::AUTHORING_COMPONENT_LEGACY_PHYSICS_BODY,
|
||||||
|
type_name: "shared::components::PhysicsBody",
|
||||||
|
display_name: "Legacy Physics Body",
|
||||||
|
category: EditorComponentCategory::Physics,
|
||||||
|
addable: false,
|
||||||
|
removable: true,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::SPHERE.as_str(),
|
||||||
|
description: "Legacy combined physics authoring retained for scene compatibility.",
|
||||||
|
search_terms: &["legacy", "physics", "body"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Hydrates through the compatibility physics path.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "prefab.instance",
|
||||||
|
type_name: "shared::components::PrefabInstance",
|
||||||
|
display_name: "Prefab Instance",
|
||||||
|
category: EditorComponentCategory::Authoring,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::PACKAGE.as_str(),
|
||||||
|
description: "Stores a linked prefab instance and its overrides.",
|
||||||
|
search_terms: &["prefab", "instance", "link"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Hydrates linked prefab members beneath this anchor.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "prefab.reference",
|
||||||
|
type_name: "shared::components::PrefabRef",
|
||||||
|
display_name: "Prefab Reference",
|
||||||
|
category: EditorComponentCategory::Authoring,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: false,
|
||||||
|
hidden: true,
|
||||||
|
icon: icons::PACKAGE.as_str(),
|
||||||
|
description: "Stable source reference owned by a prefab anchor.",
|
||||||
|
search_terms: &["prefab", "reference"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Resolves the prefab source asset.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "render.imported_model",
|
||||||
|
type_name: "shared::components::ModelRef",
|
||||||
|
display_name: "Imported Model Reference",
|
||||||
|
category: EditorComponentCategory::Rendering,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: false,
|
||||||
|
hidden: true,
|
||||||
|
icon: icons::CUBE_TRANSPARENT.as_str(),
|
||||||
|
description: "Legacy full-scene imported model reference.",
|
||||||
|
search_terms: &["model", "imported", "scene"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Hydrates the referenced imported model scene.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "render.material_override_legacy",
|
||||||
|
type_name: "shared::components::MaterialOverride",
|
||||||
|
display_name: "Legacy Material Override",
|
||||||
|
category: EditorComponentCategory::Rendering,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: false,
|
||||||
|
hidden: true,
|
||||||
|
icon: icons::PALETTE.as_str(),
|
||||||
|
description: "Legacy renderer material slot overrides retained for migration.",
|
||||||
|
search_terms: &["material", "override", "legacy"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Applies compatibility material overrides.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "render.project_sun",
|
||||||
|
type_name: "shared::components::ProjectSun",
|
||||||
|
display_name: "Project Sun",
|
||||||
|
category: EditorComponentCategory::Rendering,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: true,
|
||||||
|
hidden: false,
|
||||||
|
icon: icons::SUN.as_str(),
|
||||||
|
description: "Marks the scene light that overrides the project sun.",
|
||||||
|
search_terms: &["sun", "directional", "project"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Selects the authored directional project light.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "core.actor_kind",
|
||||||
|
type_name: "shared::components::ActorKind",
|
||||||
|
display_name: "Actor Kind Hint",
|
||||||
|
category: EditorComponentCategory::Editor,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: false,
|
||||||
|
hidden: true,
|
||||||
|
icon: icons::TAG.as_str(),
|
||||||
|
description: "Compatibility and presentation hint derived from primary components.",
|
||||||
|
search_terms: &["actor", "kind", "hint"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "No runtime effect; validation uses component composition.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "editor.component_states",
|
||||||
|
type_name: "shared::components::AuthoringComponentStates",
|
||||||
|
display_name: "Authoring Component States",
|
||||||
|
category: EditorComponentCategory::Editor,
|
||||||
|
addable: false,
|
||||||
|
removable: false,
|
||||||
|
reorderable: false,
|
||||||
|
hidden: true,
|
||||||
|
icon: icons::TOGGLE_LEFT.as_str(),
|
||||||
|
description: "Stores persisted component enable state independently of inspector layout.",
|
||||||
|
search_terms: &["editor", "active", "enabled"],
|
||||||
|
recommended: &[],
|
||||||
|
conflicts_with: &[],
|
||||||
|
hydration_effect: "Controls whether opted-in authoring components hydrate.",
|
||||||
|
},
|
||||||
|
EditorComponentDescriptor {
|
||||||
|
id: "editor.inspector_order",
|
||||||
type_name: "shared::components::InspectorOrder",
|
type_name: "shared::components::InspectorOrder",
|
||||||
display_name: "Inspector Order",
|
display_name: "Inspector Order",
|
||||||
category: EditorComponentCategory::Editor,
|
category: EditorComponentCategory::Editor,
|
||||||
@@ -256,14 +825,62 @@ impl Default for EditorComponentRegistry {
|
|||||||
reorderable: false,
|
reorderable: false,
|
||||||
hidden: true,
|
hidden: true,
|
||||||
icon: icons::LIST_BULLETS.as_str(),
|
icon: icons::LIST_BULLETS.as_str(),
|
||||||
description: "Stores editor-only component ordering and active-state metadata.",
|
description: "Stores editor-only component card ordering.",
|
||||||
search_terms: &["editor", "order"],
|
search_terms: &["editor", "order"],
|
||||||
recommended: &[],
|
recommended: &[],
|
||||||
conflicts_with: &[],
|
conflicts_with: &[],
|
||||||
hydration_effect:
|
hydration_effect: "Controls editor presentation only; runtime active state is stored separately.",
|
||||||
"Controls editor presentation and authoring component active state.",
|
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
inspectors: HashMap::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Registers one statically linked game/editor component with reflection,
|
||||||
|
/// lifecycle metadata, and its editor inspector in a single call.
|
||||||
|
pub fn register_authoring_component<T>(
|
||||||
|
app: &mut App,
|
||||||
|
descriptor: EditorComponentDescriptor,
|
||||||
|
inspector: ComponentInspectorFn,
|
||||||
|
) -> Result<(), String>
|
||||||
|
where
|
||||||
|
T: Component + Reflect + GetTypeRegistration,
|
||||||
|
{
|
||||||
|
app.register_type::<T>();
|
||||||
|
if !app.world().contains_resource::<EditorComponentRegistry>() {
|
||||||
|
app.init_resource::<EditorComponentRegistry>();
|
||||||
|
}
|
||||||
|
app.world_mut()
|
||||||
|
.resource_mut::<EditorComponentRegistry>()
|
||||||
|
.register_with_inspector(descriptor, inspector)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn built_in_registry_is_unique_and_reflectable() {
|
||||||
|
let mut app = App::new();
|
||||||
|
app.add_plugins(shared::SharedTypesPlugin)
|
||||||
|
.init_resource::<EditorComponentRegistry>();
|
||||||
|
|
||||||
|
app.world()
|
||||||
|
.resource::<EditorComponentRegistry>()
|
||||||
|
.validate(app.world())
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn static_extensions_cannot_shadow_stable_ids_or_types() {
|
||||||
|
let mut registry = EditorComponentRegistry::default();
|
||||||
|
let mut duplicate = registry.descriptors[0].clone();
|
||||||
|
duplicate.type_name = "game::editor_ext::StaticFixture";
|
||||||
|
assert!(registry.register(duplicate).is_err());
|
||||||
|
|
||||||
|
let mut duplicate = registry.descriptors[0].clone();
|
||||||
|
duplicate.id = "game.static_fixture";
|
||||||
|
assert!(registry.register(duplicate).is_err());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,16 +8,19 @@ use shared::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::assets::EditorAssets;
|
use crate::assets::EditorAssets;
|
||||||
|
use crate::diagnostics_bundle::export_diagnostic_bundle;
|
||||||
use crate::history::set_brush_with_history;
|
use crate::history::set_brush_with_history;
|
||||||
use crate::history::EditorHistory;
|
use crate::history::EditorHistory;
|
||||||
use crate::project_io::ProjectWorkspace;
|
use crate::project_io::ProjectWorkspace;
|
||||||
use crate::scene_io::SceneIo;
|
use crate::scene_io::{SceneIo, SceneIoEventSeverity};
|
||||||
use crate::selection::SelectedEntity;
|
use crate::selection::SelectedEntity;
|
||||||
use crate::ui::UiState;
|
use crate::ui::UiState;
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
pub struct DiagnosticsPanel {
|
pub struct DiagnosticsPanel {
|
||||||
pub open: bool,
|
pub open: bool,
|
||||||
|
pub bundle_status: Option<String>,
|
||||||
|
pub project_validation: Option<scene::ProjectValidationReport>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Resource, Default)]
|
#[derive(Resource, Default)]
|
||||||
@@ -26,10 +29,18 @@ pub struct BrushDiagnosticsPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn diagnostics_ui(world: &mut World, ui: &mut egui::Ui) {
|
pub fn diagnostics_ui(world: &mut World, ui: &mut egui::Ui) {
|
||||||
let scene_io = world.resource::<SceneIo>();
|
let (scene_label, dirty, status, scene_events) = {
|
||||||
let dirty = if scene_io.dirty { " (dirty)" } else { "" };
|
let scene_io = world.resource::<SceneIo>();
|
||||||
ui.label(format!("Scene: {}{dirty}", scene_io.active_path_label()));
|
(
|
||||||
ui.label(format!("Status: {}", scene_io.status));
|
scene_io.active_path_label(),
|
||||||
|
scene_io.dirty,
|
||||||
|
scene_io.status.clone(),
|
||||||
|
scene_io.events.iter().rev().cloned().collect::<Vec<_>>(),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
let dirty = if dirty { " (dirty)" } else { "" };
|
||||||
|
ui.label(format!("Scene: {scene_label}{dirty}"));
|
||||||
|
ui.label(format!("Status: {status}"));
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
"History: {}",
|
"History: {}",
|
||||||
world.resource::<EditorHistory>().status
|
world.resource::<EditorHistory>().status
|
||||||
@@ -58,6 +69,125 @@ pub fn diagnostics_ui(world: &mut World, ui: &mut egui::Ui) {
|
|||||||
let count = level_query.iter(world).count();
|
let count = level_query.iter(world).count();
|
||||||
ui.label(format!("Level objects: {count}"));
|
ui.label(format!("Level objects: {count}"));
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.strong("Project validation");
|
||||||
|
if ui.button("Validate Project").clicked() {
|
||||||
|
let root = world.resource::<ProjectWorkspace>().root.clone();
|
||||||
|
let report = scene::validate_project(std::path::Path::new(&root));
|
||||||
|
let summary = format!(
|
||||||
|
"Project validation: {} dependencies, {} findings, {} blocking errors",
|
||||||
|
report.dependencies.len(),
|
||||||
|
report.findings.len(),
|
||||||
|
report.blocking_error_count()
|
||||||
|
);
|
||||||
|
world.resource_mut::<SceneIo>().set_status(summary);
|
||||||
|
world.resource_mut::<DiagnosticsPanel>().project_validation = Some(report);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if let Some(report) = world
|
||||||
|
.resource::<DiagnosticsPanel>()
|
||||||
|
.project_validation
|
||||||
|
.as_ref()
|
||||||
|
.cloned()
|
||||||
|
{
|
||||||
|
let color = if report.is_release_ready() {
|
||||||
|
egui::Color32::from_rgb(125, 210, 145)
|
||||||
|
} else {
|
||||||
|
egui::Color32::from_rgb(255, 137, 129)
|
||||||
|
};
|
||||||
|
ui.colored_label(
|
||||||
|
color,
|
||||||
|
format!(
|
||||||
|
"{} dependencies, {} blocking errors",
|
||||||
|
report.dependencies.len(),
|
||||||
|
report.blocking_error_count()
|
||||||
|
),
|
||||||
|
);
|
||||||
|
for finding in report.findings.iter().take(12) {
|
||||||
|
let actor = finding
|
||||||
|
.owner_actor_id
|
||||||
|
.as_deref()
|
||||||
|
.map(|actor| format!(" / {actor}"))
|
||||||
|
.unwrap_or_default();
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
ui.monospace(format!("{}{}", finding.source_path, actor));
|
||||||
|
ui.label(&finding.message);
|
||||||
|
if let Some(actor_id) = finding.owner_actor_id.as_deref() {
|
||||||
|
if ui.small_button("Select").clicked() {
|
||||||
|
let mut query = world.query::<(Entity, &shared::ActorId)>();
|
||||||
|
if let Some(entity) = query
|
||||||
|
.iter(world)
|
||||||
|
.find_map(|(entity, id)| (id.0 == actor_id).then_some(entity))
|
||||||
|
{
|
||||||
|
world.resource_mut::<SelectedEntity>().0 = Some(entity);
|
||||||
|
world
|
||||||
|
.resource_mut::<UiState>()
|
||||||
|
.selected_entities
|
||||||
|
.select_replace(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if report.findings.len() > 12 {
|
||||||
|
ui.small(format!(
|
||||||
|
"{} additional findings",
|
||||||
|
report.findings.len() - 12
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.strong("Support bundle");
|
||||||
|
if ui.button("Export Diagnostic Bundle").clicked() {
|
||||||
|
let status = match export_diagnostic_bundle(world) {
|
||||||
|
Ok(path) => format!("Exported {}", path.display()),
|
||||||
|
Err(error) => format!("Export failed: {error}"),
|
||||||
|
};
|
||||||
|
world.resource_mut::<DiagnosticsPanel>().bundle_status = Some(status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
ui.small("Allowlisted metadata only; scene and asset contents, environment values, credentials, and modal state are excluded.");
|
||||||
|
if let Some(status) = world
|
||||||
|
.resource::<DiagnosticsPanel>()
|
||||||
|
.bundle_status
|
||||||
|
.as_deref()
|
||||||
|
{
|
||||||
|
ui.monospace(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
ui.separator();
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.strong("Scene I/O log");
|
||||||
|
if ui
|
||||||
|
.add_enabled(!scene_events.is_empty(), egui::Button::new("Clear"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
world.resource_mut::<SceneIo>().clear_events();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if scene_events.is_empty() {
|
||||||
|
ui.small("No scene I/O operations recorded this session.");
|
||||||
|
} else {
|
||||||
|
egui::ScrollArea::vertical()
|
||||||
|
.id_salt("scene_io_diagnostics_log")
|
||||||
|
.max_height(180.0)
|
||||||
|
.show(ui, |ui| {
|
||||||
|
for event in scene_events {
|
||||||
|
let color = match event.severity {
|
||||||
|
SceneIoEventSeverity::Info => ui.visuals().weak_text_color(),
|
||||||
|
SceneIoEventSeverity::Error => egui::Color32::from_rgb(244, 110, 105),
|
||||||
|
};
|
||||||
|
ui.horizontal_wrapped(|ui| {
|
||||||
|
ui.colored_label(color, format!("#{:02}", event.id));
|
||||||
|
ui.colored_label(color, event.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
ui.separator();
|
ui.separator();
|
||||||
ui.small("Native Bevy scenes are saved to assets/levels/*.scn.ron");
|
ui.small("Native Bevy scenes are saved to assets/levels/*.scn.ron");
|
||||||
ui.small("BRP is enabled on the editor for external tooling.");
|
ui.small("BRP is enabled on the editor for external tooling.");
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ impl PanelNodes {
|
|||||||
EditorTab::Viewport | EditorTab::GameView => self.main_view(),
|
EditorTab::Viewport | EditorTab::GameView => self.main_view(),
|
||||||
EditorTab::Hierarchy => self.hierarchy(),
|
EditorTab::Hierarchy => self.hierarchy(),
|
||||||
EditorTab::Inspector => self.inspector(),
|
EditorTab::Inspector => self.inspector(),
|
||||||
EditorTab::AssetBrowser | EditorTab::Toolbar => self.bottom(),
|
EditorTab::AssetBrowser | EditorTab::Build | EditorTab::Toolbar => self.bottom(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,18 +51,21 @@ impl PanelNodes {
|
|||||||
EditorTab::Viewport | EditorTab::GameView => nodes.main_view = path.node.0,
|
EditorTab::Viewport | EditorTab::GameView => nodes.main_view = path.node.0,
|
||||||
EditorTab::Hierarchy => nodes.hierarchy = path.node.0,
|
EditorTab::Hierarchy => nodes.hierarchy = path.node.0,
|
||||||
EditorTab::Inspector => nodes.inspector = path.node.0,
|
EditorTab::Inspector => nodes.inspector = path.node.0,
|
||||||
EditorTab::AssetBrowser | EditorTab::Toolbar => nodes.bottom = path.node.0,
|
EditorTab::AssetBrowser | EditorTab::Build | EditorTab::Toolbar => {
|
||||||
|
nodes.bottom = path.node.0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodes
|
nodes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const PANEL_TABS: [EditorTab; 4] = [
|
pub const PANEL_TABS: [EditorTab; 5] = [
|
||||||
EditorTab::Viewport,
|
EditorTab::Viewport,
|
||||||
EditorTab::Hierarchy,
|
EditorTab::Hierarchy,
|
||||||
EditorTab::Inspector,
|
EditorTab::Inspector,
|
||||||
EditorTab::AssetBrowser,
|
EditorTab::AssetBrowser,
|
||||||
|
EditorTab::Build,
|
||||||
];
|
];
|
||||||
|
|
||||||
pub fn tab_label(tab: &EditorTab) -> &'static str {
|
pub fn tab_label(tab: &EditorTab) -> &'static str {
|
||||||
@@ -71,6 +74,7 @@ pub fn tab_label(tab: &EditorTab) -> &'static str {
|
|||||||
EditorTab::Hierarchy => "Hierarchy",
|
EditorTab::Hierarchy => "Hierarchy",
|
||||||
EditorTab::Inspector => "Inspector",
|
EditorTab::Inspector => "Inspector",
|
||||||
EditorTab::AssetBrowser => "Asset Browser",
|
EditorTab::AssetBrowser => "Asset Browser",
|
||||||
|
EditorTab::Build => "Build",
|
||||||
EditorTab::Toolbar => "Toolbar (legacy)",
|
EditorTab::Toolbar => "Toolbar (legacy)",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use sim::Player;
|
|||||||
use crate::assets::{snapshot_for_asset, EditorAsset, EditorAssetKind};
|
use crate::assets::{snapshot_for_asset, EditorAsset, EditorAssetKind};
|
||||||
use crate::camera::EditorCamera;
|
use crate::camera::EditorCamera;
|
||||||
use crate::gizmos::{EditorGizmoMode, EditorGizmoSpace};
|
use crate::gizmos::{EditorGizmoMode, EditorGizmoSpace};
|
||||||
use crate::history::{set_material_with_history, spawn_with_history, EditorEntitySnapshot};
|
use crate::history::{set_material_group_with_history, spawn_with_history, EditorEntitySnapshot};
|
||||||
use crate::play::default_player_spawn;
|
use crate::play::default_player_spawn;
|
||||||
use crate::scene_io::SceneIo;
|
use crate::scene_io::SceneIo;
|
||||||
use crate::viewport::{recall_camera_bookmark, save_camera_bookmark, CameraBookmarks};
|
use crate::viewport::{recall_camera_bookmark, save_camera_bookmark, CameraBookmarks};
|
||||||
@@ -91,12 +91,16 @@ pub fn light_snapshot(name: &str, translation: Vec3) -> EditorEntitySnapshot {
|
|||||||
primitive: None,
|
primitive: None,
|
||||||
brush: None,
|
brush: None,
|
||||||
static_mesh_renderer: None,
|
static_mesh_renderer: None,
|
||||||
|
skinned_mesh_renderer: None,
|
||||||
material: None,
|
material: None,
|
||||||
material_override: None,
|
material_override: None,
|
||||||
rigid_body: None,
|
rigid_body: None,
|
||||||
collider: None,
|
collider: None,
|
||||||
physics: None,
|
physics: None,
|
||||||
light: Some(LightDesc::default()),
|
light: Some(LightDesc::default()),
|
||||||
|
animation_controller: None,
|
||||||
|
audio_source: None,
|
||||||
|
audio_listener: None,
|
||||||
player_spawn: false,
|
player_spawn: false,
|
||||||
model: None,
|
model: None,
|
||||||
prefab: None,
|
prefab: None,
|
||||||
@@ -106,8 +110,18 @@ pub fn light_snapshot(name: &str, translation: Vec3) -> EditorEntitySnapshot {
|
|||||||
post_process_volume: None,
|
post_process_volume: None,
|
||||||
team_spawn: None,
|
team_spawn: None,
|
||||||
objective: None,
|
objective: None,
|
||||||
|
|
||||||
|
navigation_bounds: None,
|
||||||
|
|
||||||
|
navigation_obstacle: None,
|
||||||
|
|
||||||
|
navigation_area: None,
|
||||||
|
|
||||||
|
navigation_link: None,
|
||||||
hierarchy_sibling_index: 0,
|
hierarchy_sibling_index: 0,
|
||||||
editor_visibility: shared::EditorVisibility::default(),
|
editor_visibility: shared::EditorVisibility::default(),
|
||||||
|
inspector_order: None,
|
||||||
|
component_states: None,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -139,12 +153,16 @@ pub fn ensure_player_spawn_for_edit(world: &mut World) -> Entity {
|
|||||||
primitive: None,
|
primitive: None,
|
||||||
brush: None,
|
brush: None,
|
||||||
static_mesh_renderer: None,
|
static_mesh_renderer: None,
|
||||||
|
skinned_mesh_renderer: None,
|
||||||
material: None,
|
material: None,
|
||||||
material_override: None,
|
material_override: None,
|
||||||
rigid_body: None,
|
rigid_body: None,
|
||||||
collider: None,
|
collider: None,
|
||||||
physics: None,
|
physics: None,
|
||||||
light: None,
|
light: None,
|
||||||
|
animation_controller: None,
|
||||||
|
audio_source: None,
|
||||||
|
audio_listener: None,
|
||||||
player_spawn: true,
|
player_spawn: true,
|
||||||
model: None,
|
model: None,
|
||||||
prefab: None,
|
prefab: None,
|
||||||
@@ -154,8 +172,18 @@ pub fn ensure_player_spawn_for_edit(world: &mut World) -> Entity {
|
|||||||
post_process_volume: None,
|
post_process_volume: None,
|
||||||
team_spawn: None,
|
team_spawn: None,
|
||||||
objective: None,
|
objective: None,
|
||||||
|
|
||||||
|
navigation_bounds: None,
|
||||||
|
|
||||||
|
navigation_obstacle: None,
|
||||||
|
|
||||||
|
navigation_area: None,
|
||||||
|
|
||||||
|
navigation_link: None,
|
||||||
hierarchy_sibling_index: 0,
|
hierarchy_sibling_index: 0,
|
||||||
editor_visibility: shared::EditorVisibility::default(),
|
editor_visibility: shared::EditorVisibility::default(),
|
||||||
|
inspector_order: None,
|
||||||
|
component_states: None,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -227,12 +255,16 @@ pub fn create_scene_sun_override_from_project_settings(world: &mut World) -> Ent
|
|||||||
primitive: None,
|
primitive: None,
|
||||||
brush: None,
|
brush: None,
|
||||||
static_mesh_renderer: None,
|
static_mesh_renderer: None,
|
||||||
|
skinned_mesh_renderer: None,
|
||||||
material: None,
|
material: None,
|
||||||
material_override: None,
|
material_override: None,
|
||||||
rigid_body: None,
|
rigid_body: None,
|
||||||
collider: None,
|
collider: None,
|
||||||
physics: None,
|
physics: None,
|
||||||
light: Some(light),
|
light: Some(light),
|
||||||
|
animation_controller: None,
|
||||||
|
audio_source: None,
|
||||||
|
audio_listener: None,
|
||||||
player_spawn: false,
|
player_spawn: false,
|
||||||
model: None,
|
model: None,
|
||||||
prefab: None,
|
prefab: None,
|
||||||
@@ -242,8 +274,18 @@ pub fn create_scene_sun_override_from_project_settings(world: &mut World) -> Ent
|
|||||||
post_process_volume: None,
|
post_process_volume: None,
|
||||||
team_spawn: None,
|
team_spawn: None,
|
||||||
objective: None,
|
objective: None,
|
||||||
|
|
||||||
|
navigation_bounds: None,
|
||||||
|
|
||||||
|
navigation_obstacle: None,
|
||||||
|
|
||||||
|
navigation_area: None,
|
||||||
|
|
||||||
|
navigation_link: None,
|
||||||
hierarchy_sibling_index: 0,
|
hierarchy_sibling_index: 0,
|
||||||
editor_visibility: shared::EditorVisibility::default(),
|
editor_visibility: shared::EditorVisibility::default(),
|
||||||
|
inspector_order: None,
|
||||||
|
component_states: None,
|
||||||
children: Vec::new(),
|
children: Vec::new(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -256,6 +298,7 @@ pub fn asset_label(asset: &EditorAsset) -> String {
|
|||||||
EditorAssetKind::Model => "Model",
|
EditorAssetKind::Model => "Model",
|
||||||
EditorAssetKind::Texture => "Texture",
|
EditorAssetKind::Texture => "Texture",
|
||||||
EditorAssetKind::Material => "Material",
|
EditorAssetKind::Material => "Material",
|
||||||
|
EditorAssetKind::AudioClip => "Audio Clip",
|
||||||
EditorAssetKind::Level => "Level",
|
EditorAssetKind::Level => "Level",
|
||||||
EditorAssetKind::Prefab => "Prefab",
|
EditorAssetKind::Prefab => "Prefab",
|
||||||
EditorAssetKind::PostProcessVolume => "Post Process Volume",
|
EditorAssetKind::PostProcessVolume => "Post Process Volume",
|
||||||
@@ -270,26 +313,32 @@ pub fn apply_texture_to_selection(
|
|||||||
world: &mut World,
|
world: &mut World,
|
||||||
asset: &EditorAsset,
|
asset: &EditorAsset,
|
||||||
selected: &SelectedEntities,
|
selected: &SelectedEntities,
|
||||||
) {
|
) -> Result<(), String> {
|
||||||
let Some(path) = asset.path.clone() else {
|
let path = asset
|
||||||
return;
|
.path
|
||||||
};
|
.clone()
|
||||||
for entity in selected_level_entities(world, selected) {
|
.ok_or_else(|| format!("Texture has no source path: {}", asset.label))?;
|
||||||
let mut material = world
|
let changes = selected_level_entities(world, selected)
|
||||||
.get::<MaterialDesc>(entity)
|
.into_iter()
|
||||||
.cloned()
|
.map(|entity| {
|
||||||
.unwrap_or_default();
|
let mut material = world
|
||||||
material.base_color_texture = Some(path.clone());
|
.get::<MaterialDesc>(entity)
|
||||||
set_material_with_history(world, entity, material);
|
.cloned()
|
||||||
}
|
.unwrap_or_default();
|
||||||
|
material.base_color_texture = Some(path.clone());
|
||||||
|
(entity, material)
|
||||||
|
})
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
set_material_group_with_history(world, changes);
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn apply_material_asset_to_selection(
|
pub fn apply_material_asset_to_selection(
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
asset: &EditorAsset,
|
asset: &EditorAsset,
|
||||||
selected: &SelectedEntities,
|
selected: &SelectedEntities,
|
||||||
) {
|
) -> Result<(), String> {
|
||||||
crate::assets::materials::apply_material_asset_to_selection(world, asset, selected);
|
crate::assets::materials::apply_material_asset_to_selection(world, asset, selected)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use bevy_egui::egui;
|
|||||||
use bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities;
|
use bevy_inspector_egui::bevy_inspector::hierarchy::SelectedEntities;
|
||||||
use egui::containers::scroll_area::ScrollSource;
|
use egui::containers::scroll_area::ScrollSource;
|
||||||
use egui_phosphor_icons::icons;
|
use egui_phosphor_icons::icons;
|
||||||
use shared::EditorVisibility;
|
use shared::{EditorVisibility, HydratedPrefabMember};
|
||||||
|
|
||||||
use crate::history::{
|
use crate::history::{
|
||||||
create_empty_child_with_history, delete_entities_with_history, duplicate_entities_with_history,
|
create_empty_child_with_history, delete_entities_with_history, duplicate_entities_with_history,
|
||||||
@@ -19,11 +19,17 @@ use crate::ui::helpers::{
|
|||||||
};
|
};
|
||||||
use crate::ui::hierarchy_ops::{
|
use crate::ui::hierarchy_ops::{
|
||||||
authored_children, editor_visibility, entity_hierarchy_path, entity_matches_filter,
|
authored_children, editor_visibility, entity_hierarchy_path, entity_matches_filter,
|
||||||
hierarchy_label_for_entity, is_entity_locked, level_object_roots, sort_siblings,
|
hierarchy_drop_violation, hierarchy_label_for_entity, is_ancestor, is_entity_locked,
|
||||||
would_create_cycle, HierarchyLabel,
|
level_object_roots, mutable_authored_children, sort_siblings, HierarchyDropViolation,
|
||||||
|
HierarchyLabel,
|
||||||
};
|
};
|
||||||
use crate::ui::hierarchy_state::{HierarchyPanelState, HierarchySort};
|
use crate::ui::hierarchy_state::{HierarchyPanelState, HierarchySort};
|
||||||
use crate::ui::theme::{panel_heading, TEXT, TEXT_DIM, TEXT_SELECTED};
|
use crate::ui::selection_ops::is_linked_read_only;
|
||||||
|
use crate::ui::theme::{
|
||||||
|
overlay_chip_frame, panel_heading, ACCENT, ERROR, PANEL_BG_DARK, SELECTION, SELECTION_BG_MUTED,
|
||||||
|
SELECTION_SECONDARY, TEXT, TEXT_DIM, TEXT_MUTED, TEXT_SELECTED,
|
||||||
|
};
|
||||||
|
use crate::ui::widgets::phosphor_icon;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct HierarchyDragPayload {
|
struct HierarchyDragPayload {
|
||||||
@@ -37,6 +43,12 @@ enum DropTarget {
|
|||||||
Before(Entity),
|
Before(Entity),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||||
|
enum DropBlock {
|
||||||
|
Hierarchy(HierarchyDropViolation),
|
||||||
|
LockedTarget(Entity),
|
||||||
|
}
|
||||||
|
|
||||||
pub fn hierarchy_panel_ui(
|
pub fn hierarchy_panel_ui(
|
||||||
world: &mut World,
|
world: &mut World,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
@@ -121,7 +133,7 @@ pub fn hierarchy_panel_ui(
|
|||||||
|
|
||||||
if ui.input(|input| input.key_pressed(egui::Key::F2)) {
|
if ui.input(|input| input.key_pressed(egui::Key::F2)) {
|
||||||
if let Some(entity) = selected_entities.as_slice().first().copied() {
|
if let Some(entity) = selected_entities.as_slice().first().copied() {
|
||||||
if is_level_object(world, entity) {
|
if is_level_object(world, entity) && !is_entity_locked(&locked, entity) {
|
||||||
*renaming_entity = Some(entity);
|
*renaming_entity = Some(entity);
|
||||||
*rename_buffer = entity_name(world, entity);
|
*rename_buffer = entity_name(world, entity);
|
||||||
}
|
}
|
||||||
@@ -130,12 +142,10 @@ pub fn hierarchy_panel_ui(
|
|||||||
|
|
||||||
let filter_lower = filter.trim().to_lowercase();
|
let filter_lower = filter.trim().to_lowercase();
|
||||||
let mut drop_target = None;
|
let mut drop_target = None;
|
||||||
let mut invalid_drop = false;
|
let mut drop_block = None;
|
||||||
|
|
||||||
let dragging = world
|
let active_drag = world.resource::<HierarchyPanelState>().active_drag.clone();
|
||||||
.resource::<HierarchyPanelState>()
|
let dragging = active_drag.is_some();
|
||||||
.active_drag
|
|
||||||
.is_some();
|
|
||||||
|
|
||||||
egui::ScrollArea::vertical()
|
egui::ScrollArea::vertical()
|
||||||
.id_salt("hierarchy_tree")
|
.id_salt("hierarchy_tree")
|
||||||
@@ -148,7 +158,7 @@ pub fn hierarchy_panel_ui(
|
|||||||
ui.spacing_mut().item_spacing.y = 2.0;
|
ui.spacing_mut().item_spacing.y = 2.0;
|
||||||
|
|
||||||
if dragging {
|
if dragging {
|
||||||
draw_root_drop_zone(ui, &mut drop_target);
|
draw_root_drop_zone(ui, active_drag.as_deref(), &mut drop_target);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut roots = level_object_roots(world);
|
let mut roots = level_object_roots(world);
|
||||||
@@ -171,12 +181,12 @@ pub fn hierarchy_panel_ui(
|
|||||||
&filter_lower,
|
&filter_lower,
|
||||||
sort_mode,
|
sort_mode,
|
||||||
show_generated,
|
show_generated,
|
||||||
dragging,
|
active_drag.as_deref(),
|
||||||
&expanded,
|
&expanded,
|
||||||
&locked,
|
&locked,
|
||||||
&prefs_paths,
|
&prefs_paths,
|
||||||
&mut drop_target,
|
&mut drop_target,
|
||||||
&mut invalid_drop,
|
&mut drop_block,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +202,8 @@ pub fn hierarchy_panel_ui(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
draw_hierarchy_drag_preview(world, ui, active_drag.as_deref(), drop_target, drop_block);
|
||||||
|
|
||||||
if ui.ctx().input(|input| input.pointer.any_released()) {
|
if ui.ctx().input(|input| input.pointer.any_released()) {
|
||||||
if let Some(target) = drop_target {
|
if let Some(target) = drop_target {
|
||||||
let drag_entities = world
|
let drag_entities = world
|
||||||
@@ -200,7 +212,7 @@ pub fn hierarchy_panel_ui(
|
|||||||
.take();
|
.take();
|
||||||
if let Some(entities) = drag_entities {
|
if let Some(entities) = drag_entities {
|
||||||
let payload = HierarchyDragPayload { entities };
|
let payload = HierarchyDragPayload { entities };
|
||||||
apply_drop(world, &payload, target, invalid_drop);
|
apply_drop(world, &payload, target, drop_block);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
world.resource_mut::<HierarchyPanelState>().active_drag = None;
|
world.resource_mut::<HierarchyPanelState>().active_drag = None;
|
||||||
@@ -220,14 +232,45 @@ fn sort_label(sort: HierarchySort) -> &'static str {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_root_drop_zone(ui: &mut egui::Ui, drop_target: &mut Option<DropTarget>) {
|
fn draw_root_drop_zone(
|
||||||
|
ui: &mut egui::Ui,
|
||||||
|
drag_entities: Option<&[Entity]>,
|
||||||
|
drop_target: &mut Option<DropTarget>,
|
||||||
|
) {
|
||||||
let (rect, response) =
|
let (rect, response) =
|
||||||
ui.allocate_exact_size(egui::vec2(ui.available_width(), 2.0), egui::Sense::hover());
|
ui.allocate_exact_size(egui::vec2(ui.available_width(), 27.0), egui::Sense::hover());
|
||||||
if let Some(hover) = response.dnd_hover_payload::<HierarchyDragPayload>() {
|
let hovered = drag_entities.is_some()
|
||||||
ui.painter()
|
&& (response.contains_pointer()
|
||||||
.rect_filled(rect, 1.0, egui::Color32::from_rgb(80, 120, 200));
|
|| response
|
||||||
|
.dnd_hover_payload::<HierarchyDragPayload>()
|
||||||
|
.is_some());
|
||||||
|
ui.painter().rect(
|
||||||
|
rect,
|
||||||
|
2.0,
|
||||||
|
if hovered {
|
||||||
|
SELECTION_BG_MUTED
|
||||||
|
} else {
|
||||||
|
PANEL_BG_DARK
|
||||||
|
},
|
||||||
|
egui::Stroke::new(1.0, if hovered { SELECTION } else { TEXT_MUTED }),
|
||||||
|
egui::StrokeKind::Inside,
|
||||||
|
);
|
||||||
|
ui.painter().text(
|
||||||
|
rect.left_center() + egui::vec2(9.0, 0.0),
|
||||||
|
egui::Align2::LEFT_CENTER,
|
||||||
|
icons::TREE_STRUCTURE.as_str(),
|
||||||
|
egui::FontId::new(13.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||||
|
if hovered { SELECTION } else { TEXT_DIM },
|
||||||
|
);
|
||||||
|
ui.painter().text(
|
||||||
|
rect.left_center() + egui::vec2(29.0, 0.0),
|
||||||
|
egui::Align2::LEFT_CENTER,
|
||||||
|
"SCENE ROOT",
|
||||||
|
egui::FontId::new(11.0, egui::FontFamily::Proportional),
|
||||||
|
if hovered { TEXT_SELECTED } else { TEXT_DIM },
|
||||||
|
);
|
||||||
|
if hovered {
|
||||||
*drop_target = Some(DropTarget::Root);
|
*drop_target = Some(DropTarget::Root);
|
||||||
let _ = hover;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -246,12 +289,12 @@ fn draw_authored_node(
|
|||||||
filter_lower: &str,
|
filter_lower: &str,
|
||||||
sort_mode: HierarchySort,
|
sort_mode: HierarchySort,
|
||||||
show_generated: bool,
|
show_generated: bool,
|
||||||
drag_active: bool,
|
drag_entities: Option<&[Entity]>,
|
||||||
expanded: &std::collections::HashSet<Entity>,
|
expanded: &std::collections::HashSet<Entity>,
|
||||||
locked: &std::collections::HashSet<Entity>,
|
locked: &std::collections::HashSet<Entity>,
|
||||||
prefs_paths: &[String],
|
prefs_paths: &[String],
|
||||||
drop_target: &mut Option<DropTarget>,
|
drop_target: &mut Option<DropTarget>,
|
||||||
invalid_drop: &mut bool,
|
drop_block: &mut Option<DropBlock>,
|
||||||
) {
|
) {
|
||||||
let path = entity_hierarchy_path(world, entity);
|
let path = entity_hierarchy_path(world, entity);
|
||||||
let mut is_expanded = expanded.contains(&entity) || prefs_paths.iter().any(|p| p == &path);
|
let mut is_expanded = expanded.contains(&entity) || prefs_paths.iter().any(|p| p == &path);
|
||||||
@@ -265,15 +308,18 @@ fn draw_authored_node(
|
|||||||
.any(|child| is_hierarchy_generated_child(world, child))
|
.any(|child| is_hierarchy_generated_child(world, child))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
draw_drop_before(
|
if sort_mode == HierarchySort::Manual {
|
||||||
world,
|
draw_drop_before(
|
||||||
ui,
|
world,
|
||||||
entity,
|
ui,
|
||||||
depth,
|
entity,
|
||||||
drag_active,
|
depth,
|
||||||
drop_target,
|
drag_entities,
|
||||||
invalid_drop,
|
locked,
|
||||||
);
|
drop_target,
|
||||||
|
drop_block,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(depth as f32 * 14.0);
|
ui.add_space(depth as f32 * 14.0);
|
||||||
@@ -318,21 +364,37 @@ fn draw_authored_node(
|
|||||||
ui.add_space(18.0);
|
ui.add_space(18.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let linked_read_only = is_linked_read_only(world, entity);
|
||||||
|
let is_locked = is_entity_locked(locked, entity);
|
||||||
let visible = editor_visibility(world, entity).visible;
|
let visible = editor_visibility(world, entity).visible;
|
||||||
let eye_icon = if visible {
|
let eye_icon = if visible {
|
||||||
icons::EYE.regular()
|
icons::EYE.regular()
|
||||||
} else {
|
} else {
|
||||||
icons::EYE_SLASH.regular()
|
icons::EYE_SLASH.regular()
|
||||||
};
|
};
|
||||||
if ui.small_button(eye_icon).clicked() {
|
let prefab_member = world.get::<HydratedPrefabMember>(entity).is_some();
|
||||||
set_editor_visibility_with_history(
|
if ui
|
||||||
world,
|
.add_enabled(
|
||||||
entity,
|
!is_locked && (!linked_read_only || prefab_member),
|
||||||
EditorVisibility { visible: !visible },
|
egui::Button::new(eye_icon),
|
||||||
);
|
)
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
|
if prefab_member {
|
||||||
|
crate::assets::prefab_overrides::set_prefab_component_override(
|
||||||
|
world,
|
||||||
|
entity,
|
||||||
|
EditorVisibility { visible: !visible },
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
set_editor_visibility_with_history(
|
||||||
|
world,
|
||||||
|
entity,
|
||||||
|
EditorVisibility { visible: !visible },
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let is_locked = is_entity_locked(locked, entity);
|
|
||||||
let lock_icon = if is_locked {
|
let lock_icon = if is_locked {
|
||||||
icons::LOCK.regular()
|
icons::LOCK.regular()
|
||||||
} else {
|
} else {
|
||||||
@@ -351,15 +413,33 @@ fn draw_authored_node(
|
|||||||
let response = ui.text_edit_singleline(rename_buffer);
|
let response = ui.text_edit_singleline(rename_buffer);
|
||||||
let commit =
|
let commit =
|
||||||
response.lost_focus() || ui.input(|input| input.key_pressed(egui::Key::Enter));
|
response.lost_focus() || ui.input(|input| input.key_pressed(egui::Key::Enter));
|
||||||
if commit {
|
if commit && !is_locked && !linked_read_only {
|
||||||
rename_entity_with_history(world, entity, rename_buffer.clone());
|
rename_entity_with_history(world, entity, rename_buffer.clone());
|
||||||
*renaming_entity = None;
|
*renaming_entity = None;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let selected = selected_entities.contains(entity);
|
let selected = selected_entities.contains(entity);
|
||||||
|
let primary = selected_entities.as_slice().first().copied() == Some(entity);
|
||||||
let label = hierarchy_label_for_entity(world, entity, HierarchyNodeKind::Authored);
|
let label = hierarchy_label_for_entity(world, entity, HierarchyNodeKind::Authored);
|
||||||
let color = if selected { TEXT_SELECTED } else { TEXT };
|
let color = if selected { TEXT_SELECTED } else { TEXT };
|
||||||
let response = ui.selectable_label(selected, hierarchy_label_text(label, color));
|
let response = ui.add_sized(
|
||||||
|
egui::vec2(ui.available_width().max(72.0), 24.0),
|
||||||
|
egui::Button::selectable(selected, hierarchy_label_text(label, color))
|
||||||
|
.sense(egui::Sense::click_and_drag()),
|
||||||
|
);
|
||||||
|
if selected {
|
||||||
|
ui.painter().line_segment(
|
||||||
|
[response.rect.left_top(), response.rect.left_bottom()],
|
||||||
|
egui::Stroke::new(
|
||||||
|
if primary { 3.0 } else { 2.0 },
|
||||||
|
if primary {
|
||||||
|
SELECTION
|
||||||
|
} else {
|
||||||
|
SELECTION_SECONDARY
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
if response.clicked() && !is_locked {
|
if response.clicked() && !is_locked {
|
||||||
let additive = ui.input(|input| {
|
let additive = ui.input(|input| {
|
||||||
input.modifiers.shift || input.modifiers.command || input.modifiers.ctrl
|
input.modifiers.shift || input.modifiers.command || input.modifiers.ctrl
|
||||||
@@ -371,38 +451,37 @@ fn draw_authored_node(
|
|||||||
}
|
}
|
||||||
world.resource_mut::<SelectedEntity>().0 = Some(entity);
|
world.resource_mut::<SelectedEntity>().0 = Some(entity);
|
||||||
}
|
}
|
||||||
if response.double_clicked() && is_level_object(world, entity) {
|
if response.double_clicked()
|
||||||
|
&& is_level_object(world, entity)
|
||||||
|
&& !is_locked
|
||||||
|
&& !linked_read_only
|
||||||
|
{
|
||||||
*renaming_entity = Some(entity);
|
*renaming_entity = Some(entity);
|
||||||
*rename_buffer = entity_name(world, entity);
|
*rename_buffer = entity_name(world, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if response.drag_started() {
|
if response.drag_started() && !is_locked && (!linked_read_only || prefab_member) {
|
||||||
let drag_entities: Vec<Entity> = if selected_entities.contains(entity) {
|
let candidates: Vec<Entity> = if selected_entities.contains(entity) {
|
||||||
selected_entities
|
selected_entities.iter().collect()
|
||||||
.iter()
|
|
||||||
.filter(|e| is_level_object(world, *e))
|
|
||||||
.collect()
|
|
||||||
} else {
|
} else {
|
||||||
vec![entity]
|
vec![entity]
|
||||||
};
|
};
|
||||||
|
let drag_entities = draggable_selection(world, &candidates, locked);
|
||||||
response.dnd_set_drag_payload(HierarchyDragPayload {
|
response.dnd_set_drag_payload(HierarchyDragPayload {
|
||||||
entities: drag_entities.clone(),
|
entities: drag_entities.clone(),
|
||||||
});
|
});
|
||||||
world.resource_mut::<HierarchyPanelState>().active_drag = Some(drag_entities);
|
world.resource_mut::<HierarchyPanelState>().active_drag = Some(drag_entities);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(hover) = response.dnd_hover_payload::<HierarchyDragPayload>() {
|
let hover_payload = response.dnd_hover_payload::<HierarchyDragPayload>();
|
||||||
let invalid = would_create_cycle(world, &hover.entities, Some(entity));
|
let hovered_entities = hover_payload
|
||||||
*invalid_drop = invalid;
|
.as_deref()
|
||||||
|
.map(|payload| payload.entities.as_slice())
|
||||||
|
.or_else(|| drag_entities.filter(|_| response.contains_pointer()));
|
||||||
|
if let Some(entities) = hovered_entities {
|
||||||
|
*drop_block = drop_block_for_target(world, locked, entities, Some(entity), entity);
|
||||||
*drop_target = Some(DropTarget::On(entity));
|
*drop_target = Some(DropTarget::On(entity));
|
||||||
if invalid {
|
draw_attach_target_feedback(ui, response.rect, drop_block.is_some());
|
||||||
ui.painter().rect_stroke(
|
|
||||||
response.rect,
|
|
||||||
2.0,
|
|
||||||
egui::Stroke::new(2.0, egui::Color32::RED),
|
|
||||||
egui::StrokeKind::Outside,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
response.context_menu(|ui| {
|
response.context_menu(|ui| {
|
||||||
@@ -413,6 +492,7 @@ fn draw_authored_node(
|
|||||||
selected_entities,
|
selected_entities,
|
||||||
renaming_entity,
|
renaming_entity,
|
||||||
rename_buffer,
|
rename_buffer,
|
||||||
|
locked,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -437,12 +517,12 @@ fn draw_authored_node(
|
|||||||
filter_lower,
|
filter_lower,
|
||||||
sort_mode,
|
sort_mode,
|
||||||
show_generated,
|
show_generated,
|
||||||
drag_active,
|
drag_entities,
|
||||||
expanded,
|
expanded,
|
||||||
locked,
|
locked,
|
||||||
prefs_paths,
|
prefs_paths,
|
||||||
drop_target,
|
drop_target,
|
||||||
invalid_drop,
|
drop_block,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -458,43 +538,94 @@ fn draw_authored_node(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(
|
||||||
|
clippy::too_many_arguments,
|
||||||
|
reason = "immediate-mode drop feedback threads the current drag, lock, and target state"
|
||||||
|
)]
|
||||||
fn draw_drop_before(
|
fn draw_drop_before(
|
||||||
world: &World,
|
world: &World,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
depth: usize,
|
depth: usize,
|
||||||
drag_active: bool,
|
drag_entities: Option<&[Entity]>,
|
||||||
|
locked: &std::collections::HashSet<Entity>,
|
||||||
drop_target: &mut Option<DropTarget>,
|
drop_target: &mut Option<DropTarget>,
|
||||||
invalid_drop: &mut bool,
|
drop_block: &mut Option<DropBlock>,
|
||||||
) {
|
) {
|
||||||
if !drag_active {
|
let Some(drag_entities) = drag_entities else {
|
||||||
return;
|
return;
|
||||||
}
|
};
|
||||||
|
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.add_space(depth as f32 * 14.0 + 18.0);
|
ui.add_space(depth as f32 * 14.0 + 18.0);
|
||||||
let (rect, response) =
|
let (rect, response) =
|
||||||
ui.allocate_exact_size(egui::vec2(ui.available_width(), 2.0), egui::Sense::hover());
|
ui.allocate_exact_size(egui::vec2(ui.available_width(), 7.0), egui::Sense::hover());
|
||||||
if let Some(hover) = response.dnd_hover_payload::<HierarchyDragPayload>() {
|
let hovered = response.contains_pointer()
|
||||||
*invalid_drop = would_create_cycle(
|
|| response
|
||||||
world,
|
.dnd_hover_payload::<HierarchyDragPayload>()
|
||||||
&hover.entities,
|
.is_some();
|
||||||
world
|
if hovered {
|
||||||
.get::<ChildOf>(entity)
|
let parent = world
|
||||||
.map(|child_of| child_of.parent()),
|
.get::<ChildOf>(entity)
|
||||||
);
|
.map(|child_of| child_of.parent());
|
||||||
*drop_target = Some(DropTarget::Before(entity));
|
*drop_block = if world.get::<HydratedPrefabMember>(entity).is_some()
|
||||||
let color = if *invalid_drop {
|
|| drag_entities
|
||||||
egui::Color32::RED
|
.iter()
|
||||||
|
.any(|dragged| world.get::<HydratedPrefabMember>(*dragged).is_some())
|
||||||
|
{
|
||||||
|
let root =
|
||||||
|
crate::assets::prefab_overrides::prefab_member_override_target(world, entity)
|
||||||
|
.map(|(root, _)| root)
|
||||||
|
.unwrap_or(entity);
|
||||||
|
Some(DropBlock::Hierarchy(
|
||||||
|
HierarchyDropViolation::PrefabBoundary { root },
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
egui::Color32::from_rgb(80, 120, 200)
|
drop_block_for_target(world, locked, drag_entities, parent, entity)
|
||||||
};
|
};
|
||||||
ui.painter().rect_filled(rect, 1.0, color);
|
*drop_target = Some(DropTarget::Before(entity));
|
||||||
let _ = hover;
|
let color = if drop_block.is_some() {
|
||||||
|
ERROR
|
||||||
|
} else {
|
||||||
|
SELECTION
|
||||||
|
};
|
||||||
|
ui.painter().line_segment(
|
||||||
|
[rect.left_center(), rect.right_center()],
|
||||||
|
egui::Stroke::new(2.0, color),
|
||||||
|
);
|
||||||
|
ui.painter().circle_filled(rect.left_center(), 3.5, color);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn draw_attach_target_feedback(ui: &egui::Ui, rect: egui::Rect, invalid: bool) {
|
||||||
|
let color = if invalid { ERROR } else { ACCENT };
|
||||||
|
ui.painter().rect_filled(
|
||||||
|
rect,
|
||||||
|
2.0,
|
||||||
|
if invalid {
|
||||||
|
egui::Color32::from_rgba_premultiplied(105, 25, 29, 68)
|
||||||
|
} else {
|
||||||
|
egui::Color32::from_rgba_premultiplied(92, 66, 18, 62)
|
||||||
|
},
|
||||||
|
);
|
||||||
|
ui.painter().rect_stroke(
|
||||||
|
rect,
|
||||||
|
2.0,
|
||||||
|
egui::Stroke::new(2.0, color),
|
||||||
|
egui::StrokeKind::Inside,
|
||||||
|
);
|
||||||
|
if rect.width() > 150.0 {
|
||||||
|
ui.painter().text(
|
||||||
|
rect.right_center() - egui::vec2(7.0, 0.0),
|
||||||
|
egui::Align2::RIGHT_CENTER,
|
||||||
|
if invalid { "BLOCKED" } else { "ATTACH" },
|
||||||
|
egui::FontId::new(9.0, egui::FontFamily::Proportional),
|
||||||
|
color,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_generated_node(
|
fn draw_generated_node(
|
||||||
world: &World,
|
world: &World,
|
||||||
ui: &mut egui::Ui,
|
ui: &mut egui::Ui,
|
||||||
@@ -558,8 +689,22 @@ fn draw_runtime_node(
|
|||||||
ui.add_space(18.0);
|
ui.add_space(18.0);
|
||||||
let label = hierarchy_label_for_entity(world, entity, HierarchyNodeKind::Runtime);
|
let label = hierarchy_label_for_entity(world, entity, HierarchyNodeKind::Runtime);
|
||||||
let selected = selected_entities.contains(entity);
|
let selected = selected_entities.contains(entity);
|
||||||
|
let primary = selected_entities.as_slice().first().copied() == Some(entity);
|
||||||
let color = if selected { TEXT_SELECTED } else { TEXT_DIM };
|
let color = if selected { TEXT_SELECTED } else { TEXT_DIM };
|
||||||
let response = ui.selectable_label(selected, hierarchy_label_text(label, color));
|
let response = ui.selectable_label(selected, hierarchy_label_text(label, color));
|
||||||
|
if selected {
|
||||||
|
ui.painter().line_segment(
|
||||||
|
[response.rect.left_top(), response.rect.left_bottom()],
|
||||||
|
egui::Stroke::new(
|
||||||
|
if primary { 3.0 } else { 2.0 },
|
||||||
|
if primary {
|
||||||
|
SELECTION
|
||||||
|
} else {
|
||||||
|
SELECTION_SECONDARY
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
if response.clicked() {
|
if response.clicked() {
|
||||||
selected_entities.select_replace(entity);
|
selected_entities.select_replace(entity);
|
||||||
}
|
}
|
||||||
@@ -609,23 +754,62 @@ fn authored_context_menu(
|
|||||||
selected_entities: &mut SelectedEntities,
|
selected_entities: &mut SelectedEntities,
|
||||||
renaming_entity: &mut Option<Entity>,
|
renaming_entity: &mut Option<Entity>,
|
||||||
rename_buffer: &mut String,
|
rename_buffer: &mut String,
|
||||||
|
locked: &std::collections::HashSet<Entity>,
|
||||||
) {
|
) {
|
||||||
if ui.button("Rename").clicked() {
|
let entity_locked = is_entity_locked(locked, entity);
|
||||||
|
let linked_read_only = is_linked_read_only(world, entity);
|
||||||
|
let prefab_member = world.get::<HydratedPrefabMember>(entity).is_some();
|
||||||
|
let entity_mutable = !entity_locked && !linked_read_only;
|
||||||
|
let selection_mutable = selected_entities.iter().all(|selected| {
|
||||||
|
!is_entity_locked(locked, selected) && !is_linked_read_only(world, selected)
|
||||||
|
});
|
||||||
|
if entity_locked {
|
||||||
|
ui.small(egui::RichText::new("Actor locked").color(TEXT_DIM));
|
||||||
|
ui.separator();
|
||||||
|
} else if linked_read_only {
|
||||||
|
ui.small(egui::RichText::new("Linked source member").color(TEXT_DIM));
|
||||||
|
ui.separator();
|
||||||
|
}
|
||||||
|
if ui
|
||||||
|
.add_enabled(entity_mutable, egui::Button::new("Rename"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
*renaming_entity = Some(entity);
|
*renaming_entity = Some(entity);
|
||||||
*rename_buffer = entity_name(world, entity);
|
*rename_buffer = entity_name(world, entity);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
if ui.button("Duplicate").clicked() {
|
if ui
|
||||||
|
.add_enabled(entity_mutable, egui::Button::new("Duplicate"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
duplicate_entities_with_history(world, &[entity]);
|
duplicate_entities_with_history(world, &[entity]);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
if ui.button("Delete").clicked() {
|
if ui
|
||||||
|
.add_enabled(entity_mutable, egui::Button::new("Delete"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
delete_entities_with_history(world, &[entity]);
|
delete_entities_with_history(world, &[entity]);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
|
if prefab_member && !entity_locked {
|
||||||
|
if ui.button("Remove from prefab instance").clicked() {
|
||||||
|
crate::assets::prefab_overrides::remove_prefab_source_child(world, entity);
|
||||||
|
selected_entities.remove(entity);
|
||||||
|
ui.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ui.button("Unparent override").clicked() {
|
||||||
|
crate::assets::prefab_overrides::reparent_prefab_source_child(world, entity, None);
|
||||||
|
ui.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
if selected_entities.len() >= 2
|
if selected_entities.len() >= 2
|
||||||
&& selected_entities.contains(entity)
|
&& selected_entities.contains(entity)
|
||||||
&& ui.button("Group").clicked()
|
&& ui
|
||||||
|
.add_enabled(selection_mutable, egui::Button::new("Group"))
|
||||||
|
.clicked()
|
||||||
{
|
{
|
||||||
let entities: Vec<Entity> = selected_entities
|
let entities: Vec<Entity> = selected_entities
|
||||||
.iter()
|
.iter()
|
||||||
@@ -634,11 +818,17 @@ fn authored_context_menu(
|
|||||||
group_selection_with_history(world, &entities);
|
group_selection_with_history(world, &entities);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
if ui.button("Unparent").clicked() {
|
if ui
|
||||||
|
.add_enabled(entity_mutable, egui::Button::new("Unparent"))
|
||||||
|
.clicked()
|
||||||
|
{
|
||||||
reparent_with_history(world, entity, None);
|
reparent_with_history(world, entity, None);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
if ui.button("Create child Empty").clicked() {
|
let create_child = ui
|
||||||
|
.add_enabled(entity_mutable, egui::Button::new("Create child Empty"))
|
||||||
|
.on_disabled_hover_text("Locked and generated source actors cannot be modified");
|
||||||
|
if create_child.clicked() {
|
||||||
create_empty_child_with_history(world, entity);
|
create_empty_child_with_history(world, entity);
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
@@ -650,8 +840,167 @@ fn authored_context_menu(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn apply_drop(world: &mut World, drag: &HierarchyDragPayload, target: DropTarget, invalid: bool) {
|
fn top_level_drag_entities(world: &World, candidates: &[Entity]) -> Vec<Entity> {
|
||||||
if invalid || drag.entities.is_empty() {
|
candidates
|
||||||
|
.iter()
|
||||||
|
.copied()
|
||||||
|
.filter(|entity| {
|
||||||
|
!candidates
|
||||||
|
.iter()
|
||||||
|
.copied()
|
||||||
|
.any(|other| other != *entity && is_ancestor(world, other, *entity))
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draggable_selection(
|
||||||
|
world: &World,
|
||||||
|
candidates: &[Entity],
|
||||||
|
locked: &std::collections::HashSet<Entity>,
|
||||||
|
) -> Vec<Entity> {
|
||||||
|
let editable: Vec<_> = candidates
|
||||||
|
.iter()
|
||||||
|
.copied()
|
||||||
|
.filter(|entity| {
|
||||||
|
is_level_object(world, *entity)
|
||||||
|
&& !is_entity_locked(locked, *entity)
|
||||||
|
&& (!is_linked_read_only(world, *entity)
|
||||||
|
|| world.get::<HydratedPrefabMember>(*entity).is_some())
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
top_level_drag_entities(world, &editable)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_hierarchy_drag_preview(
|
||||||
|
world: &World,
|
||||||
|
ui: &egui::Ui,
|
||||||
|
drag_entities: Option<&[Entity]>,
|
||||||
|
target: Option<DropTarget>,
|
||||||
|
block: Option<DropBlock>,
|
||||||
|
) {
|
||||||
|
let Some(entities) = drag_entities.filter(|entities| !entities.is_empty()) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let Some(pointer) = ui.input(|input| input.pointer.hover_pos()) else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
let title = if entities.len() == 1 {
|
||||||
|
entity_name(world, entities[0])
|
||||||
|
} else {
|
||||||
|
format!("{} ACTORS", entities.len())
|
||||||
|
};
|
||||||
|
let action = if let Some(block) = block {
|
||||||
|
match block {
|
||||||
|
DropBlock::Hierarchy(HierarchyDropViolation::Cycle) => "Cannot attach: hierarchy cycle",
|
||||||
|
DropBlock::Hierarchy(HierarchyDropViolation::PrefabBoundary { .. }) => {
|
||||||
|
"Cannot attach: prefab contents are read-only"
|
||||||
|
}
|
||||||
|
DropBlock::LockedTarget(_) => "Cannot attach: target is locked",
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match target {
|
||||||
|
Some(DropTarget::Root) => "Move to scene root",
|
||||||
|
Some(DropTarget::On(parent)) => {
|
||||||
|
return draw_hierarchy_drag_preview_card(
|
||||||
|
ui,
|
||||||
|
pointer,
|
||||||
|
&title,
|
||||||
|
&format!("Attach to {}", entity_name(world, parent)),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
Some(DropTarget::Before(sibling)) => {
|
||||||
|
return draw_hierarchy_drag_preview_card(
|
||||||
|
ui,
|
||||||
|
pointer,
|
||||||
|
&title,
|
||||||
|
&format!("Insert before {}", entity_name(world, sibling)),
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
None => "Drop on an actor to attach",
|
||||||
|
}
|
||||||
|
};
|
||||||
|
draw_hierarchy_drag_preview_card(ui, pointer, &title, action, block.is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn draw_hierarchy_drag_preview_card(
|
||||||
|
ui: &egui::Ui,
|
||||||
|
pointer: egui::Pos2,
|
||||||
|
title: &str,
|
||||||
|
action: &str,
|
||||||
|
invalid: bool,
|
||||||
|
) {
|
||||||
|
let content = ui.ctx().content_rect();
|
||||||
|
let pos = egui::pos2(
|
||||||
|
(pointer.x + 18.0).min(content.right() - 248.0),
|
||||||
|
(pointer.y + 18.0).min(content.bottom() - 58.0),
|
||||||
|
);
|
||||||
|
egui::Area::new(egui::Id::new("hierarchy_drag_preview"))
|
||||||
|
.fixed_pos(pos)
|
||||||
|
.default_size(egui::vec2(236.0, 56.0))
|
||||||
|
.order(egui::Order::Tooltip)
|
||||||
|
.interactable(false)
|
||||||
|
.show(ui.ctx(), |ui| {
|
||||||
|
ui.set_min_size(egui::vec2(236.0, 56.0));
|
||||||
|
ui.set_max_size(egui::vec2(236.0, 56.0));
|
||||||
|
overlay_chip_frame().show(ui, |ui| {
|
||||||
|
ui.set_width(218.0);
|
||||||
|
ui.horizontal(|ui| {
|
||||||
|
ui.label(
|
||||||
|
phosphor_icon(icons::TREE_STRUCTURE, 18.0).color(if invalid {
|
||||||
|
ERROR
|
||||||
|
} else {
|
||||||
|
ACCENT
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
ui.vertical(|ui| {
|
||||||
|
ui.spacing_mut().item_spacing.y = 1.0;
|
||||||
|
ui.label(egui::RichText::new(title).strong().color(TEXT_SELECTED));
|
||||||
|
ui.label(egui::RichText::new(action).size(11.0).color(if invalid {
|
||||||
|
ERROR
|
||||||
|
} else {
|
||||||
|
TEXT_DIM
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn apply_drop(
|
||||||
|
world: &mut World,
|
||||||
|
drag: &HierarchyDragPayload,
|
||||||
|
target: DropTarget,
|
||||||
|
block: Option<DropBlock>,
|
||||||
|
) {
|
||||||
|
if block.is_some() || drag.entities.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let prefab_members = drag
|
||||||
|
.entities
|
||||||
|
.iter()
|
||||||
|
.all(|entity| world.get::<HydratedPrefabMember>(*entity).is_some());
|
||||||
|
if prefab_members {
|
||||||
|
match target {
|
||||||
|
DropTarget::Root => {
|
||||||
|
crate::assets::prefab_overrides::reparent_prefab_source_children(
|
||||||
|
world,
|
||||||
|
&drag.entities,
|
||||||
|
None,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
DropTarget::On(parent) => {
|
||||||
|
crate::assets::prefab_overrides::reparent_prefab_source_children(
|
||||||
|
world,
|
||||||
|
&drag.entities,
|
||||||
|
Some(parent),
|
||||||
|
);
|
||||||
|
expand_parent_after_drop(world, parent);
|
||||||
|
}
|
||||||
|
DropTarget::Before(_) => {}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
match target {
|
match target {
|
||||||
@@ -660,14 +1009,18 @@ fn apply_drop(world: &mut World, drag: &HierarchyDragPayload, target: DropTarget
|
|||||||
}
|
}
|
||||||
DropTarget::On(parent) => {
|
DropTarget::On(parent) => {
|
||||||
reorder_siblings_with_history(world, &drag.entities, Some(parent), i32::MAX);
|
reorder_siblings_with_history(world, &drag.entities, Some(parent), i32::MAX);
|
||||||
|
expand_parent_after_drop(world, parent);
|
||||||
}
|
}
|
||||||
DropTarget::Before(before) => {
|
DropTarget::Before(before) => {
|
||||||
let parent = world
|
let parent = world
|
||||||
.get::<ChildOf>(before)
|
.get::<ChildOf>(before)
|
||||||
.map(|child_of| child_of.parent());
|
.map(|child_of| child_of.parent());
|
||||||
let siblings = match parent {
|
let siblings = match parent {
|
||||||
Some(parent) => authored_children(world, parent),
|
Some(parent) => mutable_authored_children(world, parent),
|
||||||
None => level_object_roots(world),
|
None => level_object_roots(world)
|
||||||
|
.into_iter()
|
||||||
|
.filter(|entity| !is_linked_read_only(world, *entity))
|
||||||
|
.collect(),
|
||||||
};
|
};
|
||||||
let insert_index = siblings
|
let insert_index = siblings
|
||||||
.iter()
|
.iter()
|
||||||
@@ -678,6 +1031,53 @@ fn apply_drop(world: &mut World, drag: &HierarchyDragPayload, target: DropTarget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn drop_block_for_target(
|
||||||
|
world: &World,
|
||||||
|
locked: &std::collections::HashSet<Entity>,
|
||||||
|
drag_entities: &[Entity],
|
||||||
|
new_parent: Option<Entity>,
|
||||||
|
target: Entity,
|
||||||
|
) -> Option<DropBlock> {
|
||||||
|
if is_entity_locked(locked, target)
|
||||||
|
|| new_parent.is_some_and(|parent| is_entity_locked(locked, parent))
|
||||||
|
{
|
||||||
|
return Some(DropBlock::LockedTarget(target));
|
||||||
|
}
|
||||||
|
if is_linked_read_only(world, target) {
|
||||||
|
if world.get::<HydratedPrefabMember>(target).is_some()
|
||||||
|
&& hierarchy_drop_violation(world, drag_entities, new_parent).is_none()
|
||||||
|
{
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
let root = crate::assets::prefab_overrides::prefab_member_override_target(world, target)
|
||||||
|
.map(|(root, _)| root)
|
||||||
|
.unwrap_or(target);
|
||||||
|
return Some(DropBlock::Hierarchy(
|
||||||
|
HierarchyDropViolation::PrefabBoundary { root },
|
||||||
|
));
|
||||||
|
}
|
||||||
|
hierarchy_drop_violation(world, drag_entities, new_parent).map(DropBlock::Hierarchy)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn expand_parent_after_drop(world: &mut World, parent: Entity) {
|
||||||
|
let path = entity_hierarchy_path(world, parent);
|
||||||
|
{
|
||||||
|
let mut state = world.resource_mut::<HierarchyPanelState>();
|
||||||
|
if state.expanded.insert(parent) {
|
||||||
|
state.mark_dirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut prefs = world.resource_mut::<UserPreferences>();
|
||||||
|
if !prefs
|
||||||
|
.hierarchy_expanded_paths
|
||||||
|
.iter()
|
||||||
|
.any(|entry| entry == &path)
|
||||||
|
{
|
||||||
|
prefs.hierarchy_expanded_paths.push(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn subtree_matches_filter(
|
fn subtree_matches_filter(
|
||||||
world: &World,
|
world: &World,
|
||||||
entity: Entity,
|
entity: Entity,
|
||||||
@@ -744,3 +1144,76 @@ pub(crate) fn is_runtime_hierarchy_entity(world: &World, entity: Entity) -> bool
|
|||||||
|| entity_ref.contains::<ProjectSun>())
|
|| entity_ref.contains::<ProjectSun>())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use shared::LevelObject;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn drag_selection_keeps_only_top_level_actors() {
|
||||||
|
let mut world = World::new();
|
||||||
|
let parent = world.spawn(LevelObject).id();
|
||||||
|
let child = world.spawn((LevelObject, ChildOf(parent))).id();
|
||||||
|
let peer = world.spawn(LevelObject).id();
|
||||||
|
|
||||||
|
let normalized = top_level_drag_entities(&world, &[parent, child, peer]);
|
||||||
|
|
||||||
|
assert_eq!(normalized, vec![parent, peer]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn drag_selection_excludes_locked_actors_before_subtree_normalization() {
|
||||||
|
let mut world = World::new();
|
||||||
|
let parent = world.spawn(LevelObject).id();
|
||||||
|
let child = world.spawn((LevelObject, ChildOf(parent))).id();
|
||||||
|
let peer = world.spawn(LevelObject).id();
|
||||||
|
let locked = std::collections::HashSet::from([parent]);
|
||||||
|
|
||||||
|
let normalized = draggable_selection(&world, &[parent, child, peer], &locked);
|
||||||
|
|
||||||
|
assert_eq!(normalized, vec![child, peer]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn locked_drop_target_reports_specific_block() {
|
||||||
|
let mut world = World::new();
|
||||||
|
let actor = world.spawn(LevelObject).id();
|
||||||
|
let target = world.spawn(LevelObject).id();
|
||||||
|
let locked = std::collections::HashSet::from([target]);
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
drop_block_for_target(&world, &locked, &[actor], Some(target), target),
|
||||||
|
Some(DropBlock::LockedTarget(target))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn deep_filtered_tree_keeps_matching_descendant_discoverable() {
|
||||||
|
let mut world = World::new();
|
||||||
|
let root = world.spawn((LevelObject, Name::new("Root"))).id();
|
||||||
|
let mut parent = root;
|
||||||
|
for depth in 0..64 {
|
||||||
|
parent = world
|
||||||
|
.spawn((
|
||||||
|
LevelObject,
|
||||||
|
Name::new(if depth == 63 { "Needle" } else { "Branch" }),
|
||||||
|
ChildOf(parent),
|
||||||
|
))
|
||||||
|
.id();
|
||||||
|
}
|
||||||
|
|
||||||
|
assert!(subtree_matches_filter(
|
||||||
|
&world,
|
||||||
|
root,
|
||||||
|
"needle",
|
||||||
|
HierarchySort::Manual
|
||||||
|
));
|
||||||
|
assert!(!subtree_matches_filter(
|
||||||
|
&world,
|
||||||
|
root,
|
||||||
|
"missing",
|
||||||
|
HierarchySort::Manual
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
Loaded 100 of 279 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user