Compare commits

...

3 Commits

Author SHA1 Message Date
3e737282dc resource query instead of hold all 2024-02-01 04:03:43 -08:00
708c0c48ef update common 2024-02-01 04:03:43 -08:00
ce6f8074a9 add common dep 2024-01-29 22:56:15 -08:00
3 changed files with 25 additions and 15 deletions

15
Cargo.lock generated

@ -44,6 +44,12 @@ version = "1.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07"
[[package]]
name = "glam"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "151665d9be52f9bb40fc7966565d39666f2d1e69233571b71b87791c7e0528b3"
[[package]]
name = "owo-colors"
version = "3.5.0"
@ -68,11 +74,20 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "strafesnet_common"
version = "0.1.0"
source = "git+https://git.itzana.me/StrafesNET/common?rev=5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72#5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72"
dependencies = [
"glam",
]
[[package]]
name = "strafesnet_snf"
version = "0.1.0"
dependencies = [
"binrw",
"strafesnet_common",
]
[[package]]

@ -7,3 +7,4 @@ edition = "2021"
[dependencies]
binrw = "0.13.3"
strafesnet_common = { git = "https://git.itzana.me/StrafesNET/common", rev = "5ee826d9487b5e2bea4b3cf99a68ce9a95d72f72" }

@ -1,3 +1,5 @@
use strafesnet_common::model;
use strafesnet_common::gameplay_modes;
use binrw::{BinReaderExt, binrw};
pub enum Error{
@ -58,15 +60,6 @@ for model_id in 0..num_models{
//error hiding mock code
mod physics{
pub struct StyleModifiers{}
}
mod model{
pub struct IndexedModel{}
#[super::binrw]
#[brw(little)]
pub struct ModelInstance{}
}
mod image{
pub struct Image{}
}
@ -85,23 +78,21 @@ struct Region{
#[bw(try_calc(u32::try_from(models.len())))]
model_count:u32,
#[br(count=model_count)]
models:Vec<model::ModelInstance>,
models:Vec<model::Model>,
}
pub struct StreamableMap<R:BinReaderExt>{
file:crate::file::File<R>,
style:physics::StyleModifiers,//probably should move this out of physics
//this includes every platform... move the unconstrained datas to their appropriate data block?
modes:gameplay_modes::Modes,
bvh:BvhNode,
node_id_to_block_id:Vec<crate::file::BlockId>,
//do not need this? return only new data with load_node
resource_model:std::collections::HashMap<ModelUuid,model::IndexedModel>,
resource_image:std::collections::HashMap<ImageUuid,image::Image>,
}
impl<R:BinReaderExt> StreamableMap<R>{
pub(crate) fn new(file:crate::file::File<R>)->Result<Self,Error>{
Err(Error::InvalidHeader)
}
pub fn load_node(&mut self,node_id:BvhNodeId)->Result<Vec<model::ModelInstance>,Error>{
pub fn load_node(&mut self,node_id:BvhNodeId)->Result<Vec<model::Model>,Error>{
//load region from disk
//parse the models and determine what resources need to be loaded
//load resources into self.resources
@ -111,4 +102,7 @@ impl<R:BinReaderExt> StreamableMap<R>{
let region:Region=block.read_le().map_err(|e|Error::InvalidRegion(e))?;
Ok(region.models)
}
pub fn load_resource(&mut self,resource_id:ResourceId)->Resource{
//
}
}