forked from StrafesNET/strafe-project
Compare commits
4 Commits
data-struc
...
speed-prin
| Author | SHA1 | Date | |
|---|---|---|---|
| c9b06823e7 | |||
| c58ea36d28 | |||
| 3bad427f61 | |||
| 90cca51e6e |
@@ -221,7 +221,7 @@ impl GraphicsState{
|
||||
for model in indexed_models.models.into_iter(){
|
||||
//convert ModelInstance into GraphicsModelInstance
|
||||
let instances:Vec<GraphicsModelInstance>=model.instances.into_iter().filter_map(|instance|{
|
||||
if instance.color.w==0.0{
|
||||
if instance.color.w==0.0&&!model.groups.iter().any(|g|g.texture.is_some()){
|
||||
None
|
||||
}else{
|
||||
Some(GraphicsModelInstance{
|
||||
|
||||
@@ -16,12 +16,6 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
||||
Ok(bsp)=>{
|
||||
let mut spawn_point=integer::Planar64Vec3::ZERO;
|
||||
|
||||
let vertices: Vec<_> = bsp
|
||||
.vertices
|
||||
.iter()
|
||||
.map(|vertex|<[f32;3]>::from(vertex.position))
|
||||
.collect();
|
||||
|
||||
let mut name_from_texture_id=Vec::new();
|
||||
let mut texture_id_from_name=std::collections::HashMap::new();
|
||||
|
||||
@@ -54,10 +48,11 @@ pub fn generate_indexed_models<R:std::io::Read+std::io::Seek>(input:&mut R)->Res
|
||||
let normal=face.normal();
|
||||
let normal_idx=spam_normal.len() as u32;
|
||||
spam_normal.push(valve_transform(<[f32;3]>::from(normal)));
|
||||
let mut vertices:Vec<u32>=face.vertex_indexes().map(|vertex_index|{
|
||||
let pos=glam::Vec3A::from_array(vertices[vertex_index as usize]);
|
||||
let mut vertices:Vec<u32>=face.vertex_positions().map(|vertex_pos|{
|
||||
let vertex_xyz=<[f32;3]>::from(vertex_pos);
|
||||
let pos=glam::Vec3A::from_array(vertex_xyz);
|
||||
let pos_idx=spam_pos.len();
|
||||
spam_pos.push(valve_transform(vertices[vertex_index as usize]));
|
||||
spam_pos.push(valve_transform(vertex_xyz));
|
||||
|
||||
//calculate texture coordinates
|
||||
let tex=(glam::vec2(pos.dot(texture_u),pos.dot(texture_v))+texture_offset)/texture_size;
|
||||
|
||||
@@ -727,7 +727,7 @@ enum MoveState{
|
||||
|
||||
pub struct PhysicsState{
|
||||
time:Time,
|
||||
body:Body,
|
||||
pub body:Body,
|
||||
world:WorldState,//currently there is only one state the world can be in
|
||||
game:GameMechanicsState,
|
||||
style:StyleModifiers,
|
||||
@@ -744,6 +744,8 @@ pub struct PhysicsState{
|
||||
//the spawn point is where you spawn when you load into the map.
|
||||
//This is not the same as Reset which teleports you to Spawn0
|
||||
spawn_point:Planar64Vec3,
|
||||
//lmao lets go
|
||||
start_time:Option<Time>,
|
||||
}
|
||||
#[derive(Clone,Default)]
|
||||
pub struct PhysicsOutputState{
|
||||
@@ -1086,6 +1088,7 @@ impl Default for PhysicsState{
|
||||
world:WorldState{},
|
||||
game:GameMechanicsState::default(),
|
||||
modes:Modes::default(),
|
||||
start_time:None,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1569,6 +1572,21 @@ impl instruction::InstructionConsumer<PhysicsInstruction> for PhysicsState {
|
||||
set_acceleration(&mut self.body,&self.touching,&self.models,&self.style.mesh(),a);
|
||||
},
|
||||
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
||||
//check for mapstart and set start time
|
||||
let model_id=c.model_id();
|
||||
let start_model_id=self.modes.get_mode(0).unwrap().start;
|
||||
if model_id==start_model_id{
|
||||
//object touched is a mapstart
|
||||
println!("Start!");
|
||||
self.start_time=Some(self.time);
|
||||
}
|
||||
|
||||
//check for map finish and print end time
|
||||
if general.zone.as_ref().is_some_and(|zone|zone.behaviour==crate::model::ZoneBehaviour::Finish){
|
||||
if let Some(start_time)=self.start_time.take(){
|
||||
println!("Finish! Time={}",self.time-start_time);
|
||||
}
|
||||
}
|
||||
//I think that setting the velocity to 0 was preventing surface contacts from entering an infinite loop
|
||||
self.touching.insert(c);
|
||||
run_teleport_behaviour(&general.teleport_behaviour,&mut self.game,&self.models,&self.modes,&self.style,&mut self.touching,&mut self.body,model_id);
|
||||
|
||||
@@ -27,6 +27,7 @@ pub enum Instruction{
|
||||
let mut mouse_blocking=true;
|
||||
let mut last_mouse_time=physics.next_mouse.time;
|
||||
let mut timeline=std::collections::VecDeque::new();
|
||||
let mut next_velocity_print=std::time::Instant::now();
|
||||
crate::compat_worker::QNWorker::new(move |ins:TimedInstruction<Instruction>|{
|
||||
if if let Some(phys_input)=match &ins.instruction{
|
||||
Instruction::Input(input_instruction)=>match input_instruction{
|
||||
@@ -110,6 +111,12 @@ pub enum Instruction{
|
||||
instruction:crate::physics::PhysicsInstruction::Input(instruction.instruction),
|
||||
});
|
||||
}
|
||||
|
||||
//some random print stuff
|
||||
if 3.0/5.0<next_velocity_print.elapsed().as_secs_f64(){
|
||||
next_velocity_print=next_velocity_print+std::time::Duration::from_secs_f64(3.0/5.0);
|
||||
println!("speed={}",physics.body.velocity.length());
|
||||
}
|
||||
}
|
||||
match ins.instruction{
|
||||
Instruction::Render=>{
|
||||
|
||||
Reference in New Issue
Block a user