strafe-client/src/map.rs

96 lines
2.1 KiB
Rust
Raw Normal View History

2024-01-16 03:09:34 +00:00
pub enum Error{
2024-01-19 00:39:58 +00:00
InvalidHeader,
2024-01-18 23:33:22 +00:00
InvalidNode,
2024-01-16 03:09:34 +00:00
}
/* block types
BLOCK_MAP_HEADER:
DefaultStyleInfo style_info
//bvh goes here
u64 num_nodes
//node 0 parent node is implied to be None
for node_id in 1..num_nodes{
u64 parent_node
}
2024-01-18 23:24:00 +00:00
//NOTE: alternate realities are not necessary.
//portals/wormholes simply use an in-model and and out-model.
//skyboxes are inverted models with a special shader.
2024-01-17 02:50:02 +00:00
//ideally spacial blocks are sorted from distance to start zone
//texture blocks are inserted before the first spacial block they are used in
2024-01-16 03:09:34 +00:00
u64 num_spacial_blocks
for spacial_block_id in 0..num_spacial_blocks{
u64 node_id
u64 block_id //data block
Aabb block_extents
}
2024-01-17 02:50:02 +00:00
//if the map file references external resources, num_resources = 0
u64 num_resources
for resource_id in 0..num_resources{
u64 block_id
u128 resource_id
}
2024-01-16 03:09:34 +00:00
BLOCK_MAP_RESOURCE:
2024-01-17 02:50:02 +00:00
Resource resource_type
2024-01-16 03:09:34 +00:00
//an individual one of the following:
- model (IndexedModel)
- shader (compiled SPIR-V)
- image (JpegXL)
- sound (Opus)
- video (AV1)
- animation (Trey thing)
2024-01-17 02:50:02 +00:00
BLOCK_MAP_REGION:
u64 num_models
for model_id in 0..num_models{
u128 model_resource_uuid
ModelInstance mode_instance
}
2024-01-16 03:09:34 +00:00
*/
2024-01-17 04:07:11 +00:00
//xdd
mod physics{
pub struct StyleModifiers{}
}
mod model{
pub struct IndexedModel{}
pub struct ModelInstance{}
}
mod image{
pub struct Image{}
}
//serious code
struct ModelUuid(u128);
struct ImageUuid(u128);
pub struct BvhNodeId(u64);
2024-01-18 23:33:22 +00:00
struct BvhNode{
2024-01-16 03:09:34 +00:00
//
2024-01-18 23:33:22 +00:00
}
pub struct StreamableMap{
file:crate::file::File,
style:physics::StyleModifiers,//probably should move this out of physics
bvh:BvhNode,
2024-01-17 04:07:11 +00:00
//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>,
2024-01-18 23:33:22 +00:00
}
impl StreamableMap{
2024-01-19 00:39:58 +00:00
pub fn new(file:crate::file::File)->Result<Self,Error>{
Err(Error::InvalidHeader)
}
2024-01-18 23:33:22 +00:00
pub fn load_node(&mut self,node_id:BvhNodeId)->Result<Vec<model::ModelInstance>,Error>{
//load region from disk
//parse the models and determine what resources need to be loaded
//load resources into self.resources
//return Region
Err(Error::InvalidNode)
}
2024-01-16 03:09:34 +00:00
}