Build production-ready editor authoring workflows
CI / Format, lint, test, build (push) Waiting to run
CI / Format, lint, test, build (push) Waiting to run
This commit is contained in:
1 parent
cc1fa6ea3b
commit
0553a85220
163 files changed
+34547
-1565
No files matched your search
@@ -1,8 +1,10 @@
|
||||
//! Serializable project settings loaded from `assets/project.ron`.
|
||||
|
||||
mod audio;
|
||||
mod plugin;
|
||||
mod rendering;
|
||||
|
||||
pub use audio::*;
|
||||
pub use plugin::{
|
||||
save_project_settings, sync_sim_tuning, ProjectSettingsChanged, ProjectSettingsIo,
|
||||
ProjectSettingsPlugin, SimTuning,
|
||||
@@ -19,6 +21,15 @@ use serde::{Deserialize, Serialize};
|
||||
|
||||
pub const DEFAULT_PROJECT_PATH: &str = "assets/project.ron";
|
||||
pub const SETTINGS_VERSION: u32 = 1;
|
||||
pub const PROJECT_TEMPLATE_VERSION: u32 = 1;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize, Reflect, PartialEq, Eq)]
|
||||
#[reflect(Clone)]
|
||||
pub enum ProjectKind {
|
||||
#[default]
|
||||
Game,
|
||||
Sandbox,
|
||||
}
|
||||
|
||||
/// Marker for cameras that receive the shared project rendering stack.
|
||||
#[derive(Component, Debug, Clone, Copy, Default)]
|
||||
@@ -29,10 +40,20 @@ pub struct ProjectRenderCamera;
|
||||
#[reflect(Resource, Clone)]
|
||||
pub struct ProjectSettings {
|
||||
pub version: u32,
|
||||
#[serde(default)]
|
||||
pub project_id: String,
|
||||
pub name: String,
|
||||
#[serde(default)]
|
||||
pub project_kind: ProjectKind,
|
||||
#[serde(default = "default_project_template_version")]
|
||||
pub template_version: u32,
|
||||
#[serde(default)]
|
||||
pub capabilities: Vec<String>,
|
||||
pub default_level: String,
|
||||
pub asset_roots: Vec<String>,
|
||||
pub rendering: RenderingSettings,
|
||||
#[serde(default)]
|
||||
pub audio: AudioSettings,
|
||||
pub physics: PhysicsSettings,
|
||||
pub input: InputSettings,
|
||||
}
|
||||
@@ -41,21 +62,36 @@ impl Default for ProjectSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
version: SETTINGS_VERSION,
|
||||
project_id: "blacksite-default".into(),
|
||||
name: "Bevy FPS Foundation".into(),
|
||||
project_kind: ProjectKind::Game,
|
||||
template_version: PROJECT_TEMPLATE_VERSION,
|
||||
capabilities: vec![
|
||||
"editor".into(),
|
||||
"gameplay".into(),
|
||||
"rendering".into(),
|
||||
"audio".into(),
|
||||
],
|
||||
default_level: "assets/levels/editor_scene.scn.ron".into(),
|
||||
asset_roots: vec![
|
||||
"assets/models".into(),
|
||||
"assets/textures".into(),
|
||||
"assets/materials".into(),
|
||||
"assets/levels".into(),
|
||||
"assets/audio".into(),
|
||||
],
|
||||
rendering: RenderingSettings::default(),
|
||||
audio: AudioSettings::default(),
|
||||
physics: PhysicsSettings::default(),
|
||||
input: InputSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn default_project_template_version() -> u32 {
|
||||
PROJECT_TEMPLATE_VERSION
|
||||
}
|
||||
|
||||
/// Camera post-processing and world lighting defaults.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, Reflect)]
|
||||
#[reflect(Clone)]
|
||||
@@ -221,10 +257,68 @@ mod tests {
|
||||
let text = save_project_settings_to_string(&settings).expect("serialize");
|
||||
let parsed: ProjectSettings = ron::from_str(&text).expect("deserialize");
|
||||
assert_eq!(parsed.name, settings.name);
|
||||
assert_eq!(parsed.project_id, settings.project_id);
|
||||
assert_eq!(parsed.project_kind, settings.project_kind);
|
||||
assert_eq!(parsed.template_version, settings.template_version);
|
||||
assert_eq!(parsed.capabilities, settings.capabilities);
|
||||
assert_eq!(parsed.audio, settings.audio);
|
||||
assert_eq!(parsed.physics.walk_speed, settings.physics.walk_speed);
|
||||
assert_eq!(parsed.rendering.gi_mode, settings.rendering.gi_mode);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn legacy_manifest_defaults_project_identity_fields() {
|
||||
let legacy = r#"(
|
||||
version: 1,
|
||||
name: "Legacy",
|
||||
default_level: "assets/levels/main.scn.ron",
|
||||
asset_roots: [],
|
||||
rendering: (
|
||||
gi_mode: Auto, hdr: true, exposure_mode: Manual, exposure_ev100: 13.0,
|
||||
auto_exposure_speed_brighten: 3.0, auto_exposure_speed_darken: 1.0,
|
||||
tonemapping_aces: true, bloom: true, taa: true, ssao: true,
|
||||
atmosphere: true, fog_color: (0.0, 0.0, 0.0), fog_density: 0.0,
|
||||
ambient_color: (0.0, 0.0, 0.0), ambient_brightness: 0.0,
|
||||
sun_illuminance: 100000.0, shadow_cascades: 4,
|
||||
shadow_first_cascade: 6.0, shadow_max_distance: 220.0,
|
||||
),
|
||||
physics: (
|
||||
player_radius: 0.4, player_length: 1.0, eye_offset_stand: 0.6,
|
||||
eye_offset_crouch: 0.1, gravity: 22.0, walk_speed: 6.0,
|
||||
run_speed: 9.5, crouch_speed: 3.0, jump_speed: 7.5,
|
||||
ground_accel: 70.0, air_accel: 16.0, ground_check_dist: 0.2,
|
||||
skin: 0.02, max_slide_iter: 4, ground_normal_y: 0.5,
|
||||
coyote_time: 0.12, jump_buffer: 0.12,
|
||||
),
|
||||
input: (
|
||||
yaw_sensitivity: 0.003, pitch_sensitivity: 0.0022,
|
||||
editor_fly_speed: 14.0, editor_look_sensitivity: 0.003,
|
||||
editor_pan_speed: 0.015,
|
||||
),
|
||||
)"#;
|
||||
|
||||
let parsed: ProjectSettings = ron::from_str(legacy).unwrap();
|
||||
|
||||
assert!(parsed.project_id.is_empty());
|
||||
assert_eq!(parsed.project_kind, ProjectKind::Game);
|
||||
assert_eq!(parsed.template_version, PROJECT_TEMPLATE_VERSION);
|
||||
assert!(parsed.capabilities.is_empty());
|
||||
assert_eq!(parsed.audio, AudioSettings::default());
|
||||
assert!(parsed.audio.validate().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn project_defaults_include_audio_capability_and_asset_root() {
|
||||
let settings = ProjectSettings::default();
|
||||
|
||||
assert!(settings.capabilities.iter().any(|item| item == "audio"));
|
||||
assert!(settings
|
||||
.asset_roots
|
||||
.iter()
|
||||
.any(|item| item == "assets/audio"));
|
||||
assert!(settings.audio.validate().is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn gi_mode_defaults_auto() {
|
||||
assert_eq!(RenderingSettings::default().gi_mode, GiMode::Auto);
|
||||
|
||||
Reference in new issue
Block a user