diff --git a/engine/physics/src/physics.rs b/engine/physics/src/physics.rs index 96bc0fa..26782e8 100644 --- a/engine/physics/src/physics.rs +++ b/engine/physics/src/physics.rs @@ -281,7 +281,8 @@ impl PhysicsCamera{ .clamp(Self::ANGLE_PITCH_LOWER_LIMIT,Self::ANGLE_PITCH_UPPER_LIMIT); mat3::from_rotation_yx(ax,ay) } - fn rotation(&self)->Planar64Mat3{ + #[inline] + pub fn rotation(&self)->Planar64Mat3{ self.get_rotation(self.clamped_mouse_pos) } fn simulate_move_rotation(&self,mouse_delta:glam::IVec2)->Planar64Mat3{ diff --git a/engine/session/src/session.rs b/engine/session/src/session.rs index e7959b3..55bf47b 100644 --- a/engine/session/src/session.rs +++ b/engine/session/src/session.rs @@ -161,6 +161,7 @@ pub struct Session{ recording:Recording, //players:HashMap<PlayerId,Simulation>, replays:HashMap<BotId,Replay>, + last_ray_hit:Option<strafesnet_common::model::ModelId>, } impl Session{ pub fn new( @@ -177,6 +178,7 @@ impl Session{ view_state:ViewState::Play, recording:Default::default(), replays:HashMap::new(), + last_ray_hit:None, } } fn clear_recording(&mut self){ @@ -194,6 +196,19 @@ impl Session{ ), } } + pub fn debug_raycast_print_model_id_if_changed(&mut self,time:SessionTime){ + if let Some(frame_state)=self.get_frame_state(time){ + let ray=strafesnet_common::ray::Ray{ + origin:frame_state.body.extrapolated_position(self.simulation.timer.time(time)), + direction:-frame_state.camera.rotation().z_axis, + }; + let model_id=self.geometry_shared.trace_ray(ray); + if model_id!=self.last_ray_hit{ + println!("hit={model_id:?}"); + self.last_ray_hit=model_id; + } + } + } pub fn user_settings(&self)->&UserSettings{ &self.user_settings } diff --git a/strafe-client/src/physics_worker.rs b/strafe-client/src/physics_worker.rs index 63ce68f..e6c1c92 100644 --- a/strafe-client/src/physics_worker.rs +++ b/strafe-client/src/physics_worker.rs @@ -77,5 +77,8 @@ pub fn new<'a>( run_session_instruction!(ins.time,SessionInstruction::LoadReplay(bot)); } } + + //whatever just do it + session.debug_raycast_print_model_id_if_changed(ins.time); }) }