MASSIVE Kinematic Character Controller Update
- NEW kinematic character controller powered by rapier3d at kinematic_character_controller.rs - NEW camera modes. The ability to switch between the free debug camera and new character controller. - NEW keybinds system to support the camera mode swap
This commit is contained in:
parent
8b5a6167eb
commit
713d865dd7
12 changed files with 323 additions and 26 deletions
|
|
@ -7,6 +7,7 @@ edition = "2024"
|
|||
raidillon_assets = { path = "../asset" }
|
||||
raidillon_core = { path = "../core" }
|
||||
raidillon_platform = { path = "../platform" }
|
||||
raidillon_ecs = { path = "../ecs" }
|
||||
winit = "0.30.12"
|
||||
hecs = "0.10.5"
|
||||
indexmap = "2.10.0"
|
||||
|
|
|
|||
|
|
@ -6,3 +6,4 @@ mod resources;
|
|||
|
||||
pub use crate::engine::Engine;
|
||||
pub use crate::resources::EngineResources;
|
||||
pub use input::InputState;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use raidillon_platform::{Camera, PlatformContext};
|
|||
use crate::input::InputState;
|
||||
use crate::resources::EngineResources;
|
||||
use raidillon_core::scene::Scene;
|
||||
use raidillon_ecs::components::CameraMode;
|
||||
|
||||
pub struct FPSDebugCameraSystem {
|
||||
mouse_delta: (f64, f64),
|
||||
|
|
@ -35,20 +36,10 @@ impl Default for FPSDebugCameraSystem {
|
|||
}
|
||||
|
||||
impl System for FPSDebugCameraSystem {
|
||||
fn load_world(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
let pctx = res.get::<PlatformContext>().unwrap();
|
||||
scene.world.spawn((Camera {
|
||||
eye: Vec3::new(0.0, 0.0, 2.0),
|
||||
center: Vec3::ZERO,
|
||||
up: Vec3::Y,
|
||||
fovy: 60_f32.to_radians(),
|
||||
aspect: pctx.frame_width / pctx.frame_height,
|
||||
znear: 0.1,
|
||||
zfar: 100.0,
|
||||
},));
|
||||
}
|
||||
|
||||
fn handle_event(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
if !self.is_camera_mode_valid(scene) {
|
||||
return
|
||||
}
|
||||
let pctx = res.get::<PlatformContext>().unwrap();
|
||||
let event2 = pctx.current_event.clone();
|
||||
match event2 {
|
||||
|
|
@ -92,6 +83,9 @@ impl System for FPSDebugCameraSystem {
|
|||
}
|
||||
|
||||
fn frame_update(&mut self, res: &mut EngineResources, scene: &mut Scene) {
|
||||
if !self.is_camera_mode_valid(scene) {
|
||||
return
|
||||
}
|
||||
let (pctx, input) = res.get_many::<(PlatformContext, InputState)>().unwrap();
|
||||
|
||||
if self.mouse_enabled {
|
||||
|
|
@ -134,4 +128,13 @@ impl FPSDebugCameraSystem {
|
|||
yaw_rad.sin() * pitch_rad.cos(),
|
||||
).normalize()
|
||||
}
|
||||
|
||||
fn is_camera_mode_valid(&self, scene: &mut Scene) -> bool {
|
||||
let mut q = scene.world.query::<(&Camera, &CameraMode)>();
|
||||
let (cam_ent, (cam, cam_mode)) = q
|
||||
.iter()
|
||||
.next()
|
||||
.unwrap();
|
||||
*cam_mode == CameraMode::Debug
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue