separate culling type setters
This commit is contained in:
parent
4456ee29ec
commit
f7072be5b4
@ -1200,22 +1200,28 @@ fn set_position(body:&mut Body,touching:&mut TouchingState,point:Planar64Vec3)->
|
||||
//touching.recalculate(body);
|
||||
point
|
||||
}
|
||||
fn set_velocity(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,mut v:Planar64Vec3)->Planar64Vec3{
|
||||
fn set_velocity_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,v:Planar64Vec3)->Planar64Vec3{
|
||||
//This is not correct but is better than what I have
|
||||
touching.contacts.retain(|contact|{
|
||||
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
||||
n.dot(v)<=Planar64::ZERO
|
||||
});
|
||||
set_velocity(body,touching,models,v)
|
||||
}
|
||||
fn set_velocity(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,mut v:Planar64Vec3)->Planar64Vec3{
|
||||
touching.constrain_velocity(&models,&mut v);
|
||||
body.velocity=v;
|
||||
v
|
||||
}
|
||||
fn set_acceleration(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,mut a:Planar64Vec3)->Planar64Vec3{
|
||||
fn set_acceleration_cull(body:&mut Body,touching:&mut TouchingState,models:&PhysicsModels,a:Planar64Vec3)->Planar64Vec3{
|
||||
//This is not correct but is better than what I have
|
||||
touching.contacts.retain(|contact|{
|
||||
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
||||
n.dot(a)<=Planar64::ZERO
|
||||
});
|
||||
set_acceleration(body,touching,models,a)
|
||||
}
|
||||
fn set_acceleration(body:&mut Body,touching:&TouchingState,models:&PhysicsModels,mut a:Planar64Vec3)->Planar64Vec3{
|
||||
touching.constrain_acceleration(&models,&mut a);
|
||||
body.acceleration=a;
|
||||
a
|
||||
@ -1341,7 +1347,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
self.touching.constrain_velocity(&self.models,&mut target_velocity);
|
||||
let (walk_state,a)=WalkState::ladder(&self.body,&self.style,gravity,target_velocity,contact.clone(),&normal);
|
||||
self.move_state=MoveState::Ladder(walk_state);
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration(&mut self.body,&self.touching,&self.models,a);
|
||||
}
|
||||
None=>if self.style.surf_slope.map_or(true,|s|self.models.mesh(model_id).face_nd(contact.face_id).0.walkable(s,Planar64Vec3::Y)){
|
||||
//ground
|
||||
@ -1350,7 +1356,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
self.touching.constrain_velocity(&self.models,&mut target_velocity);
|
||||
let (walk_state,a)=WalkState::ground(&self.body,&self.style,gravity,target_velocity,contact.clone(),&normal);
|
||||
self.move_state=MoveState::Walk(walk_state);
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration(&mut self.body,&self.touching,&self.models,a);
|
||||
},
|
||||
}
|
||||
//check ground
|
||||
@ -1373,7 +1379,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
let calc_move=if self.style.get_control(StyleModifiers::CONTROL_JUMP,self.controls){
|
||||
if let Some(walk_state)=get_walk_state(&self.move_state){
|
||||
let n=jumped_velocity(&self.models,&self.style,walk_state,&mut v);
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,v);
|
||||
set_velocity_cull(&mut self.body,&mut self.touching,&self.models,v);
|
||||
Planar64::ZERO<n.dot(v)
|
||||
}else{false}
|
||||
}else{false};
|
||||
@ -1390,13 +1396,13 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
},
|
||||
None=>(),
|
||||
}
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,v);
|
||||
set_velocity(&mut self.body,&self.touching,&self.models,v);
|
||||
//not sure if or is correct here
|
||||
if calc_move||Planar64::ZERO<normal.dot(v){
|
||||
(self.move_state,self.body.acceleration)=self.touching.get_move_state(&self.body,&self.models,&self.style,&self.camera,self.controls,&self.next_mouse,self.time);
|
||||
}
|
||||
if let Some(a)=self.refresh_walk_target(){
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration(&mut self.body,&self.touching,&self.models,a);
|
||||
}
|
||||
},
|
||||
(PhysicsCollisionAttributes::Intersect{intersecting: _,general},Collision::Intersect(intersect))=>{
|
||||
@ -1427,7 +1433,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
let v=self.body.velocity+control_dir*(self.style.mv-d);
|
||||
//this is wrong but will work ig
|
||||
//need to note which push planes activate in push solve and keep those
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,v);
|
||||
set_velocity_cull(&mut self.body,&mut self.touching,&self.models,v);
|
||||
}
|
||||
}
|
||||
PhysicsInstruction::ReachWalkTargetVelocity => {
|
||||
@ -1439,9 +1445,9 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
WalkEnum::Transient(walk_target)=>{
|
||||
//precisely set velocity
|
||||
let a=self.style.gravity;
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration(&mut self.body,&self.touching,&self.models,a);
|
||||
let v=walk_target.velocity;
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,v);
|
||||
set_velocity(&mut self.body,&self.touching,&self.models,v);
|
||||
walk_state.state=WalkEnum::Reached;
|
||||
},
|
||||
}
|
||||
@ -1470,7 +1476,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
if let Some(walk_state)=get_walk_state(&self.move_state){
|
||||
let mut v=self.body.velocity;
|
||||
let n=jumped_velocity(&self.models,&self.style,walk_state,&mut v);
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,v);
|
||||
set_velocity_cull(&mut self.body,&mut self.touching,&self.models,v);
|
||||
if Planar64::ZERO<n.dot(v){
|
||||
(self.move_state,self.body.acceleration)=self.touching.get_move_state(&self.body,&self.models,&self.style,&self.camera,self.controls,&self.next_mouse,self.time);
|
||||
}
|
||||
@ -1484,7 +1490,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
PhysicsInputInstruction::Reset => {
|
||||
//it matters which of these runs first, but I have not thought it through yet as it doesn't matter yet
|
||||
set_position(&mut self.body,&mut self.touching,self.spawn_point);
|
||||
set_velocity(&mut self.body,&mut self.touching,&self.models,Planar64Vec3::ZERO);
|
||||
set_velocity(&mut self.body,&self.touching,&self.models,Planar64Vec3::ZERO);
|
||||
(self.move_state,self.body.acceleration)=self.touching.get_move_state(&self.body,&self.models,&self.style,&self.camera,self.controls,&self.next_mouse,self.time);
|
||||
refresh_walk_target=false;
|
||||
},
|
||||
@ -1492,11 +1498,11 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
||||
}
|
||||
if refresh_walk_target{
|
||||
if let Some(a)=self.refresh_walk_target(){
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration_cull(&mut self.body,&mut self.touching,&self.models,a);
|
||||
}else if let Some(rocket_force)=self.style.rocket_force{
|
||||
let mut a=self.style.gravity;
|
||||
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
|
||||
set_acceleration(&mut self.body,&mut self.touching,&self.models,a);
|
||||
set_acceleration_cull(&mut self.body,&mut self.touching,&self.models,a);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user