diff --git a/src/physics.rs b/src/physics.rs index 744c981..e6ce316 100644 --- a/src/physics.rs +++ b/src/physics.rs @@ -345,6 +345,20 @@ struct Hitbox{ normal_transform:Planar64Mat3, } impl Hitbox{ + fn new(mesh:PhysicsMesh,transform:crate::integer::Planar64Affine3)->Self{ + //calculate extents + let normal_transform=transform.matrix3.inverse().transpose(); + let mut aabb=crate::aabb::Aabb::default(); + for vert in mesh.verts(){ + aabb.grow(transform.transform_point3(vert)); + } + Self{ + halfsize:aabb.size()/2, + mesh, + transform, + normal_transform, + } + } fn from_mesh_scale(mesh:PhysicsMesh,scale:Planar64Vec3)->Self{ Self{ halfsize:scale, @@ -1654,8 +1668,8 @@ impl crate::instruction::InstructionConsumer for PhysicsStat } #[allow(dead_code)] -fn test_collision(relative_body:Body,expected_collision_time:Option