This commit is contained in:
Quaternions 2024-09-11 15:58:13 -07:00
parent b2a84e3be1
commit 60bd926ce1
2 changed files with 14 additions and 13 deletions

View File

@ -342,9 +342,9 @@ impl TryFrom<&model::Mesh> for PhysicsMesh{
let v0=mesh.unique_pos[vert0_id.get() as usize]; let v0=mesh.unique_pos[vert0_id.get() as usize];
let v1=mesh.unique_pos[vert1_id.get() as usize]; let v1=mesh.unique_pos[vert1_id.get() as usize];
normal+=Planar64Vec3::new( normal+=Planar64Vec3::new(
(v0.y()-v1.y())*(v0.z()+v1.z()), (v0.y-v1.y)*(v0.z+v1.z),
(v0.z()-v1.z())*(v0.x()+v1.x()), (v0.z-v1.z)*(v0.x+v1.x),
(v0.x()-v1.x())*(v0.y()+v1.y()), (v0.x-v1.x)*(v0.y+v1.y),
); );
//get/create edge and push face into it //get/create edge and push face into it
let (edge_ref_verts,is_sorted)=EdgeRefVerts::new(submesh_vert0_id,submesh_vert1_id); let (edge_ref_verts,is_sorted)=EdgeRefVerts::new(submesh_vert0_id,submesh_vert1_id);
@ -955,7 +955,7 @@ fn is_empty_volume(normals:Vec<Planar64Vec3>)->bool{
if k!=i&&k!=j{ if k!=i&&k!=j{
let d=n.dot(normals[k]); let d=n.dot(normals[k]);
if let Some(comp)=&d_comp{ if let Some(comp)=&d_comp{
if *comp*d<Planar64::ZERO{ if comp.is_negative()&&d.is_negative()||comp.is_positive()&&d.is_positive(){
return true; return true;
} }
}else{ }else{

View File

@ -413,7 +413,7 @@ impl HitboxMesh{
aabb.grow(vert); aabb.grow(vert);
} }
Self{ Self{
halfsize:aabb.size()/2, halfsize:aabb.size()>>1,
mesh, mesh,
transform, transform,
} }
@ -475,7 +475,7 @@ impl StyleHelper for StyleModifiers{
gameplay_style::HitboxMesh::Box=>PhysicsMesh::unit_cube(), gameplay_style::HitboxMesh::Box=>PhysicsMesh::unit_cube(),
gameplay_style::HitboxMesh::Cylinder=>PhysicsMesh::unit_cylinder(), gameplay_style::HitboxMesh::Cylinder=>PhysicsMesh::unit_cylinder(),
}; };
let transform=integer::Planar64Affine3::new(Planar64Mat3::from_diagonal(self.hitbox.halfsize),Planar64Vec3::ZERO); let transform=Planar64Mat3::from_diagonal(self.hitbox.halfsize).extend(Planar64Vec3::ZERO);
HitboxMesh::new(mesh,transform) HitboxMesh::new(mesh,transform)
} }
} }
@ -851,20 +851,20 @@ impl Body{
aabb.grow(self.extrapolated_position(t1)); aabb.grow(self.extrapolated_position(t1));
//v+a*t==0 //v+a*t==0
//goober code //goober code
if self.acceleration.x()!=Planar64::ZERO{ if self.acceleration.x!=Planar64::ZERO{
let t=Time::from(-self.velocity.x()/self.acceleration.x()); let t=Time::from(-self.velocity.x/self.acceleration.x);
if t0<t&&t<t1{ if t0<t&&t<t1{
aabb.grow(self.extrapolated_position(t)); aabb.grow(self.extrapolated_position(t));
} }
} }
if self.acceleration.y()!=Planar64::ZERO{ if self.acceleration.y!=Planar64::ZERO{
let t=Time::from(-self.velocity.y()/self.acceleration.y()); let t=Time::from(-self.velocity.y/self.acceleration.y);
if t0<t&&t<t1{ if t0<t&&t<t1{
aabb.grow(self.extrapolated_position(t)); aabb.grow(self.extrapolated_position(t));
} }
} }
if self.acceleration.z()!=Planar64::ZERO{ if self.acceleration.z!=Planar64::ZERO{
let t=Time::from(-self.velocity.z()/self.acceleration.z()); let t=Time::from(-self.velocity.z/self.acceleration.z);
if t0<t&&t<t1{ if t0<t&&t<t1{
aabb.grow(self.extrapolated_position(t)); aabb.grow(self.extrapolated_position(t));
} }
@ -1403,8 +1403,9 @@ fn teleport_to_spawn(
input_state:&InputState, input_state:&InputState,
time:Time, time:Time,
)->Result<(),TeleportToSpawnError>{ )->Result<(),TeleportToSpawnError>{
const EPSILON:Planar64=Planar64::raw((1<<32)/16);
let transform=models.get_model_transform(stage.spawn()).ok_or(TeleportToSpawnError::NoModel)?; let transform=models.get_model_transform(stage.spawn()).ok_or(TeleportToSpawnError::NoModel)?;
let point=transform.vertex.transform_point3(Planar64Vec3::Y)+Planar64Vec3::Y*(style.hitbox.halfsize.y()+Planar64::ONE/16); let point=transform.vertex.y_axis+Planar64Vec3::new([Planar64::ZERO,style.hitbox.halfsize.y+EPSILON,Planar64::ZERO]);
teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time); teleport(point,move_state,body,touching,run,mode_state,Some(mode),models,hitbox_mesh,bvh,style,camera,input_state,time);
Ok(()) Ok(())
} }