misc
This commit is contained in:
parent
b065f83faf
commit
9aec0e1b52
@ -50,12 +50,12 @@ pub enum StageElementBehaviour{
|
||||
Checkpoint,//this is a combined behaviour for Ordered & Unordered in case a model is used multiple times or for both.
|
||||
}
|
||||
|
||||
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq)]
|
||||
#[derive(Clone,Copy,Debug,Hash,id::Id,Eq,PartialEq)]
|
||||
pub struct CheckpointId(u32);
|
||||
impl CheckpointId{
|
||||
pub const FIRST:Self=Self(0);
|
||||
}
|
||||
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
||||
#[derive(Clone,Copy,Debug,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
||||
pub struct StageId(u32);
|
||||
impl StageId{
|
||||
pub const FIRST:Self=Self(0);
|
||||
@ -120,7 +120,7 @@ pub enum Zone{
|
||||
Finish,
|
||||
Anticheat,
|
||||
}
|
||||
#[derive(Clone,Copy,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
||||
#[derive(Clone,Copy,Debug,Hash,id::Id,Eq,PartialEq,Ord,PartialOrd)]
|
||||
pub struct ModeId(u32);
|
||||
impl ModeId{
|
||||
pub const MAIN:Self=Self(0);
|
||||
|
@ -10,24 +10,24 @@ impl Time{
|
||||
pub const ONE_MICROSECOND:Self=Self(1_000);
|
||||
pub const ONE_NANOSECOND:Self=Self(1);
|
||||
#[inline]
|
||||
pub fn from_secs(num:i64)->Self{
|
||||
pub const fn from_secs(num:i64)->Self{
|
||||
Self(Self::ONE_SECOND.0*num)
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_millis(num:i64)->Self{
|
||||
pub const fn from_millis(num:i64)->Self{
|
||||
Self(Self::ONE_MILLISECOND.0*num)
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_micros(num:i64)->Self{
|
||||
pub const fn from_micros(num:i64)->Self{
|
||||
Self(Self::ONE_MICROSECOND.0*num)
|
||||
}
|
||||
#[inline]
|
||||
pub fn from_nanos(num:i64)->Self{
|
||||
pub const fn from_nanos(num:i64)->Self{
|
||||
Self(Self::ONE_NANOSECOND.0*num)
|
||||
}
|
||||
//should I have checked subtraction? force all time variables to be positive?
|
||||
#[inline]
|
||||
pub fn nanos(&self)->i64{
|
||||
pub const fn nanos(self)->i64{
|
||||
self.0
|
||||
}
|
||||
}
|
||||
@ -91,7 +91,7 @@ const fn gcd(mut a:u64,mut b:u64)->u64{
|
||||
};
|
||||
a
|
||||
}
|
||||
#[derive(Clone,Hash)]
|
||||
#[derive(Clone,Copy,Debug,Hash)]
|
||||
pub struct Ratio64{
|
||||
num:i64,
|
||||
den:u64,
|
||||
@ -109,15 +109,15 @@ impl Ratio64{
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn mul_int(&self,rhs:i64)->i64{
|
||||
pub const fn mul_int(&self,rhs:i64)->i64{
|
||||
rhs*self.num/(self.den as i64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn rhs_div_int(&self,rhs:i64)->i64{
|
||||
pub const fn rhs_div_int(&self,rhs:i64)->i64{
|
||||
rhs*(self.den as i64)/self.num
|
||||
}
|
||||
#[inline]
|
||||
pub fn mul_ref(&self,rhs:&Ratio64)->Ratio64{
|
||||
pub const fn mul_ref(&self,rhs:&Ratio64)->Ratio64{
|
||||
let (num,den)=(self.num*rhs.num,self.den*rhs.den);
|
||||
let d=gcd(num.unsigned_abs(),den);
|
||||
Self{
|
||||
@ -259,7 +259,7 @@ impl std::ops::Div<u64> for Ratio64{
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone,Hash)]
|
||||
#[derive(Clone,Copy,Debug,Hash)]
|
||||
pub struct Ratio64Vec2{
|
||||
pub x:Ratio64,
|
||||
pub y:Ratio64,
|
||||
@ -267,11 +267,11 @@ pub struct Ratio64Vec2{
|
||||
impl Ratio64Vec2{
|
||||
pub const ONE:Self=Self{x:Ratio64::ONE,y:Ratio64::ONE};
|
||||
#[inline]
|
||||
pub fn new(x:Ratio64,y:Ratio64)->Self{
|
||||
pub const fn new(x:Ratio64,y:Ratio64)->Self{
|
||||
Self{x,y}
|
||||
}
|
||||
#[inline]
|
||||
pub fn mul_int(&self,rhs:glam::I64Vec2)->glam::I64Vec2{
|
||||
pub const fn mul_int(&self,rhs:glam::I64Vec2)->glam::I64Vec2{
|
||||
glam::i64vec2(
|
||||
self.x.mul_int(rhs.x),
|
||||
self.y.mul_int(rhs.y),
|
||||
@ -606,15 +606,15 @@ impl Planar64Vec3{
|
||||
Self(glam::i64vec3(x,y,z))
|
||||
}
|
||||
#[inline]
|
||||
pub fn x(&self)->Planar64{
|
||||
pub const fn x(&self)->Planar64{
|
||||
Planar64(self.0.x)
|
||||
}
|
||||
#[inline]
|
||||
pub fn y(&self)->Planar64{
|
||||
pub const fn y(&self)->Planar64{
|
||||
Planar64(self.0.y)
|
||||
}
|
||||
#[inline]
|
||||
pub fn z(&self)->Planar64{
|
||||
pub const fn z(&self)->Planar64{
|
||||
Planar64(self.0.z)
|
||||
}
|
||||
#[inline]
|
||||
@ -642,7 +642,7 @@ impl Planar64Vec3{
|
||||
self.0.cmplt(rhs.0)
|
||||
}
|
||||
#[inline]
|
||||
pub fn dot(&self,rhs:Self)->Planar64{
|
||||
pub const fn dot(&self,rhs:Self)->Planar64{
|
||||
Planar64(((
|
||||
(self.0.x as i128)*(rhs.0.x as i128)+
|
||||
(self.0.y as i128)*(rhs.0.y as i128)+
|
||||
@ -650,13 +650,13 @@ impl Planar64Vec3{
|
||||
)>>32) as i64)
|
||||
}
|
||||
#[inline]
|
||||
pub fn dot128(&self,rhs:Self)->i128{
|
||||
pub const fn dot128(&self,rhs:Self)->i128{
|
||||
(self.0.x as i128)*(rhs.0.x as i128)+
|
||||
(self.0.y as i128)*(rhs.0.y as i128)+
|
||||
(self.0.z as i128)*(rhs.0.z as i128)
|
||||
}
|
||||
#[inline]
|
||||
pub fn cross(&self,rhs:Self)->Planar64Vec3{
|
||||
pub const fn cross(&self,rhs:Self)->Planar64Vec3{
|
||||
Planar64Vec3(glam::i64vec3(
|
||||
(((self.0.y as i128)*(rhs.0.z as i128)-(self.0.z as i128)*(rhs.0.y as i128))>>32) as i64,
|
||||
(((self.0.z as i128)*(rhs.0.x as i128)-(self.0.x as i128)*(rhs.0.z as i128))>>32) as i64,
|
||||
@ -664,12 +664,6 @@ impl Planar64Vec3{
|
||||
))
|
||||
}
|
||||
#[inline]
|
||||
pub fn walkable(&self,slope:Planar64,up:Self)->bool{
|
||||
let y=self.dot(up);
|
||||
let x=self.cross(up).length();
|
||||
x*slope<y
|
||||
}
|
||||
#[inline]
|
||||
pub fn length(&self)->Planar64{
|
||||
let radicand=(self.0.x as i128)*(self.0.x as i128)+(self.0.y as i128)*(self.0.y as i128)+(self.0.z as i128)*(self.0.z as i128);
|
||||
Planar64(unsafe{(radicand as f64).sqrt().to_int_unchecked()})
|
||||
@ -846,7 +840,7 @@ impl Default for Planar64Mat3{
|
||||
}
|
||||
impl Planar64Mat3{
|
||||
#[inline]
|
||||
pub fn from_cols(x_axis:Planar64Vec3,y_axis:Planar64Vec3,z_axis:Planar64Vec3)->Self{
|
||||
pub const fn from_cols(x_axis:Planar64Vec3,y_axis:Planar64Vec3,z_axis:Planar64Vec3)->Self{
|
||||
Self{
|
||||
x_axis,
|
||||
y_axis,
|
||||
|
Loading…
Reference in New Issue
Block a user