test transform

This commit is contained in:
Quaternions 2023-11-20 19:47:28 -08:00
parent 9a2b033241
commit f04e6ee4b7

View File

@ -353,6 +353,14 @@ impl Hitbox{
normal_transform:Planar64Mat3::from_diagonal(scale).inverse().transpose(), normal_transform:Planar64Mat3::from_diagonal(scale).inverse().transpose(),
} }
} }
fn from_mesh_scale_offset(mesh:PhysicsMesh,scale:Planar64Vec3,offset:Planar64Vec3)->Self{
Self{
halfsize:scale,
mesh,
transform:crate::integer::Planar64Affine3::new(Planar64Mat3::from_diagonal(scale),offset),
normal_transform:Planar64Mat3::from_diagonal(scale).inverse().transpose(),
}
}
fn roblox()->Self{ fn roblox()->Self{
Self::from_mesh_scale(PhysicsMesh::from(&crate::primitives::unit_cylinder()),Planar64Vec3::int(2,5,2)/2) Self::from_mesh_scale(PhysicsMesh::from(&crate::primitives::unit_cylinder()),Planar64Vec3::int(2,5,2)/2)
} }
@ -1644,11 +1652,11 @@ impl crate::instruction::InstructionConsumer<PhysicsInstruction> for PhysicsStat
#[test] #[test]
fn hit_the_ground(){ fn hit_the_ground(){
let h0=Hitbox::roblox(); let h0=Hitbox::roblox();
let h1=Hitbox::roblox(); let h1=Hitbox::from_mesh_scale_offset(PhysicsMesh::from(&crate::primitives::unit_cylinder()),Planar64Vec3::int(2,5,2)/2,Planar64Vec3::int(10,0,10));
let mesh0=h0.transformed_mesh(); let mesh0=h0.transformed_mesh();
let mesh1=h1.transformed_mesh(); let mesh1=h1.transformed_mesh();
let relative_body=Body::new( let relative_body=Body::new(
Planar64Vec3::Y*10, Planar64Vec3::ONE*10,
Planar64Vec3::int(1,-160,2)/16, Planar64Vec3::int(1,-160,2)/16,
Planar64Vec3::ZERO, Planar64Vec3::ZERO,
Time::ZERO Time::ZERO