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);
|
//touching.recalculate(body);
|
||||||
point
|
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
|
//This is not correct but is better than what I have
|
||||||
touching.contacts.retain(|contact|{
|
touching.contacts.retain(|contact|{
|
||||||
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
||||||
n.dot(v)<=Planar64::ZERO
|
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);
|
touching.constrain_velocity(&models,&mut v);
|
||||||
body.velocity=v;
|
body.velocity=v;
|
||||||
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
|
//This is not correct but is better than what I have
|
||||||
touching.contacts.retain(|contact|{
|
touching.contacts.retain(|contact|{
|
||||||
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
let n=models.mesh(contact.model_id).face_nd(contact.face_id).0;
|
||||||
n.dot(a)<=Planar64::ZERO
|
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);
|
touching.constrain_acceleration(&models,&mut a);
|
||||||
body.acceleration=a;
|
body.acceleration=a;
|
||||||
a
|
a
|
||||||
@ -1341,7 +1347,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
self.touching.constrain_velocity(&self.models,&mut target_velocity);
|
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);
|
let (walk_state,a)=WalkState::ladder(&self.body,&self.style,gravity,target_velocity,contact.clone(),&normal);
|
||||||
self.move_state=MoveState::Ladder(walk_state);
|
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)){
|
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
|
//ground
|
||||||
@ -1350,7 +1356,7 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
self.touching.constrain_velocity(&self.models,&mut target_velocity);
|
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);
|
let (walk_state,a)=WalkState::ground(&self.body,&self.style,gravity,target_velocity,contact.clone(),&normal);
|
||||||
self.move_state=MoveState::Walk(walk_state);
|
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
|
//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){
|
let calc_move=if self.style.get_control(StyleModifiers::CONTROL_JUMP,self.controls){
|
||||||
if let Some(walk_state)=get_walk_state(&self.move_state){
|
if let Some(walk_state)=get_walk_state(&self.move_state){
|
||||||
let n=jumped_velocity(&self.models,&self.style,walk_state,&mut v);
|
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)
|
Planar64::ZERO<n.dot(v)
|
||||||
}else{false}
|
}else{false}
|
||||||
}else{false};
|
}else{false};
|
||||||
@ -1390,13 +1396,13 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
},
|
},
|
||||||
None=>(),
|
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
|
//not sure if or is correct here
|
||||||
if calc_move||Planar64::ZERO<normal.dot(v){
|
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);
|
(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(){
|
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))=>{
|
(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);
|
let v=self.body.velocity+control_dir*(self.style.mv-d);
|
||||||
//this is wrong but will work ig
|
//this is wrong but will work ig
|
||||||
//need to note which push planes activate in push solve and keep those
|
//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 => {
|
PhysicsInstruction::ReachWalkTargetVelocity => {
|
||||||
@ -1439,9 +1445,9 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
WalkEnum::Transient(walk_target)=>{
|
WalkEnum::Transient(walk_target)=>{
|
||||||
//precisely set velocity
|
//precisely set velocity
|
||||||
let a=self.style.gravity;
|
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;
|
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;
|
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){
|
if let Some(walk_state)=get_walk_state(&self.move_state){
|
||||||
let mut v=self.body.velocity;
|
let mut v=self.body.velocity;
|
||||||
let n=jumped_velocity(&self.models,&self.style,walk_state,&mut v);
|
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){
|
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);
|
(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 => {
|
PhysicsInputInstruction::Reset => {
|
||||||
//it matters which of these runs first, but I have not thought it through yet as it doesn't matter yet
|
//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_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);
|
(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;
|
refresh_walk_target=false;
|
||||||
},
|
},
|
||||||
@ -1492,11 +1498,11 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
|
|||||||
}
|
}
|
||||||
if refresh_walk_target{
|
if refresh_walk_target{
|
||||||
if let Some(a)=self.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{
|
}else if let Some(rocket_force)=self.style.rocket_force{
|
||||||
let mut a=self.style.gravity;
|
let mut a=self.style.gravity;
|
||||||
a+=self.style.get_propulsion_control_dir(&self.camera,self.controls,&self.next_mouse,self.time)*rocket_force;
|
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