random garbage

This commit is contained in:
Quaternions 2024-02-08 23:00:36 -08:00
parent d19f5cb3ef
commit 3335e93b70

View File

@ -550,16 +550,13 @@ pub struct PhysicsModel{
} }
impl PhysicsModel{ impl PhysicsModel{
pub const fn new(mesh_id:PhysicsMeshId,attr_id:PhysicsAttributesId,transform:PhysicsMeshTransform)->Self{ const fn new(mesh_id:PhysicsMeshId,attr_id:PhysicsAttributesId,transform:PhysicsMeshTransform)->Self{
Self{ Self{
mesh_id, mesh_id,
attr_id, attr_id,
transform, transform,
} }
} }
const fn transform(&self)->&PhysicsMeshTransform{
&self.transform
}
} }
#[derive(Debug,Clone,Eq,Hash,PartialEq)] #[derive(Debug,Clone,Eq,Hash,PartialEq)]
@ -577,13 +574,13 @@ enum Collision{
Intersect(IntersectCollision), Intersect(IntersectCollision),
} }
impl Collision{ impl Collision{
fn convex_mesh_id(&self)->ConvexMeshId{ const fn convex_mesh_id(&self)->ConvexMeshId{
match self{ match self{
&Collision::Contact(ContactCollision{convex_mesh_id,face_id:_}) &Collision::Contact(ContactCollision{convex_mesh_id,face_id:_})
|&Collision::Intersect(IntersectCollision{convex_mesh_id})=>convex_mesh_id, |&Collision::Intersect(IntersectCollision{convex_mesh_id})=>convex_mesh_id,
} }
} }
fn face_id(&self)->Option<model_physics::MinkowskiFace>{ const fn face_id(&self)->Option<model_physics::MinkowskiFace>{
match self{ match self{
&Collision::Contact(ContactCollision{convex_mesh_id:_,face_id})=>Some(face_id), &Collision::Contact(ContactCollision{convex_mesh_id:_,face_id})=>Some(face_id),
&Collision::Intersect(IntersectCollision{convex_mesh_id:_})=>None, &Collision::Intersect(IntersectCollision{convex_mesh_id:_})=>None,
@ -711,7 +708,7 @@ impl TouchingState{
//detect face slide off //detect face slide off
let model_mesh=models.mesh(contact.convex_mesh_id); let model_mesh=models.mesh(contact.convex_mesh_id);
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh()); let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh());
collector.collect(minkowski.predict_collision_face_out(&relative_body,collector.time(),contact.face_id).map(|(face,time)|{ collector.collect(minkowski.predict_collision_face_out(&relative_body,collector.time(),contact.face_id).map(|(_face,time)|{
TimedInstruction{ TimedInstruction{
time, time,
instruction:PhysicsInstruction::CollisionEnd( instruction:PhysicsInstruction::CollisionEnd(
@ -724,7 +721,7 @@ impl TouchingState{
//detect model collision in reverse //detect model collision in reverse
let model_mesh=models.mesh(intersect.convex_mesh_id); let model_mesh=models.mesh(intersect.convex_mesh_id);
let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh()); let minkowski=model_physics::MinkowskiMesh::minkowski_sum(model_mesh,hitbox_mesh.transformed_mesh());
collector.collect(minkowski.predict_collision_out(&relative_body,collector.time()).map(|(face,time)|{ collector.collect(minkowski.predict_collision_out(&relative_body,collector.time()).map(|(_face,time)|{
TimedInstruction{ TimedInstruction{
time, time,
instruction:PhysicsInstruction::CollisionEnd( instruction:PhysicsInstruction::CollisionEnd(
@ -737,7 +734,7 @@ impl TouchingState{
} }
impl Body{ impl Body{
pub fn new(position:Planar64Vec3,velocity:Planar64Vec3,acceleration:Planar64Vec3,time:Time)->Self{ pub const fn new(position:Planar64Vec3,velocity:Planar64Vec3,acceleration:Planar64Vec3,time:Time)->Self{
Self{ Self{
position, position,
velocity, velocity,
@ -806,7 +803,7 @@ struct VirtualBody<'a>{
body1:&'a Body, body1:&'a Body,
} }
impl VirtualBody<'_>{ impl VirtualBody<'_>{
fn relative<'a>(body0:&'a Body,body1:&'a Body)->VirtualBody<'a>{ const fn relative<'a>(body0:&'a Body,body1:&'a Body)->VirtualBody<'a>{
//(p0,v0,a0,t0) //(p0,v0,a0,t0)
//(p1,v1,a1,t1) //(p1,v1,a1,t1)
VirtualBody{ VirtualBody{