Compare commits
8 Commits
zero-verti
...
zero-verti
| Author | SHA1 | Date | |
|---|---|---|---|
|
cd1a3d8b15
|
|||
|
3371f3359b
|
|||
|
34d5288620
|
|||
|
82de08312d
|
|||
|
4b224b1827
|
|||
|
42862ce573
|
|||
|
3690954042
|
|||
|
bfe4b491d7
|
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -3873,7 +3873,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "strafesnet_common"
|
||||
version = "0.8.2"
|
||||
version = "0.8.5"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags 2.10.0",
|
||||
|
||||
@@ -50,7 +50,7 @@ fixed_wide = { version = "0.2.2", path = "lib/fixed_wide", registry = "strafesne
|
||||
linear_ops = { version = "0.1.1", path = "lib/linear_ops", registry = "strafesnet" }
|
||||
ratio_ops = { version = "0.1.0", path = "lib/ratio_ops", registry = "strafesnet" }
|
||||
strafesnet_bsp_loader = { path = "lib/bsp_loader", registry = "strafesnet" }
|
||||
strafesnet_common = { version = "0.8.2", path = "lib/common", registry = "strafesnet" }
|
||||
strafesnet_common = { version = "0.8.5", path = "lib/common", registry = "strafesnet" }
|
||||
strafesnet_deferred_loader = { version = "0.5.1", path = "lib/deferred_loader", registry = "strafesnet" }
|
||||
strafesnet_rbx_loader = { path = "lib/rbx_loader", registry = "strafesnet" }
|
||||
strafesnet_snf = { version = "0.3.2", path = "lib/snf", registry = "strafesnet" }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "strafesnet_common"
|
||||
version = "0.8.2"
|
||||
version = "0.8.5"
|
||||
edition = "2024"
|
||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
@@ -56,6 +56,14 @@ impl<T> Time<T>{
|
||||
pub const fn coerce<U>(self)->Time<U>{
|
||||
Time::raw(self.0)
|
||||
}
|
||||
#[inline]
|
||||
pub const fn div_euclid(self,other:Self)->Self{
|
||||
Time::raw(self.0.div_euclid(other.0))
|
||||
}
|
||||
#[inline]
|
||||
pub const fn rem_euclid(self,other:Self)->Self{
|
||||
Time::raw(self.0.rem_euclid(other.0))
|
||||
}
|
||||
}
|
||||
impl<T> From<Planar64> for Time<T>{
|
||||
#[inline]
|
||||
@@ -149,10 +157,23 @@ impl_time_i64_rhs_operator!(Shr,shr);
|
||||
impl_time_i64_rhs_operator!(Shl,shl);
|
||||
impl<T> core::ops::Mul<Time<T>> for Planar64{
|
||||
type Output=Ratio<Fixed<2,64>,Planar64>;
|
||||
#[inline]
|
||||
fn mul(self,rhs:Time<T>)->Self::Output{
|
||||
Ratio::new(self*Fixed::raw(rhs.0),Planar64::raw(1_000_000_000))
|
||||
}
|
||||
}
|
||||
impl<T> From<Time<T>> for f32{
|
||||
#[inline]
|
||||
fn from(value:Time<T>)->Self{
|
||||
value.get() as f32/Time::<T>::ONE_SECOND.get() as f32
|
||||
}
|
||||
}
|
||||
impl<T> From<Time<T>> for f64{
|
||||
#[inline]
|
||||
fn from(value:Time<T>)->Self{
|
||||
value.get() as f64/Time::<T>::ONE_SECOND.get() as f64
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod test_time{
|
||||
use super::*;
|
||||
|
||||
@@ -144,10 +144,38 @@ impl MeshBuilder{
|
||||
}
|
||||
pub fn build(
|
||||
self,
|
||||
polygon_groups:Vec<PolygonGroup>,
|
||||
graphics_groups:Vec<IndexedGraphicsGroup>,
|
||||
physics_groups:Vec<IndexedPhysicsGroup>,
|
||||
mut polygon_groups:Vec<PolygonGroup>,
|
||||
mut graphics_groups:Vec<IndexedGraphicsGroup>,
|
||||
mut physics_groups:Vec<IndexedPhysicsGroup>,
|
||||
)->Mesh{
|
||||
let mut id=0;
|
||||
let mut map=Vec::new();
|
||||
polygon_groups.retain(|group|{
|
||||
let keep=match group{
|
||||
PolygonGroup::PolygonList(polygon_list)=>!polygon_list.0.is_empty(),
|
||||
};
|
||||
if keep{
|
||||
map.push(Some(PolygonGroupId::new(id)));
|
||||
id+=1;
|
||||
}else{
|
||||
map.push(None);
|
||||
}
|
||||
!keep
|
||||
});
|
||||
for group in &mut graphics_groups{
|
||||
// drop empty groups
|
||||
group.groups.retain(|polygon_group_id|map[polygon_group_id.get() as usize].is_some());
|
||||
for polygon_group_id in &mut group.groups{
|
||||
*polygon_group_id=map[polygon_group_id.get() as usize].unwrap();
|
||||
}
|
||||
}
|
||||
for group in &mut physics_groups{
|
||||
// drop empty groups
|
||||
group.groups.retain(|polygon_group_id|map[polygon_group_id.get() as usize].is_some());
|
||||
for polygon_group_id in &mut group.groups{
|
||||
*polygon_group_id=map[polygon_group_id.get() as usize].unwrap();
|
||||
}
|
||||
}
|
||||
let MeshBuilder{
|
||||
unique_pos,
|
||||
unique_normal,
|
||||
|
||||
@@ -69,10 +69,8 @@ impl<In,Out> Scaled<In,Out>
|
||||
const fn get_scale(&self)->Ratio64{
|
||||
self.scale
|
||||
}
|
||||
fn set_scale(&mut self,time:Time<In>,new_scale:Ratio64){
|
||||
let new_time=self.get_time(time);
|
||||
const fn set_scale(&mut self,new_scale:Ratio64){
|
||||
self.scale=new_scale;
|
||||
self.set_time(time,new_time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +130,7 @@ pub struct TimerFixed<T:TimerState,P:PauseState>{
|
||||
_paused:P,
|
||||
}
|
||||
|
||||
//scaled timer methods are generic across PauseState
|
||||
//some scaled timer methods are generic across PauseState
|
||||
impl<P:PauseState,In,Out> TimerFixed<Scaled<In,Out>,P>
|
||||
where Time<In>:Copy,
|
||||
{
|
||||
@@ -147,8 +145,22 @@ impl<P:PauseState,In,Out> TimerFixed<Scaled<In,Out>,P>
|
||||
pub const fn get_scale(&self)->Ratio64{
|
||||
self.state.get_scale()
|
||||
}
|
||||
}
|
||||
// setting the scale of an unpaused timer is different than a paused timer
|
||||
impl<In,Out> TimerFixed<Scaled<In,Out>,Unpaused>
|
||||
where Time<In>:Copy,
|
||||
{
|
||||
pub fn set_scale(&mut self,time:Time<In>,new_scale:Ratio64){
|
||||
self.state.set_scale(time,new_scale)
|
||||
let new_time=self.state.get_time(time);
|
||||
self.state.set_scale(new_scale);
|
||||
self.state.set_time(time,new_time);
|
||||
}
|
||||
}
|
||||
impl<In,Out> TimerFixed<Scaled<In,Out>,Paused>
|
||||
where Time<In>:Copy,
|
||||
{
|
||||
pub fn set_scale(&mut self,new_scale:Ratio64){
|
||||
self.state.set_scale(new_scale);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -305,7 +317,7 @@ impl<In,Out> Timer<Scaled<In,Out>>
|
||||
}
|
||||
pub fn set_scale(&mut self,time:Time<In>,new_scale:Ratio64){
|
||||
match self{
|
||||
Self::Paused(timer)=>timer.set_scale(time,new_scale),
|
||||
Self::Paused(timer)=>timer.set_scale(new_scale),
|
||||
Self::Unpaused(timer)=>timer.set_scale(time,new_scale),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user