Compare commits
1 Commits
master
...
debug-bug7
Author | SHA1 | Date | |
---|---|---|---|
d0f7799448
|
Cargo.lock
engine/physics/src
integration-testing
lib
bsp_loader
common
deferred_loader
fixed_wide
rbx_loader
roblox_emulator
snf
map-tool
strafe-client/src
tools
962
Cargo.lock
generated
962
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -18,17 +18,6 @@ impl<T> std::ops::Neg for Body<T>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl<T:Copy> std::ops::Neg for &Body<T>{
|
|
||||||
type Output=Body<T>;
|
|
||||||
fn neg(self)->Self::Output{
|
|
||||||
Body{
|
|
||||||
position:self.position,
|
|
||||||
velocity:-self.velocity,
|
|
||||||
acceleration:self.acceleration,
|
|
||||||
time:-self.time,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Body<T>
|
impl<T> Body<T>
|
||||||
where Time<T>:Copy,
|
where Time<T>:Copy,
|
||||||
|
@ -4,6 +4,7 @@ use crate::physics::{Time,Body};
|
|||||||
|
|
||||||
use core::ops::Bound;
|
use core::ops::Bound;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
enum Transition<M:MeshQuery>{
|
enum Transition<M:MeshQuery>{
|
||||||
Miss,
|
Miss,
|
||||||
Next(FEV<M>,GigaTime),
|
Next(FEV<M>,GigaTime),
|
||||||
@ -76,6 +77,8 @@ impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
|||||||
M::Face:Copy,
|
M::Face:Copy,
|
||||||
M::Edge:Copy,
|
M::Edge:Copy,
|
||||||
M::Vert:Copy,
|
M::Vert:Copy,
|
||||||
|
M:std::fmt::Debug,
|
||||||
|
F:std::fmt::Display,
|
||||||
F:core::ops::Mul<Fixed<1,32>,Output=Fixed<4,128>>,
|
F:core::ops::Mul<Fixed<1,32>,Output=Fixed<4,128>>,
|
||||||
<F as core::ops::Mul<Fixed<1,32>>>::Output:core::iter::Sum,
|
<F as core::ops::Mul<Fixed<1,32>>>::Output:core::iter::Sum,
|
||||||
M::Offset:core::ops::Sub<<F as std::ops::Mul<Fixed<1,32>>>::Output>,
|
M::Offset:core::ops::Sub<<F as std::ops::Mul<Fixed<1,32>>>::Output>,
|
||||||
@ -90,10 +93,15 @@ impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
|||||||
//n=face.normal d=face.dot
|
//n=face.normal d=face.dot
|
||||||
//n.a t^2+n.v t+n.p-d==0
|
//n.a t^2+n.v t+n.p-d==0
|
||||||
let (n,d)=mesh.face_nd(face_id);
|
let (n,d)=mesh.face_nd(face_id);
|
||||||
|
println!("Face n={} d={}",n,d);
|
||||||
//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::<4,128>::zeroes2((n.dot(body.position)-d)*2,n.dot(body.velocity)*2,n.dot(body.acceleration)){
|
||||||
if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
let low=low(&lower_bound,&dt);
|
||||||
|
let upp=upp(&dt,&upper_bound);
|
||||||
|
let into=n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative();
|
||||||
|
println!("dt={} low={low} upp={upp} into={into}",dt.divide());
|
||||||
|
if low&&upp&&into{
|
||||||
upper_bound=Bound::Included(dt);
|
upper_bound=Bound::Included(dt);
|
||||||
best_transition=Transition::Hit(face_id,dt);
|
best_transition=Transition::Hit(face_id,dt);
|
||||||
break;
|
break;
|
||||||
@ -119,19 +127,24 @@ impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
|||||||
},
|
},
|
||||||
&FEV::Edge(edge_id)=>{
|
&FEV::Edge(edge_id)=>{
|
||||||
//test each face collision time, ignoring roots with zero or conflicting derivative
|
//test each face collision time, ignoring roots with zero or conflicting derivative
|
||||||
|
let edge_n=mesh.edge_n(edge_id);
|
||||||
let edge_verts=mesh.edge_verts(edge_id);
|
let edge_verts=mesh.edge_verts(edge_id);
|
||||||
let &[ev0,ev1]=edge_verts.as_ref();
|
let &[ev0,ev1]=edge_verts.as_ref();
|
||||||
let (v0,v1)=(mesh.vert(ev0),mesh.vert(ev1));
|
let delta_pos=body.position*2-(mesh.vert(ev0)+mesh.vert(ev1));
|
||||||
let edge_n=v1-v0;
|
|
||||||
let delta_pos=body.position*2-(v0+v1);
|
|
||||||
for (i,&edge_face_id) in mesh.edge_faces(edge_id).as_ref().iter().enumerate(){
|
for (i,&edge_face_id) in mesh.edge_faces(edge_id).as_ref().iter().enumerate(){
|
||||||
let face_n=mesh.face_nd(edge_face_id).0;
|
let face_n=mesh.face_nd(edge_face_id).0;
|
||||||
//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);
|
||||||
|
let d=n.dot(delta_pos).wrap_4();
|
||||||
|
println!("Edge Face={:?} boundary_n={} boundary_d={}",edge_face_id,n,d>>1);
|
||||||
//WARNING yada yada d *2
|
//WARNING yada yada d *2
|
||||||
//wrap for speed
|
//wrap for speed
|
||||||
for dt in Fixed::<4,128>::zeroes2(n.dot(delta_pos).wrap_4(),n.dot(body.velocity).wrap_4()*2,n.dot(body.acceleration).wrap_4()){
|
for dt in Fixed::<4,128>::zeroes2(d,n.dot(body.velocity).wrap_4()*2,n.dot(body.acceleration).wrap_4()){
|
||||||
if low(&lower_bound,&dt)&&upp(&dt,&upper_bound)&&n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative(){
|
let low=low(&lower_bound,&dt);
|
||||||
|
let upp=upp(&dt,&upper_bound);
|
||||||
|
let into=n.dot(body.extrapolated_velocity_ratio_dt(dt)).is_negative();
|
||||||
|
println!("dt={} low={low} upp={upp} into={into}",dt.divide());
|
||||||
|
if low&&upp&&into{
|
||||||
upper_bound=Bound::Included(dt);
|
upper_bound=Bound::Included(dt);
|
||||||
best_transition=Transition::Next(FEV::Face(edge_face_id),dt);
|
best_transition=Transition::Next(FEV::Face(edge_face_id),dt);
|
||||||
break;
|
break;
|
||||||
@ -175,8 +188,11 @@ impl<F:Copy,M:MeshQuery<Normal=Vector3<F>,Offset=Fixed<4,128>>> FEV<M>
|
|||||||
pub fn crawl(mut self,mesh:&M,relative_body:&Body,lower_bound:Bound<&Time>,upper_bound:Bound<&Time>)->CrawlResult<M>{
|
pub fn crawl(mut self,mesh:&M,relative_body:&Body,lower_bound:Bound<&Time>,upper_bound:Bound<&Time>)->CrawlResult<M>{
|
||||||
let mut lower_bound=lower_bound.map(|&t|into_giga_time(t,relative_body.time));
|
let mut lower_bound=lower_bound.map(|&t|into_giga_time(t,relative_body.time));
|
||||||
let upper_bound=upper_bound.map(|&t|into_giga_time(t,relative_body.time));
|
let upper_bound=upper_bound.map(|&t|into_giga_time(t,relative_body.time));
|
||||||
|
println!("crawl begin={self:?}");
|
||||||
for _ in 0..20{
|
for _ in 0..20{
|
||||||
match self.next_transition(mesh,relative_body,lower_bound,upper_bound){
|
let transition=self.next_transition(mesh,relative_body,lower_bound,upper_bound);
|
||||||
|
println!("transition={transition:?}");
|
||||||
|
match transition{
|
||||||
Transition::Miss=>return CrawlResult::Miss(self),
|
Transition::Miss=>return CrawlResult::Miss(self),
|
||||||
Transition::Next(next_fev,next_time)=>(self,lower_bound)=(next_fev,Bound::Included(next_time)),
|
Transition::Next(next_fev,next_time)=>(self,lower_bound)=(next_fev,Bound::Included(next_time)),
|
||||||
Transition::Hit(face,time)=>return CrawlResult::Hit(face,time),
|
Transition::Hit(face,time)=>return CrawlResult::Hit(face,time),
|
||||||
|
@ -76,9 +76,9 @@ struct Face{
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct Vert(Planar64Vec3);
|
struct Vert(Planar64Vec3);
|
||||||
pub trait MeshQuery{
|
pub trait MeshQuery{
|
||||||
type Face:Copy;
|
type Face:Copy+std::fmt::Debug;
|
||||||
type Edge:Copy+DirectedEdge;
|
type Edge:Copy+DirectedEdge+std::fmt::Debug;
|
||||||
type Vert:Copy;
|
type Vert:Copy+std::fmt::Debug;
|
||||||
// Vertex must be Planar64Vec3 because it represents an actual position
|
// Vertex must be Planar64Vec3 because it represents an actual position
|
||||||
type Normal;
|
type Normal;
|
||||||
type Offset;
|
type Offset;
|
||||||
@ -759,7 +759,9 @@ impl MinkowskiMesh<'_>{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn predict_collision_in(&self,relative_body:&Body,range:impl RangeBounds<Time>)->Option<(MinkowskiFace,GigaTime)>{
|
pub fn predict_collision_in(&self,relative_body:&Body,range:impl RangeBounds<Time>)->Option<(MinkowskiFace,GigaTime)>{
|
||||||
self.closest_fev_not_inside(*relative_body,range.start_bound()).and_then(|fev|{
|
println!("@@@BEGIN SETUP@@@");
|
||||||
|
self.closest_fev_not_inside(relative_body.clone(),range.start_bound()).and_then(|fev|{
|
||||||
|
println!("@@@BEGIN REAL CRAWL@@@");
|
||||||
//continue forwards along the body parabola
|
//continue forwards along the body parabola
|
||||||
fev.crawl(self,relative_body,range.start_bound(),range.end_bound()).hit()
|
fev.crawl(self,relative_body,range.start_bound(),range.end_bound()).hit()
|
||||||
})
|
})
|
||||||
@ -768,7 +770,7 @@ impl MinkowskiMesh<'_>{
|
|||||||
let (lower_bound,upper_bound)=(range.start_bound(),range.end_bound());
|
let (lower_bound,upper_bound)=(range.start_bound(),range.end_bound());
|
||||||
// swap and negate bounds to do a time inversion
|
// swap and negate bounds to do a time inversion
|
||||||
let (lower_bound,upper_bound)=(upper_bound.map(|&t|-t),lower_bound.map(|&t|-t));
|
let (lower_bound,upper_bound)=(upper_bound.map(|&t|-t),lower_bound.map(|&t|-t));
|
||||||
let infinity_body=-relative_body;
|
let infinity_body=-relative_body.clone();
|
||||||
self.closest_fev_not_inside(infinity_body,lower_bound.as_ref()).and_then(|fev|{
|
self.closest_fev_not_inside(infinity_body,lower_bound.as_ref()).and_then(|fev|{
|
||||||
//continue backwards along the body parabola
|
//continue backwards along the body parabola
|
||||||
fev.crawl(self,&infinity_body,lower_bound.as_ref(),upper_bound.as_ref()).hit()
|
fev.crawl(self,&infinity_body,lower_bound.as_ref(),upper_bound.as_ref()).hit()
|
||||||
|
@ -863,12 +863,6 @@ impl Default for PhysicsState{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PhysicsState{
|
impl PhysicsState{
|
||||||
pub fn new_with_body(body:Body)->Self{
|
|
||||||
Self{
|
|
||||||
body,
|
|
||||||
..Self::default()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub fn camera_body(&self)->Body{
|
pub fn camera_body(&self)->Body{
|
||||||
Body{
|
Body{
|
||||||
position:self.body.position+self.style.camera_offset,
|
position:self.body.position+self.style.camera_offset,
|
||||||
@ -1926,7 +1920,7 @@ mod test{
|
|||||||
assert_eq!(collision.map(|tup|relative_body.time+tup.1.into()),expected_collision_time,"Incorrect time of collision");
|
assert_eq!(collision.map(|tup|relative_body.time+tup.1.into()),expected_collision_time,"Incorrect time of collision");
|
||||||
}
|
}
|
||||||
fn test_collision(relative_body:Body,expected_collision_time:Option<Time>){
|
fn test_collision(relative_body:Body,expected_collision_time:Option<Time>){
|
||||||
test_collision_axis_aligned(relative_body,expected_collision_time);
|
test_collision_axis_aligned(relative_body.clone(),expected_collision_time);
|
||||||
test_collision_rotated(relative_body,expected_collision_time);
|
test_collision_rotated(relative_body,expected_collision_time);
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
|
1
integration-testing/.gitignore
vendored
1
integration-testing/.gitignore
vendored
@ -1 +0,0 @@
|
|||||||
/test_files
|
|
@ -1,28 +0,0 @@
|
|||||||
#[allow(unused)]
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum ReplayError{
|
|
||||||
IO(std::io::Error),
|
|
||||||
SNF(strafesnet_snf::Error),
|
|
||||||
SNFM(strafesnet_snf::map::Error),
|
|
||||||
SNFB(strafesnet_snf::bot::Error),
|
|
||||||
}
|
|
||||||
impl From<std::io::Error> for ReplayError{
|
|
||||||
fn from(value:std::io::Error)->Self{
|
|
||||||
Self::IO(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<strafesnet_snf::Error> for ReplayError{
|
|
||||||
fn from(value:strafesnet_snf::Error)->Self{
|
|
||||||
Self::SNF(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<strafesnet_snf::map::Error> for ReplayError{
|
|
||||||
fn from(value:strafesnet_snf::map::Error)->Self{
|
|
||||||
Self::SNFM(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl From<strafesnet_snf::bot::Error> for ReplayError{
|
|
||||||
fn from(value:strafesnet_snf::bot::Error)->Self{
|
|
||||||
Self::SNFB(value)
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +1,7 @@
|
|||||||
mod error;
|
use std::io::Cursor;
|
||||||
mod util;
|
use std::path::Path;
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod tests;
|
|
||||||
|
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use error::ReplayError;
|
|
||||||
use util::read_entire_file;
|
|
||||||
use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext};
|
use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext};
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
@ -19,6 +13,40 @@ fn main(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(unused)]
|
||||||
|
#[derive(Debug)]
|
||||||
|
enum ReplayError{
|
||||||
|
IO(std::io::Error),
|
||||||
|
SNF(strafesnet_snf::Error),
|
||||||
|
SNFM(strafesnet_snf::map::Error),
|
||||||
|
SNFB(strafesnet_snf::bot::Error),
|
||||||
|
}
|
||||||
|
impl From<std::io::Error> for ReplayError{
|
||||||
|
fn from(value:std::io::Error)->Self{
|
||||||
|
Self::IO(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<strafesnet_snf::Error> for ReplayError{
|
||||||
|
fn from(value:strafesnet_snf::Error)->Self{
|
||||||
|
Self::SNF(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<strafesnet_snf::map::Error> for ReplayError{
|
||||||
|
fn from(value:strafesnet_snf::map::Error)->Self{
|
||||||
|
Self::SNFM(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl From<strafesnet_snf::bot::Error> for ReplayError{
|
||||||
|
fn from(value:strafesnet_snf::bot::Error)->Self{
|
||||||
|
Self::SNFB(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{
|
||||||
|
let data=std::fs::read(path)?;
|
||||||
|
Ok(Cursor::new(data))
|
||||||
|
}
|
||||||
|
|
||||||
fn run_replay()->Result<(),ReplayError>{
|
fn run_replay()->Result<(),ReplayError>{
|
||||||
println!("loading map file..");
|
println!("loading map file..");
|
||||||
let data=read_entire_file("../tools/bhop_maps/5692113331.snfm")?;
|
let data=read_entire_file("../tools/bhop_maps/5692113331.snfm")?;
|
||||||
|
@ -1,78 +0,0 @@
|
|||||||
use crate::error::ReplayError;
|
|
||||||
use crate::util::read_entire_file;
|
|
||||||
use strafesnet_physics::physics::{PhysicsData,PhysicsState,PhysicsContext};
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[ignore]
|
|
||||||
fn physics_bug_2()->Result<(),ReplayError>{
|
|
||||||
println!("loading map file..");
|
|
||||||
let data=read_entire_file("test_files/bhop_monster_jam.snfm")?;
|
|
||||||
let map=strafesnet_snf::read_map(data)?.into_complete_map()?;
|
|
||||||
|
|
||||||
// create recording
|
|
||||||
let mut physics_data=PhysicsData::default();
|
|
||||||
println!("generating models..");
|
|
||||||
physics_data.generate_models(&map);
|
|
||||||
println!("simulating...");
|
|
||||||
|
|
||||||
//teleport to bug
|
|
||||||
// body pos = Vector { array: [Fixed { bits: 554895163352 }, Fixed { bits: 1485633089990 }, Fixed { bits: 1279601007173 }] }
|
|
||||||
// after the fix it's still happening, possibly for a different reason, new position to evince:
|
|
||||||
// body pos = Vector { array: [Fixed { bits: 555690659654 }, Fixed { bits: 1490485868773 }, Fixed { bits: 1277783839382 }] }
|
|
||||||
use strafesnet_common::integer::{vec3,Time};
|
|
||||||
let body=strafesnet_physics::physics::Body::new(
|
|
||||||
vec3::raw_xyz(555690659654,1490485868773,1277783839382),
|
|
||||||
vec3::int(0,0,0),
|
|
||||||
vec3::int(0,-100,0),
|
|
||||||
Time::ZERO,
|
|
||||||
);
|
|
||||||
let mut physics=PhysicsState::new_with_body(body);
|
|
||||||
// wait one second to activate the bug
|
|
||||||
// hit=Some(ModelId(2262))
|
|
||||||
PhysicsContext::run_input_instruction(&mut physics,&physics_data,strafesnet_common::instruction::TimedInstruction{
|
|
||||||
time:strafesnet_common::integer::Time::from_millis(500),
|
|
||||||
instruction:strafesnet_common::physics::Instruction::Idle,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
#[ignore]
|
|
||||||
fn physics_bug_3()->Result<(),ReplayError>{
|
|
||||||
println!("loading map file..");
|
|
||||||
let data=read_entire_file("../tools/bhop_maps/5692152916.snfm")?;
|
|
||||||
let map=strafesnet_snf::read_map(data)?.into_complete_map()?;
|
|
||||||
|
|
||||||
// create recording
|
|
||||||
let mut physics_data=PhysicsData::default();
|
|
||||||
println!("generating models..");
|
|
||||||
physics_data.generate_models(&map);
|
|
||||||
println!("simulating...");
|
|
||||||
|
|
||||||
//teleport to bug
|
|
||||||
use strafesnet_common::integer::{vec3,Time};
|
|
||||||
let body=strafesnet_physics::physics::Body::new(
|
|
||||||
// bhop_toc corner position after wall hits
|
|
||||||
// vec3::raw_xyz(-1401734815424,3315081280280,-2466057177493),
|
|
||||||
// vec3::raw_xyz(0,-96915585363,1265),
|
|
||||||
// vec3::raw_xyz(0,-429496729600,0),
|
|
||||||
// alternate room center position
|
|
||||||
// vec3::raw_xyz(-1129043783837,3324870327882,-2014012350212),
|
|
||||||
// vec3::raw_xyz(0,-96915585363,1265),
|
|
||||||
// vec3::raw_xyz(0,-429496729600,0),
|
|
||||||
// corner setup before wall hits
|
|
||||||
vec3::raw_xyz(-1392580080675,3325402529458,-2444727738679),
|
|
||||||
vec3::raw_xyz(-30259028820,-22950929553,-71141663007),
|
|
||||||
vec3::raw_xyz(0,-429496729600,0),
|
|
||||||
Time::ZERO,
|
|
||||||
);
|
|
||||||
let mut physics=PhysicsState::new_with_body(body);
|
|
||||||
// wait one second to activate the bug
|
|
||||||
PhysicsContext::run_input_instruction(&mut physics,&physics_data,strafesnet_common::instruction::TimedInstruction{
|
|
||||||
time:strafesnet_common::integer::Time::from_millis(500),
|
|
||||||
instruction:strafesnet_common::physics::Instruction::Idle,
|
|
||||||
});
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
@ -1,7 +0,0 @@
|
|||||||
use std::io::Cursor;
|
|
||||||
use std::path::Path;
|
|
||||||
|
|
||||||
pub fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{
|
|
||||||
let data=std::fs::read(path)?;
|
|
||||||
Ok(Cursor::new(data))
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_bsp_loader"
|
name = "strafesnet_bsp_loader"
|
||||||
version = "0.3.1"
|
version = "0.3.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -11,8 +11,8 @@ authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glam = "0.30.0"
|
glam = "0.30.0"
|
||||||
strafesnet_common = { version = "0.7.0", path = "../common", registry = "strafesnet" }
|
strafesnet_common = { version = "0.6.0", path = "../common", registry = "strafesnet" }
|
||||||
strafesnet_deferred_loader = { version = "0.5.1", path = "../deferred_loader", registry = "strafesnet" }
|
strafesnet_deferred_loader = { version = "0.5.0", path = "../deferred_loader", registry = "strafesnet" }
|
||||||
vbsp = "0.9.1"
|
vbsp = "0.9.1"
|
||||||
vbsp-entities-css = "0.6.0"
|
vbsp-entities-css = "0.6.0"
|
||||||
vmdl = "0.2.0"
|
vmdl = "0.2.0"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_common"
|
name = "strafesnet_common"
|
||||||
version = "0.7.0"
|
version = "0.6.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -140,15 +140,6 @@ impl ModeId{
|
|||||||
pub const MAIN:Self=Self(0);
|
pub const MAIN:Self=Self(0);
|
||||||
pub const BONUS:Self=Self(1);
|
pub const BONUS:Self=Self(1);
|
||||||
}
|
}
|
||||||
impl core::fmt::Display for ModeId{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->core::fmt::Result{
|
|
||||||
match self{
|
|
||||||
&Self::MAIN=>write!(f,"Main"),
|
|
||||||
&Self::BONUS=>write!(f,"Bonus"),
|
|
||||||
&Self(mode_id)=>write!(f,"Bonus{mode_id}"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Mode{
|
pub struct Mode{
|
||||||
style:gameplay_style::StyleModifiers,
|
style:gameplay_style::StyleModifiers,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_deferred_loader"
|
name = "strafesnet_deferred_loader"
|
||||||
version = "0.5.1"
|
version = "0.5.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -10,4 +10,4 @@ authors = ["Rhys Lloyd <krakow20@gmail.com>"]
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
strafesnet_common = { version = "0.7.0", path = "../common", registry = "strafesnet" }
|
strafesnet_common = { version = "0.6.0", path = "../common", registry = "strafesnet" }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "fixed_wide"
|
name = "fixed_wide"
|
||||||
version = "0.2.1"
|
version = "0.2.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -233,11 +233,6 @@ impl FixedFromFloatError{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl core::fmt::Display for FixedFromFloatError{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
macro_rules! impl_from_float {
|
macro_rules! impl_from_float {
|
||||||
( $decode:ident, $input: ty, $mantissa_bits:expr ) => {
|
( $decode:ident, $input: ty, $mantissa_bits:expr ) => {
|
||||||
impl<const N:usize,const F:usize> TryFrom<$input> for Fixed<N,F>{
|
impl<const N:usize,const F:usize> TryFrom<$input> for Fixed<N,F>{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_rbx_loader"
|
name = "strafesnet_rbx_loader"
|
||||||
version = "0.7.0"
|
version = "0.6.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
@ -15,11 +15,10 @@ glam = "0.30.0"
|
|||||||
lazy-regex = "3.1.0"
|
lazy-regex = "3.1.0"
|
||||||
rbx_binary = { version = "1.1.0-sn4", registry = "strafesnet" }
|
rbx_binary = { version = "1.1.0-sn4", registry = "strafesnet" }
|
||||||
rbx_dom_weak = { version = "3.1.0-sn4", registry = "strafesnet", features = ["instance-userdata"] }
|
rbx_dom_weak = { version = "3.1.0-sn4", registry = "strafesnet", features = ["instance-userdata"] }
|
||||||
rbx_mesh = "0.4.0"
|
rbx_mesh = "0.3.1"
|
||||||
rbx_reflection = "5.0.0"
|
|
||||||
rbx_reflection_database = "1.0.0"
|
rbx_reflection_database = "1.0.0"
|
||||||
rbx_xml = { version = "1.1.0-sn4", registry = "strafesnet" }
|
rbx_xml = { version = "1.1.0-sn4", registry = "strafesnet" }
|
||||||
rbxassetid = { version = "0.1.0", path = "../rbxassetid", registry = "strafesnet" }
|
rbxassetid = { version = "0.1.0", path = "../rbxassetid", registry = "strafesnet" }
|
||||||
roblox_emulator = { version = "0.5.1", path = "../roblox_emulator", default-features = false, registry = "strafesnet" }
|
roblox_emulator = { version = "0.5.0", path = "../roblox_emulator", default-features = false, registry = "strafesnet" }
|
||||||
strafesnet_common = { version = "0.7.0", path = "../common", registry = "strafesnet" }
|
strafesnet_common = { version = "0.6.0", path = "../common", registry = "strafesnet" }
|
||||||
strafesnet_deferred_loader = { version = "0.5.1", path = "../deferred_loader", registry = "strafesnet" }
|
strafesnet_deferred_loader = { version = "0.5.0", path = "../deferred_loader", registry = "strafesnet" }
|
||||||
|
@ -1,245 +0,0 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
use std::num::ParseIntError;
|
|
||||||
|
|
||||||
use strafesnet_common::gameplay_modes::{StageId,ModeId};
|
|
||||||
use strafesnet_common::integer::{FixedFromFloatError,Planar64TryFromFloatError};
|
|
||||||
|
|
||||||
/// A collection of errors which can be ignored at your peril
|
|
||||||
#[derive(Debug,Default)]
|
|
||||||
pub struct RecoverableErrors{
|
|
||||||
/// A basepart has an invalid / missing property.
|
|
||||||
pub basepart_property:Vec<InstancePath>,
|
|
||||||
/// A part has an unconvertable CFrame.
|
|
||||||
pub basepart_cframe:Vec<CFrameError>,
|
|
||||||
/// A part has an unconvertable Velocity.
|
|
||||||
pub basepart_velocity:Vec<Planar64ConvertError>,
|
|
||||||
/// A part has an invalid / missing property.
|
|
||||||
pub part_property:Vec<InstancePath>,
|
|
||||||
/// A part has an invalid shape.
|
|
||||||
pub part_shape:Vec<ShapeError>,
|
|
||||||
/// A meshpart has an invalid / missing property.
|
|
||||||
pub meshpart_property:Vec<InstancePath>,
|
|
||||||
/// A meshpart has no mesh.
|
|
||||||
pub meshpart_content:Vec<InstancePath>,
|
|
||||||
/// A basepart has an unsupported subclass.
|
|
||||||
pub unsupported_class:HashSet<String>,
|
|
||||||
/// A decal has an invalid / missing property.
|
|
||||||
pub decal_property:Vec<InstancePath>,
|
|
||||||
/// A decal has an invalid normal_id.
|
|
||||||
pub normal_id:Vec<NormalIdError>,
|
|
||||||
/// A texture has an invalid / missing property.
|
|
||||||
pub texture_property:Vec<InstancePath>,
|
|
||||||
/// A mode_id failed to parse.
|
|
||||||
pub mode_id_parse_int:Vec<ParseIntContext>,
|
|
||||||
/// There is a duplicate mode.
|
|
||||||
pub duplicate_mode:HashSet<ModeId>,
|
|
||||||
/// A mode_id failed to parse.
|
|
||||||
pub stage_id_parse_int:Vec<ParseIntContext>,
|
|
||||||
/// A Stage was duplicated leading to undefined behaviour.
|
|
||||||
pub duplicate_stage:HashSet<DuplicateStageError>,
|
|
||||||
/// A WormholeOut id failed to parse.
|
|
||||||
pub wormhole_out_id_parse_int:Vec<ParseIntContext>,
|
|
||||||
/// A WormholeOut was duplicated leading to undefined behaviour.
|
|
||||||
pub duplicate_wormhole_out:HashSet<u32>,
|
|
||||||
/// A WormholeIn id failed to parse.
|
|
||||||
pub wormhole_in_id_parse_int:Vec<ParseIntContext>,
|
|
||||||
/// A jump limit failed to parse.
|
|
||||||
pub jump_limit_parse_int:Vec<ParseIntContext>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RecoverableErrors{
|
|
||||||
pub fn count(&self)->usize{
|
|
||||||
self.basepart_property.len()+
|
|
||||||
self.basepart_cframe.len()+
|
|
||||||
self.basepart_velocity.len()+
|
|
||||||
self.part_property.len()+
|
|
||||||
self.part_shape.len()+
|
|
||||||
self.meshpart_property.len()+
|
|
||||||
self.meshpart_content.len()+
|
|
||||||
self.unsupported_class.len()+
|
|
||||||
self.decal_property.len()+
|
|
||||||
self.normal_id.len()+
|
|
||||||
self.texture_property.len()+
|
|
||||||
self.mode_id_parse_int.len()+
|
|
||||||
self.duplicate_mode.len()+
|
|
||||||
self.stage_id_parse_int.len()+
|
|
||||||
self.duplicate_stage.len()+
|
|
||||||
self.wormhole_out_id_parse_int.len()+
|
|
||||||
self.duplicate_wormhole_out.len()+
|
|
||||||
self.wormhole_in_id_parse_int.len()+
|
|
||||||
self.jump_limit_parse_int.len()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn write_comma_separated<T>(
|
|
||||||
f:&mut std::fmt::Formatter<'_>,
|
|
||||||
mut it:impl Iterator<Item=T>,
|
|
||||||
custom_write:impl Fn(&mut std::fmt::Formatter<'_>,T)->std::fmt::Result
|
|
||||||
)->std::fmt::Result{
|
|
||||||
if let Some(t)=it.next(){
|
|
||||||
custom_write(f,t)?;
|
|
||||||
for t in it{
|
|
||||||
write!(f,", ")?;
|
|
||||||
custom_write(f,t)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! write_instance_path_error{
|
|
||||||
($f:ident,$self:ident,$field:ident,$class:literal,$class_plural:literal,$problem:literal)=>{
|
|
||||||
let len=$self.$field.len();
|
|
||||||
if len!=0{
|
|
||||||
let plural=if len==1{$class}else{$class_plural};
|
|
||||||
write!($f,"The following {plural} {}: ",$problem)?;
|
|
||||||
write_comma_separated($f,$self.$field.iter(),|f,InstancePath(path)|
|
|
||||||
write!(f,"{path}")
|
|
||||||
)?;
|
|
||||||
writeln!($f)?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! write_duplicate_error{
|
|
||||||
($f:ident,$self:ident,$field:ident,$class:literal,$class_plural:literal)=>{
|
|
||||||
let len=$self.$field.len();
|
|
||||||
if len!=0{
|
|
||||||
let plural=if len==1{$class}else{$class_plural};
|
|
||||||
write!($f,"The following {plural} duplicates: ")?;
|
|
||||||
write_comma_separated($f,$self.$field.iter(),|f,id|
|
|
||||||
write!(f,"{id}")
|
|
||||||
)?;
|
|
||||||
writeln!($f)?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
macro_rules! write_bespoke_error{
|
|
||||||
($f:ident,$self:ident,$field:ident,$class:literal,$class_plural:literal,$problem:literal,$path_field:ident,$error_field:ident)=>{
|
|
||||||
let len=$self.$field.len();
|
|
||||||
if len!=0{
|
|
||||||
let plural=if len==1{$class}else{$class_plural};
|
|
||||||
write!($f,"The following {plural} {}: ",$problem)?;
|
|
||||||
write_comma_separated($f,$self.$field.iter(),|f,context|
|
|
||||||
write!(f,"{} ({})",context.$path_field,context.$error_field)
|
|
||||||
)?;
|
|
||||||
writeln!($f)?;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
impl core::fmt::Display for RecoverableErrors{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write_instance_path_error!(f,self,basepart_property,"BasePart is","BaseParts are","missing a property");
|
|
||||||
write_bespoke_error!(f,self,basepart_cframe,"BasePart","BaseParts","CFrame float convert failed",path,error);
|
|
||||||
write_bespoke_error!(f,self,basepart_velocity,"BasePart","BaseParts","Velocity float convert failed",path,error);
|
|
||||||
write_instance_path_error!(f,self,part_property,"Part is","Parts are","missing a property");
|
|
||||||
write_bespoke_error!(f,self,part_shape,"Part","Parts","Shape is invalid",path,shape);
|
|
||||||
write_instance_path_error!(f,self,meshpart_property,"MeshPart is","MeshParts are","missing a property");
|
|
||||||
write_instance_path_error!(f,self,meshpart_content,"MeshPart has","MeshParts have","no mesh");
|
|
||||||
{
|
|
||||||
let len=self.unsupported_class.len();
|
|
||||||
if len!=0{
|
|
||||||
let plural=if len==1{"Class is"}else{"Classes are"};
|
|
||||||
write!(f,"The following {plural} not supported: ")?;
|
|
||||||
write_comma_separated(f,self.unsupported_class.iter(),|f,classname|write!(f,"{classname}"))?;
|
|
||||||
writeln!(f)?;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
write_instance_path_error!(f,self,decal_property,"Decal is","Decals are","missing a property");
|
|
||||||
write_bespoke_error!(f,self,normal_id,"Decal","Decals","NormalId is invalid",path,normal_id);
|
|
||||||
write_instance_path_error!(f,self,texture_property,"Texture is","Textures are","missing a property");
|
|
||||||
write_bespoke_error!(f,self,mode_id_parse_int,"ModeId","ModeIds","failed to parse",context,error);
|
|
||||||
write_duplicate_error!(f,self,duplicate_mode,"ModeId has","ModeIds have");
|
|
||||||
write_bespoke_error!(f,self,stage_id_parse_int,"StageId","StageIds","failed to parse",context,error);
|
|
||||||
write_duplicate_error!(f,self,duplicate_stage,"StageId has","StageIds have");
|
|
||||||
write_bespoke_error!(f,self,wormhole_out_id_parse_int,"WormholeOutId","WormholeOutIds","failed to parse",context,error);
|
|
||||||
write_duplicate_error!(f,self,duplicate_wormhole_out,"WormholeOutId has","WormholeOutIds have");
|
|
||||||
write_bespoke_error!(f,self,wormhole_in_id_parse_int,"WormholeInId","WormholeInIds","failed to parse",context,error);
|
|
||||||
write_bespoke_error!(f,self,jump_limit_parse_int,"jump limit","jump limits","failed to parse",context,error);
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A Decal was missing required properties
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct InstancePath(pub String);
|
|
||||||
|
|
||||||
impl core::fmt::Display for InstancePath{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
self.0.fmt(f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl InstancePath{
|
|
||||||
pub fn new(dom:&rbx_dom_weak::WeakDom,instance:&rbx_dom_weak::Instance)->InstancePath{
|
|
||||||
let mut names:Vec<_>=core::iter::successors(
|
|
||||||
Some(instance),
|
|
||||||
|i|dom.get_by_ref(i.parent())
|
|
||||||
).map(
|
|
||||||
|i|i.name.as_str()
|
|
||||||
).collect();
|
|
||||||
// discard the name of the root object
|
|
||||||
names.pop();
|
|
||||||
names.reverse();
|
|
||||||
InstancePath(names.join("."))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ParseIntContext{
|
|
||||||
pub context:String,
|
|
||||||
pub error:ParseIntError,
|
|
||||||
}
|
|
||||||
impl ParseIntContext{
|
|
||||||
pub fn parse<T:core::str::FromStr<Err=ParseIntError>>(input:&str)->Result<T,Self>{
|
|
||||||
input.parse().map_err(|error|ParseIntContext{
|
|
||||||
context:input.to_owned(),
|
|
||||||
error,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct NormalIdError{
|
|
||||||
pub path:InstancePath,
|
|
||||||
pub normal_id:u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ShapeError{
|
|
||||||
pub path:InstancePath,
|
|
||||||
pub shape:u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub enum CFrameErrorType{
|
|
||||||
ZeroDeterminant,
|
|
||||||
Convert(FixedFromFloatError),
|
|
||||||
}
|
|
||||||
impl core::fmt::Display for CFrameErrorType{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{self:?}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct CFrameError{
|
|
||||||
pub path:InstancePath,
|
|
||||||
pub error:CFrameErrorType,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct Planar64ConvertError{
|
|
||||||
pub path:InstancePath,
|
|
||||||
pub error:Planar64TryFromFloatError,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug,Hash,Eq,PartialEq)]
|
|
||||||
pub struct DuplicateStageError{
|
|
||||||
pub mode_id:ModeId,
|
|
||||||
pub stage_id:StageId,
|
|
||||||
}
|
|
||||||
impl core::fmt::Display for DuplicateStageError{
|
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
|
||||||
write!(f,"{}-Spawn{}",self.mode_id,self.stage_id.get())
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +1,10 @@
|
|||||||
use std::io::Read;
|
use std::io::Read;
|
||||||
use rbx_dom_weak::WeakDom;
|
use rbx_dom_weak::WeakDom;
|
||||||
use roblox_emulator::context::Context;
|
use roblox_emulator::context::Context;
|
||||||
use strafesnet_common::map::CompleteMap;
|
|
||||||
use strafesnet_deferred_loader::deferred_loader::{LoadFailureMode,MeshDeferredLoader,RenderConfigDeferredLoader};
|
use strafesnet_deferred_loader::deferred_loader::{LoadFailureMode,MeshDeferredLoader,RenderConfigDeferredLoader};
|
||||||
|
|
||||||
pub use error::RecoverableErrors;
|
|
||||||
pub use roblox_emulator::runner::Error as RunnerError;
|
|
||||||
|
|
||||||
mod rbx;
|
mod rbx;
|
||||||
mod mesh;
|
mod mesh;
|
||||||
mod error;
|
|
||||||
mod union;
|
mod union;
|
||||||
pub mod loader;
|
pub mod loader;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
@ -33,7 +28,7 @@ impl Model{
|
|||||||
fn new(dom:WeakDom)->Self{
|
fn new(dom:WeakDom)->Self{
|
||||||
Self{dom}
|
Self{dom}
|
||||||
}
|
}
|
||||||
pub fn to_snf(&self,failure_mode:LoadFailureMode)->Result<(CompleteMap,RecoverableErrors),LoadError>{
|
pub fn to_snf(&self,failure_mode:LoadFailureMode)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
||||||
to_snf(self,failure_mode)
|
to_snf(self,failure_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -53,20 +48,18 @@ impl Place{
|
|||||||
context,
|
context,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
pub fn run_scripts(&mut self)->Result<Vec<RunnerError>,RunnerError>{
|
pub fn run_scripts(&mut self){
|
||||||
let Place{context}=self;
|
let Place{context}=self;
|
||||||
let runner=roblox_emulator::runner::Runner::new()?;
|
let runner=roblox_emulator::runner::Runner::new().unwrap();
|
||||||
let scripts=context.scripts();
|
let scripts=context.scripts();
|
||||||
let runnable=runner.runnable_context(context)?;
|
let runnable=runner.runnable_context(context).unwrap();
|
||||||
let mut errors=Vec::new();
|
|
||||||
for script in scripts{
|
for script in scripts{
|
||||||
if let Err(e)=runnable.run_script(script){
|
if let Err(e)=runnable.run_script(script){
|
||||||
errors.push(e);
|
println!("runner error: {e}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(errors)
|
|
||||||
}
|
}
|
||||||
pub fn to_snf(&self,failure_mode:LoadFailureMode)->Result<(CompleteMap,RecoverableErrors),LoadError>{
|
pub fn to_snf(&self,failure_mode:LoadFailureMode)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
||||||
to_snf(self,failure_mode)
|
to_snf(self,failure_mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,7 +123,7 @@ impl From<loader::MeshError> for LoadError{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_snf(dom:impl AsRef<WeakDom>,failure_mode:LoadFailureMode)->Result<(CompleteMap,RecoverableErrors),LoadError>{
|
fn to_snf(dom:impl AsRef<WeakDom>,failure_mode:LoadFailureMode)->Result<strafesnet_common::map::CompleteMap,LoadError>{
|
||||||
let dom=dom.as_ref();
|
let dom=dom.as_ref();
|
||||||
|
|
||||||
let mut texture_deferred_loader=RenderConfigDeferredLoader::new();
|
let mut texture_deferred_loader=RenderConfigDeferredLoader::new();
|
||||||
@ -150,5 +143,7 @@ fn to_snf(dom:impl AsRef<WeakDom>,failure_mode:LoadFailureMode)->Result<(Complet
|
|||||||
let mut texture_loader=loader::TextureLoader::new();
|
let mut texture_loader=loader::TextureLoader::new();
|
||||||
let render_configs=texture_deferred_loader.into_render_configs(&mut texture_loader,failure_mode).map_err(LoadError::Texture)?;
|
let render_configs=texture_deferred_loader.into_render_configs(&mut texture_loader,failure_mode).map_err(LoadError::Texture)?;
|
||||||
|
|
||||||
Ok(map_step2.add_render_configs_and_textures(render_configs))
|
let map=map_step2.add_render_configs_and_textures(render_configs);
|
||||||
|
|
||||||
|
Ok(map)
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<MeshWithS
|
|||||||
}) as u32)
|
}) as u32)
|
||||||
};
|
};
|
||||||
match rbx_mesh::read_versioned(roblox_mesh_bytes.cursor()).map_err(Error::RbxMesh)?{
|
match rbx_mesh::read_versioned(roblox_mesh_bytes.cursor()).map_err(Error::RbxMesh)?{
|
||||||
rbx_mesh::mesh::Mesh::V1(mesh)=>{
|
rbx_mesh::mesh::VersionedMesh::Version1(mesh)=>{
|
||||||
let color_id=acquire_color_id([1.0f32;4]);
|
let color_id=acquire_color_id([1.0f32;4]);
|
||||||
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(mesh.vertices.chunks_exact(3).map(|trip|{
|
polygon_groups.push(PolygonGroup::PolygonList(PolygonList::new(mesh.vertices.chunks_exact(3).map(|trip|{
|
||||||
let mut ingest_vertex1=|vertex:&rbx_mesh::mesh::Vertex1|Ok(acquire_vertex_id(IndexedVertex{
|
let mut ingest_vertex1=|vertex:&rbx_mesh::mesh::Vertex1|Ok(acquire_vertex_id(IndexedVertex{
|
||||||
@ -166,7 +166,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<MeshWithS
|
|||||||
Ok(vec![ingest_vertex1(&trip[0])?,ingest_vertex1(&trip[1])?,ingest_vertex1(&trip[2])?])
|
Ok(vec![ingest_vertex1(&trip[0])?,ingest_vertex1(&trip[1])?,ingest_vertex1(&trip[2])?])
|
||||||
}).collect::<Result<_,_>>()?)));
|
}).collect::<Result<_,_>>()?)));
|
||||||
},
|
},
|
||||||
rbx_mesh::mesh::Mesh::V2(mesh)=>{
|
rbx_mesh::mesh::VersionedMesh::Version2(mesh)=>{
|
||||||
let vertex_id_map=match mesh.header.sizeof_vertex{
|
let vertex_id_map=match mesh.header.sizeof_vertex{
|
||||||
rbx_mesh::mesh::SizeOfVertex2::Truncated=>{
|
rbx_mesh::mesh::SizeOfVertex2::Truncated=>{
|
||||||
//pick white and make all the vertices white
|
//pick white and make all the vertices white
|
||||||
@ -180,7 +180,7 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<MeshWithS
|
|||||||
vec![vertex_id_map[&face.0],vertex_id_map[&face.1],vertex_id_map[&face.2]]
|
vec![vertex_id_map[&face.0],vertex_id_map[&face.1],vertex_id_map[&face.2]]
|
||||||
).collect())));
|
).collect())));
|
||||||
},
|
},
|
||||||
rbx_mesh::mesh::Mesh::V3(mesh)=>{
|
rbx_mesh::mesh::VersionedMesh::Version3(mesh)=>{
|
||||||
let vertex_id_map=match mesh.header.sizeof_vertex{
|
let vertex_id_map=match mesh.header.sizeof_vertex{
|
||||||
rbx_mesh::mesh::SizeOfVertex2::Truncated=>{
|
rbx_mesh::mesh::SizeOfVertex2::Truncated=>{
|
||||||
let color_id=acquire_color_id([1.0f32;4]);
|
let color_id=acquire_color_id([1.0f32;4]);
|
||||||
@ -190,13 +190,13 @@ pub fn convert(roblox_mesh_bytes:crate::data::RobloxMeshBytes)->Result<MeshWithS
|
|||||||
}?;
|
}?;
|
||||||
ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods);
|
ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods);
|
||||||
},
|
},
|
||||||
rbx_mesh::mesh::Mesh::V4(mesh)=>{
|
rbx_mesh::mesh::VersionedMesh::Version4(mesh)=>{
|
||||||
let vertex_id_map=ingest_vertices2(
|
let vertex_id_map=ingest_vertices2(
|
||||||
mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id
|
mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id
|
||||||
)?;
|
)?;
|
||||||
ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods);
|
ingest_faces2_lods3(&mut polygon_groups,&vertex_id_map,&mesh.faces,&mesh.lods);
|
||||||
},
|
},
|
||||||
rbx_mesh::mesh::Mesh::V5(mesh)=>{
|
rbx_mesh::mesh::VersionedMesh::Version5(mesh)=>{
|
||||||
let vertex_id_map=ingest_vertices2(
|
let vertex_id_map=ingest_vertices2(
|
||||||
mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id
|
mesh.vertices,&mut acquire_pos_id,&mut acquire_tex_id,&mut acquire_normal_id,&mut acquire_color_id,&mut acquire_vertex_id
|
||||||
)?;
|
)?;
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::error::{RecoverableErrors,CFrameError,CFrameErrorType,DuplicateStageError,InstancePath,NormalIdError,Planar64ConvertError,ParseIntContext,ShapeError};
|
|
||||||
use crate::loader::{MeshWithSize,MeshIndex};
|
use crate::loader::{MeshWithSize,MeshIndex};
|
||||||
use crate::primitives::{self,CubeFace,CubeFaceDescription,WedgeFaceDescription,CornerWedgeFaceDescription,FaceDescription,Primitives};
|
use crate::primitives::{self,CubeFace,CubeFaceDescription,WedgeFaceDescription,CornerWedgeFaceDescription,FaceDescription,Primitives};
|
||||||
use strafesnet_common::map;
|
use strafesnet_common::map;
|
||||||
@ -7,7 +6,7 @@ use strafesnet_common::model;
|
|||||||
use strafesnet_common::gameplay_modes::{NormalizedModes,Mode,ModeId,ModeUpdate,ModesBuilder,Stage,StageElement,StageElementBehaviour,StageId,Zone};
|
use strafesnet_common::gameplay_modes::{NormalizedModes,Mode,ModeId,ModeUpdate,ModesBuilder,Stage,StageElement,StageElementBehaviour,StageId,Zone};
|
||||||
use strafesnet_common::gameplay_style;
|
use strafesnet_common::gameplay_style;
|
||||||
use strafesnet_common::gameplay_attributes as attr;
|
use strafesnet_common::gameplay_attributes as attr;
|
||||||
use strafesnet_common::integer::{self,vec3,Planar64TryFromFloatError,Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3};
|
use strafesnet_common::integer::{self,vec3,Planar64,Planar64Vec3,Planar64Mat3,Planar64Affine3};
|
||||||
use strafesnet_common::model::RenderConfigId;
|
use strafesnet_common::model::RenderConfigId;
|
||||||
use strafesnet_deferred_loader::deferred_loader::{RenderConfigDeferredLoader,MeshDeferredLoader};
|
use strafesnet_deferred_loader::deferred_loader::{RenderConfigDeferredLoader,MeshDeferredLoader};
|
||||||
use strafesnet_deferred_loader::mesh::Meshes;
|
use strafesnet_deferred_loader::mesh::Meshes;
|
||||||
@ -18,32 +17,40 @@ fn static_ustr(s:&'static str)->rbx_dom_weak::Ustr{
|
|||||||
rbx_dom_weak::ustr(s)
|
rbx_dom_weak::ustr(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Result<Planar64Affine3,Planar64TryFromFloatError>{
|
fn recursive_collect_superclass(
|
||||||
Ok(Planar64Affine3::new(
|
objects:&mut std::vec::Vec<rbx_dom_weak::types::Ref>,
|
||||||
|
dom:&rbx_dom_weak::WeakDom,
|
||||||
|
instance:&rbx_dom_weak::Instance,
|
||||||
|
superclass:&str
|
||||||
|
){
|
||||||
|
let instance=instance;
|
||||||
|
let db=rbx_reflection_database::get();
|
||||||
|
let Some(superclass)=db.classes.get(superclass)else{
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
objects.extend(
|
||||||
|
dom.descendants_of(instance.referent()).filter_map(|instance|{
|
||||||
|
let class=db.classes.get(instance.class.as_str())?;
|
||||||
|
db.has_superclass(class,superclass).then(||instance.referent())
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn planar64_affine3_from_roblox(cf:&rbx_dom_weak::types::CFrame,size:&rbx_dom_weak::types::Vector3)->Planar64Affine3{
|
||||||
|
Planar64Affine3::new(
|
||||||
Planar64Mat3::from_cols([
|
Planar64Mat3::from_cols([
|
||||||
(vec3::try_from_f32_array([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x])?
|
vec3::try_from_f32_array([cf.orientation.x.x,cf.orientation.y.x,cf.orientation.z.x]).unwrap()
|
||||||
*integer::try_from_f32(size.x/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)?
|
*integer::try_from_f32(size.x/2.0).unwrap(),
|
||||||
(vec3::try_from_f32_array([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y])?
|
vec3::try_from_f32_array([cf.orientation.x.y,cf.orientation.y.y,cf.orientation.z.y]).unwrap()
|
||||||
*integer::try_from_f32(size.y/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)?
|
*integer::try_from_f32(size.y/2.0).unwrap(),
|
||||||
(vec3::try_from_f32_array([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z])?
|
vec3::try_from_f32_array([cf.orientation.x.z,cf.orientation.y.z,cf.orientation.z.z]).unwrap()
|
||||||
*integer::try_from_f32(size.z/2.0)?).narrow_1().unwrap(),//.map_err(Planar64ConvertError::Narrow)?
|
*integer::try_from_f32(size.z/2.0).unwrap(),
|
||||||
]),
|
].map(|t|t.narrow_1().unwrap())),
|
||||||
vec3::try_from_f32_array([cf.position.x,cf.position.y,cf.position.z])?
|
vec3::try_from_f32_array([cf.position.x,cf.position.y,cf.position.z]).unwrap()
|
||||||
))
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
enum GetAttributesError{
|
fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap<model::ModelId,u32>,wormhole_id_to_out_model:&mut HashMap<u32,model::ModelId>)->attr::CollisionAttributes{
|
||||||
ModeIdParseInt(ParseIntContext),
|
|
||||||
DuplicateMode(ModeId),
|
|
||||||
StageIdParseInt(ParseIntContext),
|
|
||||||
DuplicateStage(DuplicateStageError),
|
|
||||||
WormholeOutIdParseInt(ParseIntContext),
|
|
||||||
DuplicateWormholeOut(u32),
|
|
||||||
WormholeInIdParseInt(ParseIntContext),
|
|
||||||
JumpLimitParseInt(ParseIntContext),
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:model::ModelId,modes_builder:&mut ModesBuilder,wormhole_in_model_to_id:&mut HashMap<model::ModelId,u32>,wormhole_id_to_out_model:&mut HashMap<u32,model::ModelId>)->Result<attr::CollisionAttributes,GetAttributesError>{
|
|
||||||
let mut general=attr::GeneralAttributes::default();
|
let mut general=attr::GeneralAttributes::default();
|
||||||
let mut intersecting=attr::IntersectingAttributes::default();
|
let mut intersecting=attr::IntersectingAttributes::default();
|
||||||
let mut contacting=attr::ContactingAttributes::default();
|
let mut contacting=attr::ContactingAttributes::default();
|
||||||
@ -77,14 +84,13 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
"MapStart"=>{
|
"MapStart"=>{
|
||||||
force_can_collide=false;
|
force_can_collide=false;
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
let mode_id=ModeId::MAIN;
|
|
||||||
modes_builder.insert_mode(
|
modes_builder.insert_mode(
|
||||||
mode_id,
|
ModeId::MAIN,
|
||||||
Mode::empty(
|
Mode::empty(
|
||||||
gameplay_style::StyleModifiers::roblox_bhop(),
|
gameplay_style::StyleModifiers::roblox_bhop(),
|
||||||
model_id
|
model_id
|
||||||
)
|
)
|
||||||
).map_err(|_|GetAttributesError::DuplicateMode(mode_id))?;
|
).unwrap();
|
||||||
},
|
},
|
||||||
"MapFinish"=>{
|
"MapFinish"=>{
|
||||||
force_can_collide=false;
|
force_can_collide=false;
|
||||||
@ -124,30 +130,26 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
"BonusStart"=>{
|
"BonusStart"=>{
|
||||||
force_can_collide=false;
|
force_can_collide=false;
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
let mode_id=ModeId::new(ParseIntContext::parse(&captures[2]).map_err(GetAttributesError::ModeIdParseInt)?);
|
|
||||||
modes_builder.insert_mode(
|
modes_builder.insert_mode(
|
||||||
mode_id,
|
ModeId::new(captures[2].parse::<u32>().unwrap()),
|
||||||
Mode::empty(
|
Mode::empty(
|
||||||
gameplay_style::StyleModifiers::roblox_bhop(),
|
gameplay_style::StyleModifiers::roblox_bhop(),
|
||||||
model_id
|
model_id
|
||||||
)
|
)
|
||||||
).map_err(|_|GetAttributesError::DuplicateMode(mode_id))?;
|
).unwrap();
|
||||||
},
|
},
|
||||||
"WormholeOut"=>{
|
"WormholeOut"=>{
|
||||||
//the PhysicsModelId has to exist for it to be teleported to!
|
//the PhysicsModelId has to exist for it to be teleported to!
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
//this object is not special in strafe client, but the roblox mapping needs to be converted to model id
|
//this object is not special in strafe client, but the roblox mapping needs to be converted to model id
|
||||||
let wormhole_id=ParseIntContext::parse(&captures[2]).map_err(GetAttributesError::WormholeOutIdParseInt)?;
|
assert!(wormhole_id_to_out_model.insert(captures[2].parse::<u32>().unwrap(),model_id).is_none(),"Cannot have multiple WormholeOut with same id");
|
||||||
if wormhole_id_to_out_model.insert(wormhole_id,model_id).is_some(){
|
|
||||||
return Err(GetAttributesError::DuplicateWormholeOut(wormhole_id));
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
_=>(),
|
_=>(),
|
||||||
}
|
}
|
||||||
}else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$")
|
}else if let Some(captures)=lazy_regex::regex!(r"^(Force)?(Spawn|SpawnAt|Trigger|Teleport|Platform)(\d+)$")
|
||||||
.captures(other){
|
.captures(other){
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
let stage_id=StageId::new(ParseIntContext::parse(&captures[3]).map_err(GetAttributesError::StageIdParseInt)?);
|
let stage_id=StageId::new(captures[3].parse::<u32>().unwrap());
|
||||||
let stage_element=StageElement::new(
|
let stage_element=StageElement::new(
|
||||||
//stage_id:
|
//stage_id:
|
||||||
stage_id,
|
stage_id,
|
||||||
@ -159,12 +161,11 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
//behaviour:
|
//behaviour:
|
||||||
match &captures[2]{
|
match &captures[2]{
|
||||||
"Spawn"=>{
|
"Spawn"=>{
|
||||||
let mode_id=ModeId::MAIN;
|
|
||||||
modes_builder.insert_stage(
|
modes_builder.insert_stage(
|
||||||
mode_id,
|
ModeId::MAIN,
|
||||||
stage_id,
|
stage_id,
|
||||||
Stage::empty(model_id),
|
Stage::empty(model_id),
|
||||||
).map_err(|_|GetAttributesError::DuplicateStage(DuplicateStageError{mode_id,stage_id}))?;
|
).unwrap();
|
||||||
//TODO: let denormalize handle this
|
//TODO: let denormalize handle this
|
||||||
StageElementBehaviour::SpawnAt
|
StageElementBehaviour::SpawnAt
|
||||||
},
|
},
|
||||||
@ -174,7 +175,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
"Trigger"=>{force_can_collide=false;StageElementBehaviour::Trigger},
|
"Trigger"=>{force_can_collide=false;StageElementBehaviour::Trigger},
|
||||||
"Teleport"=>{force_can_collide=false;StageElementBehaviour::Teleport},
|
"Teleport"=>{force_can_collide=false;StageElementBehaviour::Teleport},
|
||||||
"Platform"=>StageElementBehaviour::Platform,
|
"Platform"=>StageElementBehaviour::Platform,
|
||||||
_=>unreachable!("regex1[2] messed up bad"),
|
_=>panic!("regex1[2] messed up bad"),
|
||||||
},
|
},
|
||||||
None
|
None
|
||||||
);
|
);
|
||||||
@ -197,33 +198,30 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
StageId::FIRST,
|
StageId::FIRST,
|
||||||
false,
|
false,
|
||||||
StageElementBehaviour::Check,
|
StageElementBehaviour::Check,
|
||||||
Some(ParseIntContext::parse(&captures[2]).map_err(GetAttributesError::JumpLimitParseInt)?)
|
Some(captures[2].parse::<u8>().unwrap())
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
"WormholeIn"=>{
|
"WormholeIn"=>{
|
||||||
force_can_collide=false;
|
force_can_collide=false;
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
let wormhole_id=ParseIntContext::parse(&captures[2]).map_err(GetAttributesError::WormholeInIdParseInt)?;
|
assert!(wormhole_in_model_to_id.insert(model_id,captures[2].parse::<u32>().unwrap()).is_none(),"Impossible");
|
||||||
// It is impossible for two different objects to have the same model id
|
|
||||||
assert!(wormhole_in_model_to_id.insert(model_id,wormhole_id).is_none(),"Impossible");
|
|
||||||
},
|
},
|
||||||
_=>unreachable!("regex2[1] messed up bad"),
|
_=>panic!("regex2[1] messed up bad"),
|
||||||
}
|
}
|
||||||
}else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$")
|
}else if let Some(captures)=lazy_regex::regex!(r"^Bonus(Finish|Anticheat)(\d+)$")
|
||||||
.captures(other){
|
.captures(other){
|
||||||
force_can_collide=false;
|
force_can_collide=false;
|
||||||
force_intersecting=true;
|
force_intersecting=true;
|
||||||
let mode_id=ModeId::new(ParseIntContext::parse(&captures[2]).map_err(GetAttributesError::ModeIdParseInt)?);
|
|
||||||
modes_builder.push_mode_update(
|
modes_builder.push_mode_update(
|
||||||
mode_id,
|
ModeId::new(captures[2].parse::<u32>().unwrap()),
|
||||||
ModeUpdate::zone(
|
ModeUpdate::zone(
|
||||||
model_id,
|
model_id,
|
||||||
//zone:
|
//zone:
|
||||||
match &captures[1]{
|
match &captures[1]{
|
||||||
"Finish"=>Zone::Finish,
|
"Finish"=>Zone::Finish,
|
||||||
"Anticheat"=>Zone::Anticheat,
|
"Anticheat"=>Zone::Anticheat,
|
||||||
_=>unreachable!("regex3[1] messed up bad"),
|
_=>panic!("regex3[1] messed up bad"),
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -245,7 +243,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
if allow_booster&&velocity!=vec3::ZERO{
|
if allow_booster&&velocity!=vec3::ZERO{
|
||||||
general.booster=Some(attr::Booster::Velocity(velocity));
|
general.booster=Some(attr::Booster::Velocity(velocity));
|
||||||
}
|
}
|
||||||
Ok(match force_can_collide{
|
match force_can_collide{
|
||||||
true=>{
|
true=>{
|
||||||
match name{
|
match name{
|
||||||
"Bounce"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Elastic(u32::MAX)),
|
"Bounce"=>contacting.contact_behaviour=Some(attr::ContactingBehaviour::Elastic(u32::MAX)),
|
||||||
@ -263,7 +261,7 @@ fn get_attributes(name:&str,can_collide:bool,velocity:Planar64Vec3,model_id:mode
|
|||||||
}else{
|
}else{
|
||||||
attr::CollisionAttributes::Decoration
|
attr::CollisionAttributes::Decoration
|
||||||
},
|
},
|
||||||
})
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone,Copy)]
|
#[derive(Clone,Copy)]
|
||||||
@ -409,25 +407,21 @@ fn get_content_url(content:&rbx_dom_weak::types::Content)->Option<&str>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_texture_description<'a>(
|
fn get_texture_description<'a>(
|
||||||
|
temp_objects:&mut Vec<rbx_dom_weak::types::Ref>,
|
||||||
render_config_deferred_loader:&mut RenderConfigDeferredLoader<&'a str>,
|
render_config_deferred_loader:&mut RenderConfigDeferredLoader<&'a str>,
|
||||||
recoverable_errors:&mut RecoverableErrors,
|
|
||||||
db:&rbx_reflection::ReflectionDatabase,
|
|
||||||
dom:&'a rbx_dom_weak::WeakDom,
|
dom:&'a rbx_dom_weak::WeakDom,
|
||||||
object:&rbx_dom_weak::Instance,
|
object:&rbx_dom_weak::Instance,
|
||||||
size:&rbx_dom_weak::types::Vector3,
|
size:&rbx_dom_weak::types::Vector3,
|
||||||
)->RobloxPartDescription{
|
)->RobloxPartDescription{
|
||||||
//use the biggest one and cut it down later...
|
//use the biggest one and cut it down later...
|
||||||
let mut part_texture_description=RobloxPartDescription::default();
|
let mut part_texture_description=RobloxPartDescription::default();
|
||||||
let decal=&db.classes["Decal"];
|
temp_objects.clear();
|
||||||
let decals=object.children().iter().filter_map(|&referent|{
|
recursive_collect_superclass(temp_objects,&dom,object,"Decal");
|
||||||
let instance=dom.get_by_ref(referent)?;
|
for &mut decal_ref in temp_objects{
|
||||||
db.classes.get(instance.class.as_str()).is_some_and(|class|
|
let Some(decal)=dom.get_by_ref(decal_ref) else{
|
||||||
db.has_superclass(class,decal)
|
println!("Decal get_by_ref failed");
|
||||||
).then_some(instance)
|
continue;
|
||||||
});
|
};
|
||||||
for decal in decals{
|
|
||||||
// decals should always have these properties,
|
|
||||||
// but it is not guaranteed by the rbx_dom_weak data structure.
|
|
||||||
let (
|
let (
|
||||||
Some(rbx_dom_weak::types::Variant::Content(content)),
|
Some(rbx_dom_weak::types::Variant::Content(content)),
|
||||||
Some(rbx_dom_weak::types::Variant::Enum(normalid)),
|
Some(rbx_dom_weak::types::Variant::Enum(normalid)),
|
||||||
@ -439,16 +433,16 @@ fn get_texture_description<'a>(
|
|||||||
decal.properties.get(&static_ustr("Color3")),
|
decal.properties.get(&static_ustr("Color3")),
|
||||||
decal.properties.get(&static_ustr("Transparency")),
|
decal.properties.get(&static_ustr("Transparency")),
|
||||||
)else{
|
)else{
|
||||||
recoverable_errors.decal_property.push(InstancePath::new(dom,decal));
|
println!("Decal is missing a required property");
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let texture_id=get_content_url(content);
|
let texture_id=match content.value(){
|
||||||
|
rbx_dom_weak::types::ContentType::Uri(uri)=>Some(uri.as_str()),
|
||||||
|
_=>None,
|
||||||
|
};
|
||||||
let render_id=render_config_deferred_loader.acquire_render_config_id(texture_id);
|
let render_id=render_config_deferred_loader.acquire_render_config_id(texture_id);
|
||||||
let Ok(cube_face)=normalid.to_u32().try_into()else{
|
let Ok(cube_face)=normalid.to_u32().try_into()else{
|
||||||
recoverable_errors.normal_id.push(NormalIdError{
|
println!("NormalId is invalid");
|
||||||
path:InstancePath::new(dom,decal),
|
|
||||||
normal_id:normalid.to_u32(),
|
|
||||||
});
|
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let (roblox_texture_color,roblox_texture_transform)=if decal.class=="Texture"{
|
let (roblox_texture_color,roblox_texture_transform)=if decal.class=="Texture"{
|
||||||
@ -485,7 +479,6 @@ fn get_texture_description<'a>(
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}else{
|
}else{
|
||||||
recoverable_errors.texture_property.push(InstancePath::new(dom,decal));
|
|
||||||
(glam::Vec4::ONE,RobloxTextureTransform::identity())
|
(glam::Vec4::ONE,RobloxTextureTransform::identity())
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@ -539,8 +532,6 @@ pub fn convert<'a>(
|
|||||||
render_config_deferred_loader:&mut RenderConfigDeferredLoader<&'a str>,
|
render_config_deferred_loader:&mut RenderConfigDeferredLoader<&'a str>,
|
||||||
mesh_deferred_loader:&mut MeshDeferredLoader<MeshIndex<'a>>,
|
mesh_deferred_loader:&mut MeshDeferredLoader<MeshIndex<'a>>,
|
||||||
)->PartialMap1<'a>{
|
)->PartialMap1<'a>{
|
||||||
let mut recoverable_errors=RecoverableErrors::default();
|
|
||||||
|
|
||||||
let mut deferred_models_deferred_attributes=Vec::new();
|
let mut deferred_models_deferred_attributes=Vec::new();
|
||||||
let mut deferred_unions_deferred_attributes=Vec::new();
|
let mut deferred_unions_deferred_attributes=Vec::new();
|
||||||
let mut primitive_models_deferred_attributes=Vec::new();
|
let mut primitive_models_deferred_attributes=Vec::new();
|
||||||
@ -550,83 +541,63 @@ pub fn convert<'a>(
|
|||||||
//just going to leave it like this for now instead of reworking the data structures for this whole thing
|
//just going to leave it like this for now instead of reworking the data structures for this whole thing
|
||||||
let textureless_render_group=render_config_deferred_loader.acquire_render_config_id(None);
|
let textureless_render_group=render_config_deferred_loader.acquire_render_config_id(None);
|
||||||
|
|
||||||
let db=rbx_reflection_database::get();
|
let mut object_refs=Vec::new();
|
||||||
let basepart=&db.classes["BasePart"];
|
let mut temp_objects=Vec::new();
|
||||||
let baseparts=dom.descendants().filter(|&instance|
|
recursive_collect_superclass(&mut object_refs, &dom, dom.root(),"BasePart");
|
||||||
db.classes.get(instance.class.as_str()).is_some_and(|class|
|
for object_ref in object_refs {
|
||||||
db.has_superclass(class,basepart)
|
if let Some(object)=dom.get_by_ref(object_ref){
|
||||||
)
|
if let (
|
||||||
);
|
Some(rbx_dom_weak::types::Variant::CFrame(cf)),
|
||||||
for object in baseparts{
|
Some(rbx_dom_weak::types::Variant::Vector3(size)),
|
||||||
let (
|
Some(rbx_dom_weak::types::Variant::Vector3(velocity)),
|
||||||
Some(rbx_dom_weak::types::Variant::CFrame(cf)),
|
Some(rbx_dom_weak::types::Variant::Float32(transparency)),
|
||||||
Some(rbx_dom_weak::types::Variant::Vector3(size)),
|
Some(rbx_dom_weak::types::Variant::Color3uint8(color3)),
|
||||||
Some(rbx_dom_weak::types::Variant::Vector3(velocity)),
|
Some(rbx_dom_weak::types::Variant::Bool(can_collide)),
|
||||||
Some(rbx_dom_weak::types::Variant::Float32(transparency)),
|
) = (
|
||||||
Some(rbx_dom_weak::types::Variant::Color3uint8(color3)),
|
object.properties.get(&static_ustr("CFrame")),
|
||||||
Some(&rbx_dom_weak::types::Variant::Bool(can_collide)),
|
object.properties.get(&static_ustr("Size")),
|
||||||
) = (
|
object.properties.get(&static_ustr("Velocity")),
|
||||||
object.properties.get(&static_ustr("CFrame")),
|
object.properties.get(&static_ustr("Transparency")),
|
||||||
object.properties.get(&static_ustr("Size")),
|
object.properties.get(&static_ustr("Color")),
|
||||||
object.properties.get(&static_ustr("Velocity")),
|
object.properties.get(&static_ustr("CanCollide")),
|
||||||
object.properties.get(&static_ustr("Transparency")),
|
)
|
||||||
object.properties.get(&static_ustr("Color")),
|
{
|
||||||
object.properties.get(&static_ustr("CanCollide")),
|
let model_transform=planar64_affine3_from_roblox(cf,size);
|
||||||
)else{
|
|
||||||
recoverable_errors.basepart_property.push(InstancePath::new(dom,object));
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
let model_transform=match planar64_affine3_from_roblox(cf,size){
|
|
||||||
Ok(model_transform)=>{
|
|
||||||
if model_transform.matrix3.det().is_zero(){
|
if model_transform.matrix3.det().is_zero(){
|
||||||
recoverable_errors.basepart_cframe.push(CFrameError{
|
let mut parent_ref=object.parent();
|
||||||
path:InstancePath::new(dom,object),
|
let mut full_path=object.name.clone();
|
||||||
error:CFrameErrorType::ZeroDeterminant,
|
while let Some(parent)=dom.get_by_ref(parent_ref){
|
||||||
});
|
full_path=format!("{}.{}",parent.name,full_path);
|
||||||
|
parent_ref=parent.parent();
|
||||||
|
}
|
||||||
|
println!("Zero determinant CFrame at location {}",full_path);
|
||||||
|
println!("matrix3:{}",model_transform.matrix3);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
model_transform
|
|
||||||
},
|
|
||||||
Err(e)=>{
|
|
||||||
recoverable_errors.basepart_cframe.push(CFrameError{
|
|
||||||
path:InstancePath::new(dom,object),
|
|
||||||
error:CFrameErrorType::Convert(e),
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//TODO: also detect "CylinderMesh" etc here
|
//TODO: also detect "CylinderMesh" etc here
|
||||||
let shape=match object.class.as_str(){
|
let shape=match object.class.as_str(){
|
||||||
"Part"|"Seat"|"SpawnLocation"=>{
|
"Part"=>if let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get(&static_ustr("Shape")){
|
||||||
let Some(rbx_dom_weak::types::Variant::Enum(shape))=object.properties.get(&static_ustr("Shape"))else{
|
Shape::Primitive(shape.to_u32().try_into().expect("Funky roblox PartType"))
|
||||||
recoverable_errors.part_property.push(InstancePath::new(dom,object));
|
}else{
|
||||||
continue;
|
panic!("Part has no Shape!");
|
||||||
|
},
|
||||||
|
"TrussPart"=>Shape::Primitive(Primitives::Cube),
|
||||||
|
"WedgePart"=>Shape::Primitive(Primitives::Wedge),
|
||||||
|
"CornerWedgePart"=>Shape::Primitive(Primitives::CornerWedge),
|
||||||
|
"MeshPart"=>Shape::MeshPart,
|
||||||
|
"UnionOperation"=>Shape::PhysicsData,
|
||||||
|
_=>{
|
||||||
|
println!("Unsupported BasePart ClassName={}; defaulting to cube",object.class);
|
||||||
|
Shape::Primitive(Primitives::Cube)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
let Ok(shape)=shape.to_u32().try_into()else{
|
|
||||||
recoverable_errors.part_shape.push(ShapeError{
|
|
||||||
path:InstancePath::new(dom,object),
|
|
||||||
shape:shape.to_u32(),
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
};
|
|
||||||
Shape::Primitive(shape)
|
|
||||||
},
|
|
||||||
"TrussPart"|"VehicleSeat"=>Shape::Primitive(Primitives::Cube),
|
|
||||||
"WedgePart"=>Shape::Primitive(Primitives::Wedge),
|
|
||||||
"CornerWedgePart"=>Shape::Primitive(Primitives::CornerWedge),
|
|
||||||
"MeshPart"=>Shape::MeshPart,
|
|
||||||
"UnionOperation"=>Shape::PhysicsData,
|
|
||||||
"Terrain"=>continue,
|
|
||||||
_=>{
|
|
||||||
recoverable_errors.unsupported_class.insert(object.class.as_str().to_owned());
|
|
||||||
Shape::Primitive(Primitives::Cube)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let (availability,mesh_id)=match shape{
|
let (availability,mesh_id)=match shape{
|
||||||
Shape::Primitive(primitive_shape)=>{
|
Shape::Primitive(primitive_shape)=>{
|
||||||
let part_texture_description=get_texture_description(render_config_deferred_loader,&mut recoverable_errors,db,dom,object,size);
|
//TODO: TAB TAB
|
||||||
|
let part_texture_description=get_texture_description(&mut temp_objects,render_config_deferred_loader,dom,object,size);
|
||||||
//obscure rust syntax "slice pattern"
|
//obscure rust syntax "slice pattern"
|
||||||
let RobloxPartDescription([
|
let RobloxPartDescription([
|
||||||
f0,//Cube::Right
|
f0,//Cube::Right
|
||||||
@ -675,83 +646,66 @@ pub fn convert<'a>(
|
|||||||
mesh_id
|
mesh_id
|
||||||
};
|
};
|
||||||
(MeshAvailability::Immediate,mesh_id)
|
(MeshAvailability::Immediate,mesh_id)
|
||||||
},
|
},
|
||||||
Shape::MeshPart=>{
|
Shape::MeshPart=>if let (
|
||||||
let (
|
Some(rbx_dom_weak::types::Variant::Content(mesh_content)),
|
||||||
Some(rbx_dom_weak::types::Variant::Content(mesh_content)),
|
Some(rbx_dom_weak::types::Variant::Content(texture_content)),
|
||||||
Some(rbx_dom_weak::types::Variant::Content(texture_content)),
|
)=(
|
||||||
)=(
|
// mesh must exist
|
||||||
// mesh must exist
|
object.properties.get(&static_ustr("MeshContent")),
|
||||||
object.properties.get(&static_ustr("MeshContent")),
|
// texture is allowed to be none
|
||||||
// texture is allowed to be none
|
object.properties.get(&static_ustr("TextureContent")),
|
||||||
object.properties.get(&static_ustr("TextureContent")),
|
){
|
||||||
)else{
|
let mesh_asset_id=get_content_url(mesh_content).unwrap_or_default();
|
||||||
recoverable_errors.meshpart_property.push(InstancePath::new(dom,object));
|
let texture_asset_id=get_content_url(texture_content);
|
||||||
continue;
|
(
|
||||||
|
MeshAvailability::DeferredMesh(render_config_deferred_loader.acquire_render_config_id(texture_asset_id)),
|
||||||
|
mesh_deferred_loader.acquire_mesh_id(MeshIndex::file_mesh(mesh_asset_id)),
|
||||||
|
)
|
||||||
|
}else{
|
||||||
|
panic!("Mesh has no Mesh or Texture");
|
||||||
|
},
|
||||||
|
Shape::PhysicsData=>{
|
||||||
|
let mut content="";
|
||||||
|
let mut mesh_data:&[u8]=&[];
|
||||||
|
let mut physics_data:&[u8]=&[];
|
||||||
|
if let Some(rbx_dom_weak::types::Variant::ContentId(asset_id))=object.properties.get(&static_ustr("AssetId")){
|
||||||
|
content=asset_id.as_ref();
|
||||||
|
}
|
||||||
|
if let Some(rbx_dom_weak::types::Variant::BinaryString(data))=object.properties.get(&static_ustr("MeshData")){
|
||||||
|
mesh_data=data.as_ref();
|
||||||
|
}
|
||||||
|
if let Some(rbx_dom_weak::types::Variant::BinaryString(data))=object.properties.get(&static_ustr("PhysicsData")){
|
||||||
|
physics_data=data.as_ref();
|
||||||
|
}
|
||||||
|
let part_texture_description=get_texture_description(&mut temp_objects,render_config_deferred_loader,dom,object,size);
|
||||||
|
let mesh_index=MeshIndex::union(content,mesh_data,physics_data,size,part_texture_description.clone());
|
||||||
|
let mesh_id=mesh_deferred_loader.acquire_mesh_id(mesh_index);
|
||||||
|
(MeshAvailability::DeferredUnion(part_texture_description),mesh_id)
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let mesh_asset_id=match get_content_url(mesh_content){
|
let model_deferred_attributes=ModelDeferredAttributes{
|
||||||
Some(mesh_asset_id)=>mesh_asset_id,
|
mesh:mesh_id,
|
||||||
None=>{
|
transform:model_transform,
|
||||||
recoverable_errors.meshpart_content.push(InstancePath::new(dom,object));
|
color:glam::vec4(color3.r as f32/255f32, color3.g as f32/255f32, color3.b as f32/255f32, 1.0-*transparency),
|
||||||
// Return an empty string which will fail to parse as an asset id
|
deferred_attributes:GetAttributesArgs{
|
||||||
""
|
name:object.name.as_str(),
|
||||||
}
|
can_collide:*can_collide,
|
||||||
|
velocity:vec3::try_from_f32_array([velocity.x,velocity.y,velocity.z]).unwrap(),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
let texture_asset_id=get_content_url(texture_content);
|
match availability{
|
||||||
(
|
MeshAvailability::Immediate=>primitive_models_deferred_attributes.push(model_deferred_attributes),
|
||||||
MeshAvailability::DeferredMesh(render_config_deferred_loader.acquire_render_config_id(texture_asset_id)),
|
MeshAvailability::DeferredMesh(render)=>deferred_models_deferred_attributes.push(DeferredModelDeferredAttributes{
|
||||||
mesh_deferred_loader.acquire_mesh_id(MeshIndex::file_mesh(mesh_asset_id)),
|
render,
|
||||||
)
|
model:model_deferred_attributes
|
||||||
},
|
}),
|
||||||
Shape::PhysicsData=>{
|
MeshAvailability::DeferredUnion(part_texture_description)=>deferred_unions_deferred_attributes.push(DeferredUnionDeferredAttributes{
|
||||||
let mut content="";
|
render:part_texture_description,
|
||||||
let mut mesh_data:&[u8]=&[];
|
model:model_deferred_attributes,
|
||||||
let mut physics_data:&[u8]=&[];
|
}),
|
||||||
if let Some(rbx_dom_weak::types::Variant::ContentId(asset_id))=object.properties.get(&static_ustr("AssetId")){
|
|
||||||
content=asset_id.as_ref();
|
|
||||||
}
|
}
|
||||||
if let Some(rbx_dom_weak::types::Variant::BinaryString(data))=object.properties.get(&static_ustr("MeshData")){
|
|
||||||
mesh_data=data.as_ref();
|
|
||||||
}
|
|
||||||
if let Some(rbx_dom_weak::types::Variant::BinaryString(data))=object.properties.get(&static_ustr("PhysicsData")){
|
|
||||||
physics_data=data.as_ref();
|
|
||||||
}
|
|
||||||
let part_texture_description=get_texture_description(render_config_deferred_loader,&mut recoverable_errors,db,dom,object,size);
|
|
||||||
let mesh_index=MeshIndex::union(content,mesh_data,physics_data,size,part_texture_description.clone());
|
|
||||||
let mesh_id=mesh_deferred_loader.acquire_mesh_id(mesh_index);
|
|
||||||
(MeshAvailability::DeferredUnion(part_texture_description),mesh_id)
|
|
||||||
},
|
|
||||||
};
|
|
||||||
let velocity=match vec3::try_from_f32_array([velocity.x,velocity.y,velocity.z]){
|
|
||||||
Ok(velocity)=>velocity,
|
|
||||||
Err(e)=>{
|
|
||||||
recoverable_errors.basepart_velocity.push(Planar64ConvertError{
|
|
||||||
path:InstancePath::new(dom,object),
|
|
||||||
error:e,
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
};
|
|
||||||
let model_deferred_attributes=ModelDeferredAttributes{
|
|
||||||
mesh:mesh_id,
|
|
||||||
transform:model_transform,
|
|
||||||
color:glam::vec4(color3.r as f32/255f32,color3.g as f32/255f32,color3.b as f32/255f32,1.0-*transparency),
|
|
||||||
deferred_attributes:GetAttributesArgs{
|
|
||||||
name:object.name.as_str(),
|
|
||||||
can_collide,
|
|
||||||
velocity,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
match availability{
|
|
||||||
MeshAvailability::Immediate=>primitive_models_deferred_attributes.push(model_deferred_attributes),
|
|
||||||
MeshAvailability::DeferredMesh(render)=>deferred_models_deferred_attributes.push(DeferredModelDeferredAttributes{
|
|
||||||
render,
|
|
||||||
model:model_deferred_attributes
|
|
||||||
}),
|
|
||||||
MeshAvailability::DeferredUnion(part_texture_description)=>deferred_unions_deferred_attributes.push(DeferredUnionDeferredAttributes{
|
|
||||||
render:part_texture_description,
|
|
||||||
model:model_deferred_attributes,
|
|
||||||
}),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PartialMap1{
|
PartialMap1{
|
||||||
@ -759,7 +713,6 @@ pub fn convert<'a>(
|
|||||||
primitive_models_deferred_attributes,
|
primitive_models_deferred_attributes,
|
||||||
deferred_models_deferred_attributes,
|
deferred_models_deferred_attributes,
|
||||||
deferred_unions_deferred_attributes,
|
deferred_unions_deferred_attributes,
|
||||||
recoverable_errors,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct MeshIdWithSize{
|
struct MeshIdWithSize{
|
||||||
@ -819,7 +772,6 @@ pub struct PartialMap1<'a>{
|
|||||||
primitive_models_deferred_attributes:Vec<ModelDeferredAttributes<'a>>,
|
primitive_models_deferred_attributes:Vec<ModelDeferredAttributes<'a>>,
|
||||||
deferred_models_deferred_attributes:Vec<DeferredModelDeferredAttributes<'a>>,
|
deferred_models_deferred_attributes:Vec<DeferredModelDeferredAttributes<'a>>,
|
||||||
deferred_unions_deferred_attributes:Vec<DeferredUnionDeferredAttributes<'a>>,
|
deferred_unions_deferred_attributes:Vec<DeferredUnionDeferredAttributes<'a>>,
|
||||||
recoverable_errors:RecoverableErrors,
|
|
||||||
}
|
}
|
||||||
impl PartialMap1<'_>{
|
impl PartialMap1<'_>{
|
||||||
pub fn add_meshpart_meshes_and_calculate_attributes(
|
pub fn add_meshpart_meshes_and_calculate_attributes(
|
||||||
@ -843,7 +795,6 @@ impl PartialMap1<'_>{
|
|||||||
// I just want to chain iterators together man
|
// I just want to chain iterators together man
|
||||||
let aint_no_way=core::cell::UnsafeCell::new(&mut self.primitive_meshes);
|
let aint_no_way=core::cell::UnsafeCell::new(&mut self.primitive_meshes);
|
||||||
|
|
||||||
let mut model_counter=0;
|
|
||||||
let mut mesh_id_from_render_config_id=HashMap::new();
|
let mut mesh_id_from_render_config_id=HashMap::new();
|
||||||
let mut union_id_from_render_config_id=HashMap::new();
|
let mut union_id_from_render_config_id=HashMap::new();
|
||||||
//now that the meshes are loaded, these models can be generated
|
//now that the meshes are loaded, these models can be generated
|
||||||
@ -896,78 +847,61 @@ impl PartialMap1<'_>{
|
|||||||
})
|
})
|
||||||
}))
|
}))
|
||||||
.chain(self.primitive_models_deferred_attributes.into_iter())
|
.chain(self.primitive_models_deferred_attributes.into_iter())
|
||||||
.filter_map(|model_deferred_attributes|{
|
.enumerate().map(|(model_id,model_deferred_attributes)|{
|
||||||
let model_id=model::ModelId::new(model_counter);
|
let model_id=model::ModelId::new(model_id as u32);
|
||||||
let attributes=match get_attributes(
|
ModelOwnedAttributes{
|
||||||
&model_deferred_attributes.deferred_attributes.name,
|
|
||||||
model_deferred_attributes.deferred_attributes.can_collide,
|
|
||||||
model_deferred_attributes.deferred_attributes.velocity,
|
|
||||||
model_id,
|
|
||||||
&mut modes_builder,
|
|
||||||
&mut wormhole_in_model_to_id,
|
|
||||||
&mut wormhole_id_to_out_model,
|
|
||||||
){
|
|
||||||
Ok(attributes)=>attributes,
|
|
||||||
Err(e)=>{
|
|
||||||
match e{
|
|
||||||
GetAttributesError::ModeIdParseInt(e)=>self.recoverable_errors.mode_id_parse_int.push(e),
|
|
||||||
GetAttributesError::DuplicateMode(mode_id)=>{self.recoverable_errors.duplicate_mode.insert(mode_id);},
|
|
||||||
GetAttributesError::StageIdParseInt(e)=>self.recoverable_errors.stage_id_parse_int.push(e),
|
|
||||||
GetAttributesError::DuplicateStage(duplicate_stage)=>{self.recoverable_errors.duplicate_stage.insert(duplicate_stage);},
|
|
||||||
GetAttributesError::WormholeOutIdParseInt(e)=>self.recoverable_errors.wormhole_out_id_parse_int.push(e),
|
|
||||||
GetAttributesError::DuplicateWormholeOut(wormhole_id)=>{self.recoverable_errors.duplicate_wormhole_out.insert(wormhole_id);},
|
|
||||||
GetAttributesError::WormholeInIdParseInt(e)=>self.recoverable_errors.wormhole_in_id_parse_int.push(e),
|
|
||||||
GetAttributesError::JumpLimitParseInt(e)=>self.recoverable_errors.jump_limit_parse_int.push(e),
|
|
||||||
}
|
|
||||||
return None;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
model_counter+=1;
|
|
||||||
Some(ModelOwnedAttributes{
|
|
||||||
mesh:model_deferred_attributes.mesh,
|
mesh:model_deferred_attributes.mesh,
|
||||||
attributes,
|
attributes:get_attributes(
|
||||||
|
&model_deferred_attributes.deferred_attributes.name,
|
||||||
|
model_deferred_attributes.deferred_attributes.can_collide,
|
||||||
|
model_deferred_attributes.deferred_attributes.velocity,
|
||||||
|
model_id,
|
||||||
|
&mut modes_builder,
|
||||||
|
&mut wormhole_in_model_to_id,
|
||||||
|
&mut wormhole_id_to_out_model,
|
||||||
|
),
|
||||||
color:model_deferred_attributes.color,
|
color:model_deferred_attributes.color,
|
||||||
transform:model_deferred_attributes.transform,
|
transform:model_deferred_attributes.transform,
|
||||||
})
|
}
|
||||||
}).collect();
|
}).collect();
|
||||||
let models=models_owned_attributes.into_iter().enumerate().map(|(model_id,mut model_owned_attributes)|{
|
let models=models_owned_attributes.into_iter().enumerate().map(|(model_id,mut model_owned_attributes)|{
|
||||||
let model_id=model::ModelId::new(model_id as u32);
|
//TODO: TAB
|
||||||
//update attributes with wormhole id
|
let model_id=model::ModelId::new(model_id as u32);
|
||||||
//TODO: errors/prints
|
//update attributes with wormhole id
|
||||||
if let Some(wormhole_id)=wormhole_in_model_to_id.get(&model_id){
|
//TODO: errors/prints
|
||||||
if let Some(&wormhole_out_model_id)=wormhole_id_to_out_model.get(wormhole_id){
|
if let Some(wormhole_id)=wormhole_in_model_to_id.get(&model_id){
|
||||||
match &mut model_owned_attributes.attributes{
|
if let Some(&wormhole_out_model_id)=wormhole_id_to_out_model.get(wormhole_id){
|
||||||
attr::CollisionAttributes::Contact(attr::ContactAttributes{contacting:_,general})
|
match &mut model_owned_attributes.attributes{
|
||||||
|attr::CollisionAttributes::Intersect(attr::IntersectAttributes{intersecting:_,general})
|
attr::CollisionAttributes::Contact(attr::ContactAttributes{contacting:_,general})
|
||||||
=>general.wormhole=Some(attr::Wormhole{destination_model:wormhole_out_model_id}),
|
|attr::CollisionAttributes::Intersect(attr::IntersectAttributes{intersecting:_,general})
|
||||||
attr::CollisionAttributes::Decoration=>println!("Not a wormhole"),
|
=>general.wormhole=Some(attr::Wormhole{destination_model:wormhole_out_model_id}),
|
||||||
}
|
attr::CollisionAttributes::Decoration=>println!("Not a wormhole"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//index the attributes
|
|
||||||
let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model_owned_attributes.attributes){
|
|
||||||
attributes_id
|
|
||||||
}else{
|
|
||||||
let attributes_id=attr::CollisionAttributesId::new(unique_attributes.len() as u32);
|
|
||||||
attributes_id_from_attributes.insert(model_owned_attributes.attributes.clone(),attributes_id);
|
|
||||||
unique_attributes.push(model_owned_attributes.attributes);
|
|
||||||
attributes_id
|
|
||||||
};
|
|
||||||
model::Model{
|
|
||||||
mesh:model_owned_attributes.mesh,
|
|
||||||
transform:model_owned_attributes.transform,
|
|
||||||
color:model_owned_attributes.color,
|
|
||||||
attributes:attributes_id,
|
|
||||||
}
|
|
||||||
}).collect();
|
|
||||||
PartialMap2{
|
|
||||||
meshes:self.primitive_meshes,
|
|
||||||
models,
|
|
||||||
modes:modes_builder.build_normalized(),
|
|
||||||
attributes:unique_attributes,
|
|
||||||
recoverable_errors:self.recoverable_errors,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//index the attributes
|
||||||
|
let attributes_id=if let Some(&attributes_id)=attributes_id_from_attributes.get(&model_owned_attributes.attributes){
|
||||||
|
attributes_id
|
||||||
|
}else{
|
||||||
|
let attributes_id=attr::CollisionAttributesId::new(unique_attributes.len() as u32);
|
||||||
|
attributes_id_from_attributes.insert(model_owned_attributes.attributes.clone(),attributes_id);
|
||||||
|
unique_attributes.push(model_owned_attributes.attributes);
|
||||||
|
attributes_id
|
||||||
|
};
|
||||||
|
model::Model{
|
||||||
|
mesh:model_owned_attributes.mesh,
|
||||||
|
transform:model_owned_attributes.transform,
|
||||||
|
color:model_owned_attributes.color,
|
||||||
|
attributes:attributes_id,
|
||||||
|
}
|
||||||
|
}).collect();
|
||||||
|
PartialMap2{
|
||||||
|
meshes:self.primitive_meshes,
|
||||||
|
models,
|
||||||
|
modes:modes_builder.build_normalized(),
|
||||||
|
attributes:unique_attributes,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -976,13 +910,12 @@ pub struct PartialMap2{
|
|||||||
models:Vec<model::Model>,
|
models:Vec<model::Model>,
|
||||||
modes:NormalizedModes,
|
modes:NormalizedModes,
|
||||||
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
||||||
recoverable_errors:RecoverableErrors,
|
|
||||||
}
|
}
|
||||||
impl PartialMap2{
|
impl PartialMap2{
|
||||||
pub fn add_render_configs_and_textures(
|
pub fn add_render_configs_and_textures(
|
||||||
self,
|
self,
|
||||||
render_configs:RenderConfigs,
|
render_configs:RenderConfigs,
|
||||||
)->(map::CompleteMap,RecoverableErrors){
|
)->map::CompleteMap{
|
||||||
let (textures,render_configs)=render_configs.consume();
|
let (textures,render_configs)=render_configs.consume();
|
||||||
let (textures,texture_id_map):(Vec<Vec<u8>>,HashMap<model::TextureId,model::TextureId>)
|
let (textures,texture_id_map):(Vec<Vec<u8>>,HashMap<model::TextureId,model::TextureId>)
|
||||||
=textures.into_iter().enumerate().map(|(new_texture_id,(old_texture_id,Texture::ImageDDS(texture)))|{
|
=textures.into_iter().enumerate().map(|(new_texture_id,(old_texture_id,Texture::ImageDDS(texture)))|{
|
||||||
@ -1001,17 +934,14 @@ impl PartialMap2{
|
|||||||
);
|
);
|
||||||
render_config
|
render_config
|
||||||
}).collect();
|
}).collect();
|
||||||
(
|
map::CompleteMap{
|
||||||
map::CompleteMap{
|
modes:self.modes,
|
||||||
modes:self.modes,
|
attributes:self.attributes,
|
||||||
attributes:self.attributes,
|
meshes:self.meshes,
|
||||||
meshes:self.meshes,
|
models:self.models,
|
||||||
models:self.models,
|
//the roblox legacy texture thing always works
|
||||||
//the roblox legacy texture thing always works
|
textures,
|
||||||
textures,
|
render_configs,
|
||||||
render_configs,
|
}
|
||||||
},
|
|
||||||
self.recoverable_errors,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,8 +81,8 @@ pub fn convert(
|
|||||||
).map_err(Error::RobloxMeshData)?;
|
).map_err(Error::RobloxMeshData)?;
|
||||||
let graphics_mesh=match mesh_data{
|
let graphics_mesh=match mesh_data{
|
||||||
rbx_mesh::mesh_data::MeshData::CSGK(_)=>return Err(Error::Block),
|
rbx_mesh::mesh_data::MeshData::CSGK(_)=>return Err(Error::Block),
|
||||||
rbx_mesh::mesh_data::MeshData::CSGMDL(rbx_mesh::mesh_data::CSGMDL::V2(mesh_data2))=>mesh_data2.mesh,
|
rbx_mesh::mesh_data::MeshData::CSGMDL(rbx_mesh::mesh_data::CSGMDL::CSGMDL2(mesh_data2))=>mesh_data2.mesh,
|
||||||
rbx_mesh::mesh_data::MeshData::CSGMDL(rbx_mesh::mesh_data::CSGMDL::V4(mesh_data4))=>mesh_data4.mesh,
|
rbx_mesh::mesh_data::MeshData::CSGMDL(rbx_mesh::mesh_data::CSGMDL::CSGMDL4(mesh_data4))=>mesh_data4.mesh,
|
||||||
};
|
};
|
||||||
//autoscale to size, idk what roblox is doing with the graphics mesh size
|
//autoscale to size, idk what roblox is doing with the graphics mesh size
|
||||||
let mut pos_min=glam::Vec3::MAX;
|
let mut pos_min=glam::Vec3::MAX;
|
||||||
@ -153,13 +153,10 @@ pub fn convert(
|
|||||||
// have not seen this format in practice
|
// have not seen this format in practice
|
||||||
|rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::Block)
|
|rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::Block)
|
||||||
=>return Err(Error::Block),
|
=>return Err(Error::Block),
|
||||||
rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::V3(meshes))
|
rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::Meshes(meshes))
|
||||||
|rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::V5(meshes))
|
|
||||||
=>meshes.meshes,
|
|
||||||
rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::V6(meshes))
|
|
||||||
=>vec![meshes.mesh],
|
|
||||||
rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::V7(meshes))
|
|
||||||
=>meshes.meshes,
|
=>meshes.meshes,
|
||||||
|
rbx_mesh::physics_data::PhysicsData::CSGPHS(rbx_mesh::physics_data::CSGPHS::PhysicsInfoMesh(pim))
|
||||||
|
=>vec![pim.mesh],
|
||||||
};
|
};
|
||||||
let physics_convex_meshes_it=physics_convex_meshes.into_iter().map(|mesh|{
|
let physics_convex_meshes_it=physics_convex_meshes.into_iter().map(|mesh|{
|
||||||
// this can be factored out of the loop but I am lazy
|
// this can be factored out of the loop but I am lazy
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "roblox_emulator"
|
name = "roblox_emulator"
|
||||||
version = "0.5.1"
|
version = "0.5.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
repository = "https://git.itzana.me/StrafesNET/strafe-project"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
|
@ -79,15 +79,7 @@ impl Context{
|
|||||||
|
|
||||||
//insert services
|
//insert services
|
||||||
let game=dom.root_ref();
|
let game=dom.root_ref();
|
||||||
let terrain_bldr=InstanceBuilder::new("Terrain")
|
let terrain_bldr=InstanceBuilder::new("Terrain");
|
||||||
.with_properties([
|
|
||||||
("CFrame",rbx_dom_weak::types::Variant::CFrame(rbx_dom_weak::types::CFrame::new(rbx_dom_weak::types::Vector3::new(0.0,0.0,0.0),rbx_dom_weak::types::Matrix3::identity()))),
|
|
||||||
("Size",rbx_dom_weak::types::Variant::Vector3(rbx_dom_weak::types::Vector3::new(1.0,1.0,1.0))),
|
|
||||||
("Velocity",rbx_dom_weak::types::Variant::Vector3(rbx_dom_weak::types::Vector3::new(0.0,0.0,0.0))),
|
|
||||||
("Transparency",rbx_dom_weak::types::Variant::Float32(0.0)),
|
|
||||||
("Color",rbx_dom_weak::types::Variant::Color3uint8(rbx_dom_weak::types::Color3uint8::new(255,255,255))),
|
|
||||||
("CanCollide",rbx_dom_weak::types::Variant::Bool(true)),
|
|
||||||
]);
|
|
||||||
let workspace=dom.insert(game,
|
let workspace=dom.insert(game,
|
||||||
InstanceBuilder::new("Workspace")
|
InstanceBuilder::new("Workspace")
|
||||||
//Set Workspace.Terrain property equal to Terrain
|
//Set Workspace.Terrain property equal to Terrain
|
||||||
|
@ -13,12 +13,14 @@ pub enum Error{
|
|||||||
error:mlua::Error
|
error:mlua::Error
|
||||||
},
|
},
|
||||||
RustLua(mlua::Error),
|
RustLua(mlua::Error),
|
||||||
|
Services(crate::context::ServicesError),
|
||||||
}
|
}
|
||||||
impl std::fmt::Display for Error{
|
impl std::fmt::Display for Error{
|
||||||
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
fn fmt(&self,f:&mut std::fmt::Formatter<'_>)->std::fmt::Result{
|
||||||
match self{
|
match self{
|
||||||
Self::Lua{source,error}=>write!(f,"lua error: source:\n{source}\n{error}"),
|
Self::Lua{source,error}=>write!(f,"lua error: source:\n{source}\n{error}"),
|
||||||
Self::RustLua(error)=>write!(f,"rust-side lua error: {error}"),
|
Self::RustLua(error)=>write!(f,"rust-side lua error: {error}"),
|
||||||
|
other=>write!(f,"{other:?}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "strafesnet_snf"
|
name = "strafesnet_snf"
|
||||||
version = "0.3.1"
|
version = "0.3.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
binrw = "0.15.0"
|
binrw = "0.14.0"
|
||||||
id = { version = "0.1.0", registry = "strafesnet" }
|
id = { version = "0.1.0", registry = "strafesnet" }
|
||||||
strafesnet_common = { version = "0.7.0", path = "../common", registry = "strafesnet" }
|
strafesnet_common = { version = "0.6.0", path = "../common", registry = "strafesnet" }
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "map-tool"
|
name = "map-tool"
|
||||||
version = "1.7.2"
|
version = "1.7.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
@ -19,10 +19,10 @@ rbx_dom_weak = { version = "3.1.0-sn4", registry = "strafesnet" }
|
|||||||
rbx_reflection_database = "1.0.0"
|
rbx_reflection_database = "1.0.0"
|
||||||
rbx_xml = { version = "1.1.0-sn4", registry = "strafesnet" }
|
rbx_xml = { version = "1.1.0-sn4", registry = "strafesnet" }
|
||||||
rbxassetid = { version = "0.1.0", registry = "strafesnet" }
|
rbxassetid = { version = "0.1.0", registry = "strafesnet" }
|
||||||
strafesnet_bsp_loader = { version = "0.3.1", path = "../lib/bsp_loader", registry = "strafesnet" }
|
strafesnet_bsp_loader = { version = "0.3.0", path = "../lib/bsp_loader", registry = "strafesnet" }
|
||||||
strafesnet_deferred_loader = { version = "0.5.1", path = "../lib/deferred_loader", registry = "strafesnet" }
|
strafesnet_deferred_loader = { version = "0.5.0", path = "../lib/deferred_loader", registry = "strafesnet" }
|
||||||
strafesnet_rbx_loader = { version = "0.7.0", path = "../lib/rbx_loader", registry = "strafesnet" }
|
strafesnet_rbx_loader = { version = "0.6.0", path = "../lib/rbx_loader", registry = "strafesnet" }
|
||||||
strafesnet_snf = { version = "0.3.1", path = "../lib/snf", registry = "strafesnet" }
|
strafesnet_snf = { version = "0.3.0", path = "../lib/snf", registry = "strafesnet" }
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread", "fs"] }
|
tokio = { version = "1.43.0", features = ["macros", "rt-multi-thread", "fs"] }
|
||||||
vbsp = "0.9.1"
|
vbsp = "0.9.1"
|
||||||
|
@ -32,12 +32,8 @@ pub struct RobloxToSNFSubcommand {
|
|||||||
pub struct DownloadAssetsSubcommand{
|
pub struct DownloadAssetsSubcommand{
|
||||||
#[arg(required=true)]
|
#[arg(required=true)]
|
||||||
roblox_files:Vec<PathBuf>,
|
roblox_files:Vec<PathBuf>,
|
||||||
#[arg(long,group="cookie",required=true)]
|
// #[arg(long)]
|
||||||
cookie_literal:Option<String>,
|
// cookie_file:Option<String>,
|
||||||
#[arg(long,group="cookie",required=true)]
|
|
||||||
cookie_envvar:Option<String>,
|
|
||||||
#[arg(long,group="cookie",required=true)]
|
|
||||||
cookie_file:Option<PathBuf>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Commands{
|
impl Commands{
|
||||||
@ -46,26 +42,12 @@ impl Commands{
|
|||||||
Commands::RobloxToSNF(subcommand)=>roblox_to_snf(subcommand.input_files,subcommand.output_folder).await,
|
Commands::RobloxToSNF(subcommand)=>roblox_to_snf(subcommand.input_files,subcommand.output_folder).await,
|
||||||
Commands::DownloadAssets(subcommand)=>download_assets(
|
Commands::DownloadAssets(subcommand)=>download_assets(
|
||||||
subcommand.roblox_files,
|
subcommand.roblox_files,
|
||||||
cookie_from_args(
|
rbx_asset::cookie::Cookie::new("".to_string()),
|
||||||
subcommand.cookie_literal,
|
|
||||||
subcommand.cookie_envvar,
|
|
||||||
subcommand.cookie_file,
|
|
||||||
).await?,
|
|
||||||
).await,
|
).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn cookie_from_args(literal:Option<String>,environment:Option<String>,file:Option<PathBuf>)->AResult<rbx_asset::cookie::Cookie>{
|
|
||||||
let cookie=match (literal,environment,file){
|
|
||||||
(Some(cookie_literal),None,None)=>cookie_literal,
|
|
||||||
(None,Some(cookie_environment),None)=>std::env::var(cookie_environment)?,
|
|
||||||
(None,None,Some(cookie_file))=>tokio::fs::read_to_string(cookie_file).await?,
|
|
||||||
_=>Err(anyhow::Error::msg("Illegal cookie argument triple"))?,
|
|
||||||
};
|
|
||||||
Ok(rbx_asset::cookie::Cookie::new(cookie))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum LoadDomError{
|
enum LoadDomError{
|
||||||
@ -267,8 +249,8 @@ async fn download_retry(stats:&mut Stats,context:&rbx_asset::cookie::Context,dow
|
|||||||
tokio::fs::write(path,&data).await?;
|
tokio::fs::write(path,&data).await?;
|
||||||
break Ok(DownloadResult::Data(data));
|
break Ok(DownloadResult::Data(data));
|
||||||
},
|
},
|
||||||
Err(rbx_asset::cookie::GetError::Response(rbx_asset::types::ResponseError::Details{status_code,url_and_body}))=>{
|
Err(rbx_asset::cookie::GetError::Response(rbx_asset::types::ResponseError::StatusCodeWithUrlAndBody(scwuab)))=>{
|
||||||
if status_code.as_u16()==429{
|
if scwuab.status_code.as_u16()==429{
|
||||||
if retry==12{
|
if retry==12{
|
||||||
println!("Giving up asset download {asset_id}");
|
println!("Giving up asset download {asset_id}");
|
||||||
stats.timed_out_downloads+=1;
|
stats.timed_out_downloads+=1;
|
||||||
@ -280,7 +262,7 @@ async fn download_retry(stats:&mut Stats,context:&rbx_asset::cookie::Context,dow
|
|||||||
retry+=1;
|
retry+=1;
|
||||||
}else{
|
}else{
|
||||||
stats.failed_downloads+=1;
|
stats.failed_downloads+=1;
|
||||||
println!("weird status_code error: status_code={status_code} url={} body={}",url_and_body.url,url_and_body.body);
|
println!("weird scuwab error: {scwuab:?}");
|
||||||
break Ok(DownloadResult::Failed);
|
break Ok(DownloadResult::Failed);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -434,23 +416,17 @@ impl std::fmt::Display for ConvertError{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
impl std::error::Error for ConvertError{}
|
impl std::error::Error for ConvertError{}
|
||||||
|
async fn convert_to_snf(path:&Path,output_folder:PathBuf)->AResult<()>{
|
||||||
struct Errors{
|
let entire_file=tokio::fs::read(path).await?;
|
||||||
script_errors:Vec<strafesnet_rbx_loader::RunnerError>,
|
|
||||||
convert_errors:strafesnet_rbx_loader::RecoverableErrors,
|
|
||||||
}
|
|
||||||
|
|
||||||
fn convert_to_snf(path:&Path,output_folder:PathBuf)->Result<Errors,ConvertError>{
|
|
||||||
let entire_file=std::fs::read(path).map_err(ConvertError::IO)?;
|
|
||||||
|
|
||||||
let model=strafesnet_rbx_loader::read(
|
let model=strafesnet_rbx_loader::read(
|
||||||
entire_file.as_slice()
|
std::io::Cursor::new(entire_file)
|
||||||
).map_err(ConvertError::RobloxRead)?;
|
).map_err(ConvertError::RobloxRead)?;
|
||||||
|
|
||||||
let mut place=strafesnet_rbx_loader::Place::from(model);
|
let mut place=strafesnet_rbx_loader::Place::from(model);
|
||||||
let script_errors=place.run_scripts().unwrap_or_else(|e|vec![e]);
|
place.run_scripts();
|
||||||
|
|
||||||
let (map,convert_errors)=place.to_snf(LoadFailureMode::DefaultToNone).map_err(ConvertError::RobloxLoad)?;
|
let map=place.to_snf(LoadFailureMode::DefaultToNone).map_err(ConvertError::RobloxLoad)?;
|
||||||
|
|
||||||
let mut dest=output_folder;
|
let mut dest=output_folder;
|
||||||
dest.push(path.file_stem().unwrap());
|
dest.push(path.file_stem().unwrap());
|
||||||
@ -459,10 +435,7 @@ fn convert_to_snf(path:&Path,output_folder:PathBuf)->Result<Errors,ConvertError>
|
|||||||
|
|
||||||
strafesnet_snf::map::write_map(file,map).map_err(ConvertError::SNFMap)?;
|
strafesnet_snf::map::write_map(file,map).map_err(ConvertError::SNFMap)?;
|
||||||
|
|
||||||
Ok(Errors{
|
Ok(())
|
||||||
script_errors,
|
|
||||||
convert_errors,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn roblox_to_snf(paths:Vec<std::path::PathBuf>,output_folder:PathBuf)->AResult<()>{
|
async fn roblox_to_snf(paths:Vec<std::path::PathBuf>,output_folder:PathBuf)->AResult<()>{
|
||||||
@ -471,25 +444,15 @@ async fn roblox_to_snf(paths:Vec<std::path::PathBuf>,output_folder:PathBuf)->ARe
|
|||||||
let thread_limit=std::thread::available_parallelism()?.get();
|
let thread_limit=std::thread::available_parallelism()?.get();
|
||||||
let mut it=paths.into_iter();
|
let mut it=paths.into_iter();
|
||||||
static SEM:tokio::sync::Semaphore=tokio::sync::Semaphore::const_new(0);
|
static SEM:tokio::sync::Semaphore=tokio::sync::Semaphore::const_new(0);
|
||||||
// This is wrong! Calling roblox_to_snf multiple times keeps adding permits
|
|
||||||
SEM.add_permits(thread_limit);
|
SEM.add_permits(thread_limit);
|
||||||
|
|
||||||
while let (Ok(permit),Some(path))=(SEM.acquire().await,it.next()){
|
while let (Ok(permit),Some(path))=(SEM.acquire().await,it.next()){
|
||||||
let output_folder=output_folder.clone();
|
let output_folder=output_folder.clone();
|
||||||
tokio::task::spawn_blocking(move||{
|
tokio::spawn(async move{
|
||||||
let result=convert_to_snf(path.as_path(),output_folder);
|
let result=convert_to_snf(path.as_path(),output_folder).await;
|
||||||
drop(permit);
|
drop(permit);
|
||||||
match result{
|
match result{
|
||||||
Ok(errors)=>{
|
Ok(())=>(),
|
||||||
for error in errors.script_errors{
|
|
||||||
println!("Script error: {error}");
|
|
||||||
}
|
|
||||||
let error_count=errors.convert_errors.count();
|
|
||||||
if error_count!=0{
|
|
||||||
println!("Error count: {error_count}");
|
|
||||||
println!("Errors: {}",errors.convert_errors);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
Err(e)=>println!("Convert error: {e:?}"),
|
Err(e)=>println!("Convert error: {e:?}"),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -98,15 +98,10 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<LoadFormat,LoadError>{
|
|||||||
#[cfg(feature="roblox")]
|
#[cfg(feature="roblox")]
|
||||||
ReadFormat::Roblox(model)=>{
|
ReadFormat::Roblox(model)=>{
|
||||||
let mut place=strafesnet_rbx_loader::Place::from(model);
|
let mut place=strafesnet_rbx_loader::Place::from(model);
|
||||||
let script_errors=place.run_scripts().unwrap();
|
place.run_scripts();
|
||||||
for error in script_errors{
|
Ok(LoadFormat::Map(
|
||||||
println!("Script error: {error}");
|
place.to_snf(LoadFailureMode::DefaultToNone).map_err(LoadError::LoadRoblox)?
|
||||||
}
|
))
|
||||||
let (map,errors)=place.to_snf(LoadFailureMode::DefaultToNone).map_err(LoadError::LoadRoblox)?;
|
|
||||||
if errors.count()!=0{
|
|
||||||
print!("Errors encountered while loading the map:\n{}",errors);
|
|
||||||
}
|
|
||||||
Ok(LoadFormat::Map(map))
|
|
||||||
},
|
},
|
||||||
#[cfg(feature="source")]
|
#[cfg(feature="source")]
|
||||||
ReadFormat::Source(bsp)=>Ok(LoadFormat::Map(
|
ReadFormat::Source(bsp)=>Ok(LoadFormat::Map(
|
||||||
|
@ -1 +0,0 @@
|
|||||||
mangohud ../target/release/strafe-client bhop_maps/5692098704.snfm "$@"
|
|
Reference in New Issue
Block a user