forked from StrafesNET/strafe-client
stop being so wide
This commit is contained in:
parent
4eda90e178
commit
6ca6e4ac3d
@ -24,7 +24,7 @@ type MinkowskiTransition=Transition<MinkowskiFace,MinkowskiDirectedEdge,Minkowsk
|
|||||||
let (n,d)=mesh.face_nd(face_id);
|
let (n,d)=mesh.face_nd(face_id);
|
||||||
//TODO: use higher precision d value?
|
//TODO: use higher precision d value?
|
||||||
//use the mesh transform translation instead of baking it into the d value.
|
//use the mesh transform translation instead of baking it into the d value.
|
||||||
for dt in Fixed::<4,128>::zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
for dt in Fixed::<2,64>::zeroes2((n.dot(body.position)-d).fix_2()*2,n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){
|
||||||
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_transtition=MinkowskiTransition::Hit(face_id,dt);
|
best_transtition=MinkowskiTransition::Hit(face_id,dt);
|
||||||
@ -38,7 +38,7 @@ type MinkowskiTransition=Transition<MinkowskiFace,MinkowskiDirectedEdge,Minkowsk
|
|||||||
let verts=mesh.edge_verts(directed_edge_id.as_undirected());
|
let verts=mesh.edge_verts(directed_edge_id.as_undirected());
|
||||||
//WARNING: d is moved out of the *2 block because of adding two vertices!
|
//WARNING: d is moved out of the *2 block because of adding two vertices!
|
||||||
//WARNING: precision is swept under the rug!
|
//WARNING: precision is swept under the rug!
|
||||||
for dt in Fixed::<4,128>::zeroes2(n.dot(body.position*2-(mesh.vert(verts[0])+mesh.vert(verts[1]))).fix_4(),n.dot(body.velocity).fix_4()*2,n.dot(body.acceleration).fix_4()){
|
for dt in Fixed::<2,64>::zeroes2(n.dot(body.position*2-(mesh.vert(verts[0])+mesh.vert(verts[1]))).fix_2(),n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){
|
||||||
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt);
|
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt);
|
||||||
@ -58,7 +58,7 @@ type MinkowskiTransition=Transition<MinkowskiFace,MinkowskiDirectedEdge,Minkowsk
|
|||||||
//edge_n gets parity from the order of edge_faces
|
//edge_n gets parity from the order of edge_faces
|
||||||
let n=face_n.cross(edge_n)*((i as i64)*2-1);
|
let n=face_n.cross(edge_n)*((i as i64)*2-1);
|
||||||
//WARNING yada yada d *2
|
//WARNING yada yada d *2
|
||||||
for dt in Fixed::<4,128>::zeroes2(n.dot(delta_pos).fix_4(),n.dot(body.velocity).fix_4()*2,n.dot(body.acceleration).fix_4()){
|
for dt in Fixed::<2,64>::zeroes2(n.dot(delta_pos).fix_2(),n.dot(body.velocity).fix_2()*2,n.dot(body.acceleration).fix_2()){
|
||||||
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Face(edge_face_id),dt);
|
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Face(edge_face_id),dt);
|
||||||
@ -72,7 +72,7 @@ type MinkowskiTransition=Transition<MinkowskiFace,MinkowskiDirectedEdge,Minkowsk
|
|||||||
let n=edge_n*(1-2*(i as i64));
|
let n=edge_n*(1-2*(i as i64));
|
||||||
for dt in Fixed::<2,64>::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
for dt in Fixed::<2,64>::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
||||||
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
let dt=Ratio::new(dt.num.fix_4(),dt.den.fix_4());
|
let dt=Ratio::new(dt.num.fix_2(),dt.den.fix_2());
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Vert(vert_id),dt);
|
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Vert(vert_id),dt);
|
||||||
break;
|
break;
|
||||||
@ -88,7 +88,7 @@ type MinkowskiTransition=Transition<MinkowskiFace,MinkowskiDirectedEdge,Minkowsk
|
|||||||
let n=-mesh.directed_edge_n(directed_edge_id);
|
let n=-mesh.directed_edge_n(directed_edge_id);
|
||||||
for dt in Fixed::<2,64>::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
for dt in Fixed::<2,64>::zeroes2((n.dot(body.position-mesh.vert(vert_id)))*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
||||||
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if body_time.le_ratio(dt)&&dt.lt_ratio(best_time)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
let dt=Ratio::new(dt.num.fix_4(),dt.den.fix_4());
|
let dt=Ratio::new(dt.num.fix_2(),dt.den.fix_2());
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt);
|
best_transtition=MinkowskiTransition::Next(MinkowskiFEV::Edge(directed_edge_id.as_undirected()),dt);
|
||||||
break;
|
break;
|
||||||
@ -108,11 +108,11 @@ type MinkowskiCrawlResult=CrawlResult<MinkowskiFace,MinkowskiDirectedEdge,Minkow
|
|||||||
pub fn crawl_fev(mut fev:MinkowskiFEV,mesh:&MinkowskiMesh,relative_body:&Body,start_time:Time,time_limit:Time)->MinkowskiCrawlResult{
|
pub fn crawl_fev(mut fev:MinkowskiFEV,mesh:&MinkowskiMesh,relative_body:&Body,start_time:Time,time_limit:Time)->MinkowskiCrawlResult{
|
||||||
let mut body_time={
|
let mut body_time={
|
||||||
let r=(start_time-relative_body.time).to_ratio();
|
let r=(start_time-relative_body.time).to_ratio();
|
||||||
Ratio::new(r.num.fix_4(),r.den.fix_4())
|
Ratio::new(r.num.fix_2(),r.den.fix_2())
|
||||||
};
|
};
|
||||||
let time_limit={
|
let time_limit={
|
||||||
let r=(time_limit-relative_body.time).to_ratio();
|
let r=(time_limit-relative_body.time).to_ratio();
|
||||||
Ratio::new(r.num.fix_4(),r.den.fix_4())
|
Ratio::new(r.num.fix_2(),r.den.fix_2())
|
||||||
};
|
};
|
||||||
for _ in 0..20{
|
for _ in 0..20{
|
||||||
match next_transition(&fev,body_time,mesh,relative_body,time_limit){
|
match next_transition(&fev,body_time,mesh,relative_body,time_limit){
|
||||||
|
@ -599,7 +599,7 @@ enum EV{
|
|||||||
Edge(MinkowskiEdge),
|
Edge(MinkowskiEdge),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type GigaTime=Ratio<Fixed<4,128>,Fixed<4,128>>;
|
pub type GigaTime=Ratio<Fixed<2,64>,Fixed<2,64>>;
|
||||||
|
|
||||||
impl MinkowskiMesh<'_>{
|
impl MinkowskiMesh<'_>{
|
||||||
pub fn minkowski_sum<'a>(mesh0:TransformedMesh<'a>,mesh1:TransformedMesh<'a>)->MinkowskiMesh<'a>{
|
pub fn minkowski_sum<'a>(mesh0:TransformedMesh<'a>,mesh1:TransformedMesh<'a>)->MinkowskiMesh<'a>{
|
||||||
@ -743,7 +743,7 @@ impl MinkowskiMesh<'_>{
|
|||||||
//determine when it passes an edge ("sliding off" case)
|
//determine when it passes an edge ("sliding off" case)
|
||||||
let mut best_time={
|
let mut best_time={
|
||||||
let r=(time_limit-relative_body.time).to_ratio();
|
let r=(time_limit-relative_body.time).to_ratio();
|
||||||
Ratio::new(r.num.fix_4(),r.den.fix_4())
|
Ratio::new(r.num.fix_2(),r.den.fix_2())
|
||||||
};
|
};
|
||||||
let mut best_edge=None;
|
let mut best_edge=None;
|
||||||
let face_n=self.face_nd(contact_face_id).0;
|
let face_n=self.face_nd(contact_face_id).0;
|
||||||
@ -755,7 +755,7 @@ impl MinkowskiMesh<'_>{
|
|||||||
let d=n.dot(self.vert(verts[0])+self.vert(verts[1]));
|
let d=n.dot(self.vert(verts[0])+self.vert(verts[1]));
|
||||||
//WARNING! d outside of *2
|
//WARNING! d outside of *2
|
||||||
//WARNING: truncated precision
|
//WARNING: truncated precision
|
||||||
for dt in Fixed::<4,128>::zeroes2(((n.dot(relative_body.position))*2-d).fix_4(),n.dot(relative_body.velocity).fix_4()*2,n.dot(relative_body.acceleration).fix_4()){
|
for dt in Fixed::<2,64>::zeroes2(((n.dot(relative_body.position))*2-d).fix_2(),n.dot(relative_body.velocity).fix_2()*2,n.dot(relative_body.acceleration).fix_2()){
|
||||||
if dt.num.is_positive()&&dt.lt_ratio(best_time)&&n.dot(relative_body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
if dt.num.is_positive()&&dt.lt_ratio(best_time)&&n.dot(relative_body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
||||||
best_time=dt;
|
best_time=dt;
|
||||||
best_edge=Some(directed_edge_id);
|
best_edge=Some(directed_edge_id);
|
||||||
@ -849,7 +849,7 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
|
|||||||
let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).borrow();
|
let &[e1f0,e1f1]=self.mesh1.edge_faces(e1).borrow();
|
||||||
Cow::Owned([(e1f1,false),(e1f0,true)].map(|(edge_face_id1,face_parity)|{
|
Cow::Owned([(e1f1,false),(e1f0,true)].map(|(edge_face_id1,face_parity)|{
|
||||||
let mut best_edge=None;
|
let mut best_edge=None;
|
||||||
let mut best_d:Ratio<Fixed<8,256>,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE);
|
let mut best_d:Ratio<Fixed<2,64>,Fixed<2,64>>=Ratio::new(Fixed::ZERO,Fixed::ONE);
|
||||||
let edge_face1_n=self.mesh1.face_nd(edge_face_id1).0;
|
let edge_face1_n=self.mesh1.face_nd(edge_face_id1).0;
|
||||||
let edge_face1_nn=edge_face1_n.dot(edge_face1_n);
|
let edge_face1_nn=edge_face1_n.dot(edge_face1_n);
|
||||||
for &directed_edge_id0 in v0e.iter(){
|
for &directed_edge_id0 in v0e.iter(){
|
||||||
@ -860,7 +860,7 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
|
|||||||
let edge0_nn=edge0_n.dot(edge0_n);
|
let edge0_nn=edge0_n.dot(edge0_n);
|
||||||
// Assume not every number is huge
|
// Assume not every number is huge
|
||||||
// TODO: revisit this
|
// TODO: revisit this
|
||||||
let dd=(d*d)/(edge_face1_nn*edge0_nn);
|
let dd=(d*d).fix_2()/(edge_face1_nn*edge0_nn).fix_2();
|
||||||
if best_d<dd{
|
if best_d<dd{
|
||||||
best_d=dd;
|
best_d=dd;
|
||||||
best_edge=Some(directed_edge_id0);
|
best_edge=Some(directed_edge_id0);
|
||||||
@ -879,7 +879,7 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
|
|||||||
let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).borrow();
|
let &[e0f0,e0f1]=self.mesh0.edge_faces(e0).borrow();
|
||||||
Cow::Owned([(e0f0,true),(e0f1,false)].map(|(edge_face_id0,face_parity)|{
|
Cow::Owned([(e0f0,true),(e0f1,false)].map(|(edge_face_id0,face_parity)|{
|
||||||
let mut best_edge=None;
|
let mut best_edge=None;
|
||||||
let mut best_d:Ratio<Fixed<8,256>,Fixed<8,256>>=Ratio::new(Fixed::ZERO,Fixed::ONE);
|
let mut best_d:Ratio<Fixed<2,64>,Fixed<2,64>>=Ratio::new(Fixed::ZERO,Fixed::ONE);
|
||||||
let edge_face0_n=self.mesh0.face_nd(edge_face_id0).0;
|
let edge_face0_n=self.mesh0.face_nd(edge_face_id0).0;
|
||||||
let edge_face0_nn=edge_face0_n.dot(edge_face0_n);
|
let edge_face0_nn=edge_face0_n.dot(edge_face0_n);
|
||||||
for &directed_edge_id1 in v1e.iter(){
|
for &directed_edge_id1 in v1e.iter(){
|
||||||
@ -887,7 +887,7 @@ impl MeshQuery<MinkowskiFace,MinkowskiDirectedEdge,MinkowskiVert> for MinkowskiM
|
|||||||
let d=edge_face0_n.dot(edge1_n);
|
let d=edge_face0_n.dot(edge1_n);
|
||||||
if d.is_negative(){
|
if d.is_negative(){
|
||||||
let edge1_nn=edge1_n.dot(edge1_n);
|
let edge1_nn=edge1_n.dot(edge1_n);
|
||||||
let dd=(d*d)/(edge_face0_nn*edge1_nn);
|
let dd=(d*d).fix_2()/(edge_face0_nn*edge1_nn).fix_2();
|
||||||
if best_d<dd{
|
if best_d<dd{
|
||||||
best_d=dd;
|
best_d=dd;
|
||||||
best_edge=Some(directed_edge_id1);
|
best_edge=Some(directed_edge_id1);
|
||||||
|
Loading…
Reference in New Issue
Block a user