parent
4447ff2aa6
commit
b315e589e6
File diff suppressed because it is too large
Load Diff
25
Cargo.toml
25
Cargo.toml
|
@ -4,6 +4,25 @@ version = "0.1.0"
|
|||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
bevy = "0.7.0"
|
||||
bevy_mod_raycast = "0.5.0"
|
||||
bevy_prototype_debug_lines = { version = "0.7", features = ["3d"] }
|
||||
bevy = "0.8.0"
|
||||
bevy_mod_raycast = "0.6.0"
|
||||
|
||||
# Enable a small amount of optimization in debug mode
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
||||
# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
|
||||
[profile.dev.package."*"]
|
||||
opt-level = 3
|
||||
|
||||
[profile.wasm-release]
|
||||
inherits = "release"
|
||||
# Optimize with size in mind, also try "s", sometimes it is better.
|
||||
# This doesn't increase compilation times compared to -O3, great improvements
|
||||
opt-level = "z"
|
||||
# Do a second optimization pass removing duplicate or unused code from dependencies.
|
||||
# Slows compile times, marginal improvements
|
||||
lto = "fat"
|
||||
# When building crates, optimize larger chunks at a time
|
||||
# Slows compile times, marginal improvements
|
||||
codegen-units = 1
|
||||
|
|
|
@ -9,7 +9,7 @@ pub struct MyRaycastSet;
|
|||
pub struct Camera;
|
||||
pub fn spawn_camera(commands: &mut Commands) {
|
||||
commands
|
||||
.spawn_bundle(PerspectiveCameraBundle::default())
|
||||
.spawn_bundle(Camera3dBundle::default())
|
||||
.insert(Camera)
|
||||
.insert(RayCastSource::<MyRaycastSet>::new());
|
||||
}
|
||||
|
|
44
src/debug.rs
44
src/debug.rs
|
@ -1,9 +1,9 @@
|
|||
use std::f32::consts::TAU;
|
||||
// use std::f32::consts::TAU;
|
||||
|
||||
use bevy::{ecs::schedule::ShouldRun, prelude::*};
|
||||
use bevy_prototype_debug_lines::*;
|
||||
// use bevy_prototype_debug_lines::*;
|
||||
|
||||
use crate::illumination::Illumination;
|
||||
// use crate::illumination::Illumination;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Debug {
|
||||
|
@ -18,29 +18,29 @@ pub fn debug_run_criteria(debug: Res<Debug>) -> ShouldRun {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn debug_draw_illumination(
|
||||
query: Query<(&GlobalTransform, &Illumination)>,
|
||||
mut lines: ResMut<DebugLines>,
|
||||
) {
|
||||
for (trans, illumination) in query.iter() {
|
||||
draw_sphere(&mut lines, trans.translation, illumination.radius);
|
||||
}
|
||||
}
|
||||
// pub fn debug_draw_illumination(
|
||||
// query: Query<(&GlobalTransform, &Illumination)>,
|
||||
// mut lines: ResMut<DebugLines>,
|
||||
// ) {
|
||||
// for (trans, illumination) in query.iter() {
|
||||
// draw_sphere(&mut lines, trans.translation, illumination.radius);
|
||||
// }
|
||||
// }
|
||||
|
||||
fn draw_sphere(lines: &mut DebugLines, c: Vec3, r: f32) {
|
||||
const THICKNESS: f32 = 0.1;
|
||||
const MAX_LINES: usize = 10;
|
||||
// fn draw_sphere(lines: &mut DebugLines, c: Vec3, r: f32) {
|
||||
// const THICKNESS: f32 = 0.1;
|
||||
// const MAX_LINES: usize = 10;
|
||||
|
||||
for i in 0..MAX_LINES {
|
||||
let angle1 = (i as f32 / MAX_LINES as f32) * TAU;
|
||||
let angle2 = ((i + 1) as f32 / MAX_LINES as f32) * TAU;
|
||||
// for i in 0..MAX_LINES {
|
||||
// let angle1 = (i as f32 / MAX_LINES as f32) * TAU;
|
||||
// let angle2 = ((i + 1) as f32 / MAX_LINES as f32) * TAU;
|
||||
|
||||
let start = Vec3::new(r * f32::cos(angle1), 1.0, r * f32::sin(angle1)) + c;
|
||||
let end = Vec3::new(r * f32::cos(angle2), 1.0, r * f32::sin(angle2)) + c;
|
||||
// let start = Vec3::new(r * f32::cos(angle1), 1.0, r * f32::sin(angle1)) + c;
|
||||
// let end = Vec3::new(r * f32::cos(angle2), 1.0, r * f32::sin(angle2)) + c;
|
||||
|
||||
lines.line(start, end, THICKNESS);
|
||||
}
|
||||
}
|
||||
// lines.line(start, end, THICKNESS);
|
||||
// }
|
||||
// }
|
||||
|
||||
pub fn toggle_debug(mut debug: ResMut<Debug>, input: Res<Input<KeyCode>>) {
|
||||
if input.pressed(KeyCode::J) && input.pressed(KeyCode::K) && input.just_pressed(KeyCode::L) {
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
use bevy::{
|
||||
prelude::*,
|
||||
render::render_resource::{AddressMode, FilterMode},
|
||||
render::{
|
||||
render_resource::{AddressMode, FilterMode, SamplerDescriptor},
|
||||
texture::ImageSampler,
|
||||
},
|
||||
};
|
||||
|
||||
use crate::AppState;
|
||||
|
@ -23,10 +26,15 @@ pub fn loading(
|
|||
mut state: ResMut<State<AppState>>,
|
||||
) {
|
||||
if let Some(t) = textures.get_mut(&assets.floor) {
|
||||
t.sampler_descriptor.address_mode_u = AddressMode::MirrorRepeat;
|
||||
t.sampler_descriptor.address_mode_v = AddressMode::Repeat;
|
||||
t.sampler_descriptor.address_mode_w = AddressMode::Repeat;
|
||||
t.sampler_descriptor.mipmap_filter = FilterMode::Linear;
|
||||
let s = SamplerDescriptor {
|
||||
address_mode_u: AddressMode::MirrorRepeat,
|
||||
address_mode_v: AddressMode::Repeat,
|
||||
address_mode_w: AddressMode::Repeat,
|
||||
mipmap_filter: FilterMode::Linear,
|
||||
..default()
|
||||
};
|
||||
|
||||
t.sampler_descriptor = ImageSampler::Descriptor(s);
|
||||
|
||||
state.set(AppState::Game).unwrap();
|
||||
}
|
||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -1,6 +1,6 @@
|
|||
use bevy::{input::system::exit_on_esc_system, pbr::AmbientLight, prelude::*};
|
||||
use bevy::{pbr::AmbientLight, prelude::*, window::close_on_esc};
|
||||
use bevy_mod_raycast::{DefaultRaycastingPlugin, RayCastMesh, RaycastSystem};
|
||||
use bevy_prototype_debug_lines::*;
|
||||
// use bevy_prototype_debug_lines::*;
|
||||
|
||||
mod camera;
|
||||
mod columns;
|
||||
|
@ -28,7 +28,7 @@ fn main() {
|
|||
.insert_resource(Msaa { samples: 4 })
|
||||
.insert_resource(ClearColor(Color::rgb(0.0, 0.0, 0.0)))
|
||||
.add_plugins(DefaultPlugins)
|
||||
.add_plugin(DebugLinesPlugin::with_depth_test(true))
|
||||
// .add_plugin(DebugLinesPlugin::with_depth_test(true))
|
||||
.init_resource::<Debug>()
|
||||
.init_resource::<LightBallMaterials>()
|
||||
.init_resource::<PillarMaterials>()
|
||||
|
@ -52,7 +52,7 @@ fn main() {
|
|||
SystemSet::on_update(AppState::Game)
|
||||
.with_system(update_raw_mouse_coords)
|
||||
.with_system(update_processed_mouse_coords)
|
||||
.with_system(exit_on_esc_system)
|
||||
.with_system(close_on_esc)
|
||||
.with_system(light_movement)
|
||||
.with_system(move_light_friends)
|
||||
.with_system(update_floating_orbs_interpolation)
|
||||
|
@ -66,9 +66,7 @@ fn main() {
|
|||
.with_system(toggle_debug),
|
||||
)
|
||||
.add_system_set(
|
||||
SystemSet::on_update(AppState::Game)
|
||||
.with_run_criteria(debug_run_criteria)
|
||||
.with_system(debug_draw_illumination),
|
||||
SystemSet::on_update(AppState::Game).with_run_criteria(debug_run_criteria), // .with_system(debug_draw_illumination),
|
||||
)
|
||||
.run();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue