Session::debug_raycast_print_model_id_if_changed

This commit is contained in:
Quaternions 2025-02-21 12:50:57 -08:00
parent 7be7d40c8a
commit f52399a931
3 changed files with 20 additions and 1 deletions
engine
physics/src
session/src
strafe-client/src

@ -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{

@ -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
}

@ -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);
})
}