Compare commits
14 Commits
web2
...
entity-phy
| Author | SHA1 | Date | |
|---|---|---|---|
| ed1250e2f1 | |||
| 2b272e1b7c | |||
| 70fb970582 | |||
| 31184d21da | |||
| 6b4b17f49d | |||
| d0c17873f6 | |||
| d39705d5e7 | |||
| a3a50580f8 | |||
| d5bf4549a9 | |||
| b5da85fae1 | |||
| 78c53ae429 | |||
| e794b2649c | |||
| 50f6fe5bd8 | |||
| fc3681f41f |
400
Cargo.lock
generated
400
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -1811,14 +1811,18 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|||||||
},
|
},
|
||||||
Instruction::Mode(ModeInstruction::Restart(mode_id))=>{
|
Instruction::Mode(ModeInstruction::Restart(mode_id))=>{
|
||||||
//teleport to mode start zone
|
//teleport to mode start zone
|
||||||
|
let mut spawn_point=vec3::ZERO;
|
||||||
let mode=data.modes.get_mode(mode_id);
|
let mode=data.modes.get_mode(mode_id);
|
||||||
let spawn_point=mode.and_then(|mode|
|
if let Some(mode)=mode{
|
||||||
|
// set style
|
||||||
|
state.style=mode.get_style().clone();
|
||||||
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
//TODO: spawn at the bottom of the start zone plus the hitbox size
|
||||||
//TODO: set camera andles to face the same way as the start zone
|
//TODO: set camera angles to face the same way as the start zone
|
||||||
data.models.get_model_transform(mode.get_start().into()).map(|transform|
|
if let Some(transform)=data.models.get_model_transform(mode.get_start()){
|
||||||
transform.vertex.translation
|
// NOTE: this value may be 0,0,0 on source maps
|
||||||
)
|
spawn_point=transform.vertex.translation;
|
||||||
).unwrap_or(vec3::ZERO);
|
}
|
||||||
|
}
|
||||||
set_position(spawn_point,&mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state,mode,&data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time);
|
set_position(spawn_point,&mut state.move_state,&mut state.body,&mut state.touching,&mut state.run,&mut state.mode_state,mode,&data.models,&data.hitbox_mesh,&data.bvh,&state.style,&state.camera,&state.input_state,state.time);
|
||||||
set_velocity(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO);
|
set_velocity(&mut state.body,&state.touching,&data.models,&data.hitbox_mesh,vec3::ZERO);
|
||||||
state.set_move_state(data,MoveState::Air);
|
state.set_move_state(data,MoveState::Air);
|
||||||
@@ -1828,6 +1832,9 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
|||||||
Instruction::Mode(ModeInstruction::Spawn(mode_id,stage_id))=>{
|
Instruction::Mode(ModeInstruction::Spawn(mode_id,stage_id))=>{
|
||||||
//spawn at a particular stage
|
//spawn at a particular stage
|
||||||
if let Some(mode)=data.modes.get_mode(mode_id){
|
if let Some(mode)=data.modes.get_mode(mode_id){
|
||||||
|
// set style
|
||||||
|
state.style=mode.get_style().clone();
|
||||||
|
// teleport to stage in mode
|
||||||
if let Some(stage)=mode.get_stage(stage_id){
|
if let Some(stage)=mode.get_stage(stage_id){
|
||||||
let _=teleport_to_spawn(
|
let _=teleport_to_spawn(
|
||||||
stage.spawn(),
|
stage.spawn(),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
use std::io::{Cursor,Read};
|
use std::io::Cursor;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
@@ -39,9 +39,7 @@ impl From<strafesnet_snf::bot::Error> for ReplayError{
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{
|
fn read_entire_file(path:impl AsRef<Path>)->Result<Cursor<Vec<u8>>,std::io::Error>{
|
||||||
let mut file=std::fs::File::open(path)?;
|
let data=std::fs::read(path)?;
|
||||||
let mut data=Vec::new();
|
|
||||||
file.read_to_end(&mut data)?;
|
|
||||||
Ok(Cursor::new(data))
|
Ok(Cursor::new(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::borrow::Cow;
|
|||||||
|
|
||||||
use vbsp_entities_css::Entity;
|
use vbsp_entities_css::Entity;
|
||||||
|
|
||||||
use strafesnet_common::{map,model,integer,gameplay_attributes};
|
use strafesnet_common::{map,model,integer,gameplay_attributes as attr};
|
||||||
use strafesnet_deferred_loader::deferred_loader::{MeshDeferredLoader,RenderConfigDeferredLoader};
|
use strafesnet_deferred_loader::deferred_loader::{MeshDeferredLoader,RenderConfigDeferredLoader};
|
||||||
use strafesnet_deferred_loader::mesh::Meshes;
|
use strafesnet_deferred_loader::mesh::Meshes;
|
||||||
use strafesnet_deferred_loader::texture::{RenderConfigs,Texture};
|
use strafesnet_deferred_loader::texture::{RenderConfigs,Texture};
|
||||||
@@ -42,7 +42,7 @@ fn add_brush<'a>(
|
|||||||
model:&'a str,
|
model:&'a str,
|
||||||
origin:vbsp::Vector,
|
origin:vbsp::Vector,
|
||||||
rendercolor:vbsp::Color,
|
rendercolor:vbsp::Color,
|
||||||
attributes:gameplay_attributes::CollisionAttributesId,
|
attributes:attr::CollisionAttributesId,
|
||||||
){
|
){
|
||||||
let transform=integer::Planar64Affine3::from_translation(
|
let transform=integer::Planar64Affine3::from_translation(
|
||||||
valve_transform(origin.into())
|
valve_transform(origin.into())
|
||||||
@@ -83,13 +83,40 @@ pub fn convert<'a>(
|
|||||||
)->PartialMap1{
|
)->PartialMap1{
|
||||||
let bsp=bsp.as_ref();
|
let bsp=bsp.as_ref();
|
||||||
//figure out real attributes later
|
//figure out real attributes later
|
||||||
let mut unique_attributes=Vec::new();
|
let unique_attributes=vec![
|
||||||
unique_attributes.push(gameplay_attributes::CollisionAttributes::Decoration);
|
attr::CollisionAttributes::Decoration,
|
||||||
unique_attributes.push(gameplay_attributes::CollisionAttributes::contact_default());
|
attr::CollisionAttributes::contact_default(),
|
||||||
unique_attributes.push(gameplay_attributes::CollisionAttributes::intersect_default());
|
attr::CollisionAttributes::intersect_default(),
|
||||||
const ATTRIBUTE_DECORATION:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(0);
|
// ladder
|
||||||
const ATTRIBUTE_CONTACT_DEFAULT:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(1);
|
attr::CollisionAttributes::Contact(
|
||||||
const ATTRIBUTE_INTERSECT_DEFAULT:gameplay_attributes::CollisionAttributesId=gameplay_attributes::CollisionAttributesId::new(2);
|
attr::ContactAttributes{
|
||||||
|
contacting:attr::ContactingAttributes{
|
||||||
|
contact_behaviour:Some(attr::ContactingBehaviour::Ladder(
|
||||||
|
attr::ContactingLadder{sticky:true}
|
||||||
|
))
|
||||||
|
},
|
||||||
|
general:attr::GeneralAttributes::default(),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
// water
|
||||||
|
attr::CollisionAttributes::Intersect(
|
||||||
|
attr::IntersectAttributes{
|
||||||
|
intersecting:attr::IntersectingAttributes{
|
||||||
|
water:Some(attr::IntersectingWater{
|
||||||
|
viscosity:integer::Planar64::ONE,
|
||||||
|
density:integer::Planar64::ONE,
|
||||||
|
velocity:integer::vec3::ZERO,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
general:attr::GeneralAttributes::default(),
|
||||||
|
}
|
||||||
|
),
|
||||||
|
];
|
||||||
|
const ATTRIBUTE_DECORATION:attr::CollisionAttributesId=attr::CollisionAttributesId::new(0);
|
||||||
|
const ATTRIBUTE_CONTACT_DEFAULT:attr::CollisionAttributesId=attr::CollisionAttributesId::new(1);
|
||||||
|
const ATTRIBUTE_INTERSECT_DEFAULT:attr::CollisionAttributesId=attr::CollisionAttributesId::new(2);
|
||||||
|
const ATTRIBUTE_LADDER_DEFAULT:attr::CollisionAttributesId=attr::CollisionAttributesId::new(3);
|
||||||
|
const ATTRIBUTE_WATER_DEFAULT:attr::CollisionAttributesId=attr::CollisionAttributesId::new(4);
|
||||||
|
|
||||||
//declare all prop models to Loader
|
//declare all prop models to Loader
|
||||||
let mut prop_models=bsp.static_props().map(|prop|{
|
let mut prop_models=bsp.static_props().map(|prop|{
|
||||||
@@ -167,7 +194,11 @@ pub fn convert<'a>(
|
|||||||
model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list))
|
model::PolygonGroup::PolygonList(model::PolygonList::new(polygon_list))
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
mb.build(polygon_groups,graphics_groups,vec![])
|
let physics_groups=vec![model::IndexedPhysicsGroup{
|
||||||
|
groups:(0..world_model.face_count as u32).map(model::PolygonGroupId::new).collect(),
|
||||||
|
}];
|
||||||
|
|
||||||
|
mb.build(polygon_groups,graphics_groups,physics_groups)
|
||||||
}).collect();
|
}).collect();
|
||||||
|
|
||||||
let mut found_spawn=None;
|
let mut found_spawn=None;
|
||||||
@@ -182,52 +213,204 @@ pub fn convert<'a>(
|
|||||||
color:glam::Vec4::W,
|
color:glam::Vec4::W,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// THE CUBE OF DESTINY
|
||||||
|
let destination_mesh_id=model::MeshId::new(world_meshes.len() as u32);
|
||||||
|
world_meshes.push(crate::brush::unit_cube());
|
||||||
|
|
||||||
const WHITE:vbsp::Color=vbsp::Color{r:255,g:255,b:255};
|
const WHITE:vbsp::Color=vbsp::Color{r:255,g:255,b:255};
|
||||||
|
const ENTITY_ATTRIBUTE:gameplay_attributes::CollisionAttributesId=ATTRIBUTE_CONTACT_DEFAULT;
|
||||||
|
const ENTITY_TRIGGER_ATTRIBUTE:gameplay_attributes::CollisionAttributesId=ATTRIBUTE_INTERSECT_DEFAULT;
|
||||||
for raw_ent in &bsp.entities{
|
for raw_ent in &bsp.entities{
|
||||||
|
macro_rules! ent_brush_default{
|
||||||
|
($entity:ident)=>{
|
||||||
|
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,$entity.rendercolor,ENTITY_ATTRIBUTE)
|
||||||
|
};
|
||||||
|
} macro_rules! ent_brush_prop{
|
||||||
|
($entity:ident)=>{
|
||||||
|
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,WHITE,ENTITY_ATTRIBUTE)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
macro_rules! ent_brush_trigger{
|
||||||
|
($entity:ident)=>{
|
||||||
|
add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,$entity.model,$entity.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE)
|
||||||
|
};
|
||||||
|
}
|
||||||
match raw_ent.parse(){
|
match raw_ent.parse(){
|
||||||
Ok(Entity::Cycler(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::AmbientGeneric(_ambient_generic))=>(),
|
||||||
Ok(Entity::EnvSprite(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::Cycler(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncBreakable(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::EnvBeam(_env_beam))=>(),
|
||||||
Ok(Entity::FuncBrush(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::EnvBubbles(_env_bubbles))=>(),
|
||||||
Ok(Entity::FuncButton(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::EnvDetailController(_env_detail_controller))=>(),
|
||||||
Ok(Entity::FuncDoor(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::EnvEmbers(_env_embers))=>(),
|
||||||
Ok(Entity::FuncDoorRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::EnvEntityMaker(_env_entity_maker))=>(),
|
||||||
|
Ok(Entity::EnvExplosion(_env_explosion))=>(),
|
||||||
|
Ok(Entity::EnvFade(_env_fade))=>(),
|
||||||
|
Ok(Entity::EnvFire(_env_fire))=>(),
|
||||||
|
Ok(Entity::EnvFireTrail(_env_fire_trail))=>(),
|
||||||
|
Ok(Entity::EnvFiresource(_env_firesource))=>(),
|
||||||
|
Ok(Entity::EnvFogController(_env_fog_controller))=>(),
|
||||||
|
Ok(Entity::EnvHudhint(_env_hudhint))=>(),
|
||||||
|
Ok(Entity::EnvLaser(_env_laser))=>(),
|
||||||
|
Ok(Entity::EnvLightglow(_env_lightglow))=>(),
|
||||||
|
Ok(Entity::EnvPhysexplosion(_env_physexplosion))=>(),
|
||||||
|
Ok(Entity::EnvProjectedtexture(_env_projectedtexture))=>(),
|
||||||
|
Ok(Entity::EnvScreenoverlay(_env_screenoverlay))=>(),
|
||||||
|
Ok(Entity::EnvShake(_env_shake))=>(),
|
||||||
|
Ok(Entity::EnvShooter(_env_shooter))=>(),
|
||||||
|
Ok(Entity::EnvSmokestack(_env_smokestack))=>(),
|
||||||
|
Ok(Entity::EnvSoundscape(_env_soundscape))=>(),
|
||||||
|
Ok(Entity::EnvSoundscapeProxy(_env_soundscape_proxy))=>(),
|
||||||
|
Ok(Entity::EnvSoundscapeTriggerable(_env_soundscape_triggerable))=>(),
|
||||||
|
Ok(Entity::EnvSpark(_env_spark))=>(),
|
||||||
|
Ok(Entity::EnvSprite(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::EnvSpritetrail(_env_spritetrail))=>(),
|
||||||
|
Ok(Entity::EnvSteam(_env_steam))=>(),
|
||||||
|
Ok(Entity::EnvSun(_env_sun))=>(),
|
||||||
|
Ok(Entity::EnvTonemapController(_env_tonemap_controller))=>(),
|
||||||
|
Ok(Entity::EnvWind(_env_wind))=>(),
|
||||||
|
// trigger_teleport.filtername probably has to do with one of these
|
||||||
|
Ok(Entity::FilterActivatorClass(_filter_activator_class))=>(),
|
||||||
|
Ok(Entity::FilterActivatorName(_filter_activator_name))=>(),
|
||||||
|
Ok(Entity::FilterDamageType(_filter_damage_type))=>(),
|
||||||
|
Ok(Entity::FilterMulti(_filter_multi))=>(),
|
||||||
|
Ok(Entity::FuncAreaportal(_func_areaportal))=>(),
|
||||||
|
Ok(Entity::FuncAreaportalwindow(_func_areaportalwindow))=>(),
|
||||||
|
Ok(Entity::FuncBombTarget(_func_bomb_target))=>(),
|
||||||
|
Ok(Entity::FuncBreakable(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::FuncBreakableSurf(_func_breakable_surf))=>(),
|
||||||
|
Ok(Entity::FuncBrush(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::FuncButton(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::FuncBuyzone(_func_buyzone))=>(),
|
||||||
|
Ok(Entity::FuncClipVphysics(_func_clip_vphysics))=>(),
|
||||||
|
Ok(Entity::FuncConveyor(_func_conveyor))=>(),
|
||||||
|
// FuncDoor is Platform
|
||||||
|
Ok(Entity::FuncDoor(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::FuncDoorRotating(brush))=>ent_brush_default!(brush),
|
||||||
|
Ok(Entity::FuncDustcloud(_func_dustcloud))=>(),
|
||||||
|
Ok(Entity::FuncDustmotes(_func_dustmotes))=>(),
|
||||||
|
Ok(Entity::FuncFishPool(_func_fish_pool))=>(),
|
||||||
|
Ok(Entity::FuncFootstepControl(_func_footstep_control))=>(),
|
||||||
|
Ok(Entity::FuncHostageRescue(_func_hostage_rescue))=>(),
|
||||||
Ok(Entity::FuncIllusionary(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncIllusionary(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
||||||
Ok(Entity::FuncMonitor(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncLod(_func_lod))=>(),
|
||||||
Ok(Entity::FuncMovelinear(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncMonitor(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncPhysbox(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncMovelinear(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncPhysboxMultiplayer(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncOccluder(_func_occluder))=>(),
|
||||||
Ok(Entity::FuncRotButton(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncPhysbox(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncPhysboxMultiplayer(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncTracktrain(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncPrecipitation(_func_precipitation))=>(),
|
||||||
Ok(Entity::FuncTrain(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncRotButton(brush))=>ent_brush_prop!(brush),
|
||||||
Ok(Entity::FuncWall(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncRotating(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::FuncWallToggle(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncSmokevolume(_func_smokevolume))=>(),
|
||||||
Ok(Entity::FuncWaterAnalog(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor.unwrap_or(WHITE),ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncTracktrain(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::PropDoorRotating(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncTrain(brush))=>ent_brush_default!(brush),
|
||||||
Ok(Entity::PropDynamic(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncWall(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ENTITY_ATTRIBUTE),
|
||||||
Ok(Entity::PropDynamicOverride(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncWallToggle(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin.unwrap_or_default(),brush.rendercolor,ENTITY_ATTRIBUTE),
|
||||||
Ok(Entity::PropPhysics(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::FuncWaterAnalog(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,brush.rendercolor.unwrap_or(WHITE),ENTITY_ATTRIBUTE),
|
||||||
Ok(Entity::PropPhysicsMultiplayer(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::GamePlayerEquip(_game_player_equip))=>(),
|
||||||
Ok(Entity::PropPhysicsOverride(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::GameText(_game_text))=>(),
|
||||||
Ok(Entity::PropRagdoll(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::GameUi(_game_ui))=>(),
|
||||||
Ok(Entity::TriggerGravity(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::GameWeaponManager(_game_weapon_manager))=>(),
|
||||||
Ok(Entity::TriggerHurt(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::HostageEntity(_hostage_entity))=>(),
|
||||||
Ok(Entity::TriggerLook(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoCameraLink(_info_camera_link))=>(),
|
||||||
Ok(Entity::TriggerMultiple(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoLadder(_info_ladder))=>(),
|
||||||
Ok(Entity::TriggerOnce(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoLightingRelative(_info_lighting_relative))=>(),
|
||||||
Ok(Entity::TriggerProximity(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoMapParameters(_info_map_parameters))=>(),
|
||||||
Ok(Entity::TriggerPush(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoNode(_info_node))=>(),
|
||||||
Ok(Entity::TriggerSoundscape(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoNodeHint(_info_node_hint))=>(),
|
||||||
Ok(Entity::TriggerTeleport(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoParticleSystem(_info_particle_system))=>(),
|
||||||
Ok(Entity::TriggerVphysicsMotion(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoPlayerCounterterrorist(spawn))=>found_spawn=Some(spawn.origin),
|
||||||
Ok(Entity::TriggerWind(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model,brush.origin,WHITE,ATTRIBUTE_DECORATION),
|
Ok(Entity::InfoPlayerLogo(_info_player_logo))=>(),
|
||||||
Ok(Entity::InfoPlayerCounterterrorist(spawn))=>{
|
Ok(Entity::InfoPlayerStart(_info_player_start))=>(),
|
||||||
found_spawn=Some(valve_transform(spawn.origin.into()));
|
Ok(Entity::InfoPlayerTerrorist(spawn))=>found_spawn=Some(spawn.origin),
|
||||||
},
|
Ok(Entity::InfoTarget(_info_target))=>(),
|
||||||
Ok(Entity::InfoPlayerTerrorist(spawn))=>{
|
// InfoTeleportDestination is Spawn#
|
||||||
found_spawn=Some(valve_transform(spawn.origin.into()));
|
Ok(Entity::InfoTeleportDestination(_info_teleport_destination))=>(),
|
||||||
},
|
Ok(Entity::Infodecal(_infodecal))=>(),
|
||||||
|
Ok(Entity::KeyframeRope(_keyframe_rope))=>(),
|
||||||
|
Ok(Entity::Light(_light))=>(),
|
||||||
|
Ok(Entity::LightEnvironment(_light_environment))=>(),
|
||||||
|
Ok(Entity::LightSpot(_light_spot))=>(),
|
||||||
|
Ok(Entity::LogicAuto(_logic_auto))=>(),
|
||||||
|
Ok(Entity::LogicBranch(_logic_branch))=>(),
|
||||||
|
Ok(Entity::LogicCase(_logic_case))=>(),
|
||||||
|
Ok(Entity::LogicCompare(_logic_compare))=>(),
|
||||||
|
Ok(Entity::LogicMeasureMovement(_logic_measure_movement))=>(),
|
||||||
|
Ok(Entity::LogicRelay(_logic_relay))=>(),
|
||||||
|
Ok(Entity::LogicTimer(_logic_timer))=>(),
|
||||||
|
Ok(Entity::MathCounter(_math_counter))=>(),
|
||||||
|
Ok(Entity::MoveRope(_move_rope))=>(),
|
||||||
|
Ok(Entity::PathTrack(_path_track))=>(),
|
||||||
|
Ok(Entity::PhysBallsocket(_phys_ballsocket))=>(),
|
||||||
|
Ok(Entity::PhysConstraint(_phys_constraint))=>(),
|
||||||
|
Ok(Entity::PhysConstraintsystem(_phys_constraintsystem))=>(),
|
||||||
|
Ok(Entity::PhysHinge(_phys_hinge))=>(),
|
||||||
|
Ok(Entity::PhysKeepupright(_phys_keepupright))=>(),
|
||||||
|
Ok(Entity::PhysLengthconstraint(_phys_lengthconstraint))=>(),
|
||||||
|
Ok(Entity::PhysPulleyconstraint(_phys_pulleyconstraint))=>(),
|
||||||
|
Ok(Entity::PhysRagdollconstraint(_phys_ragdollconstraint))=>(),
|
||||||
|
Ok(Entity::PhysRagdollmagnet(_phys_ragdollmagnet))=>(),
|
||||||
|
Ok(Entity::PhysThruster(_phys_thruster))=>(),
|
||||||
|
Ok(Entity::PhysTorque(_phys_torque))=>(),
|
||||||
|
Ok(Entity::PlayerSpeedmod(_player_speedmod))=>(),
|
||||||
|
Ok(Entity::PlayerWeaponstrip(_player_weaponstrip))=>(),
|
||||||
|
Ok(Entity::PointCamera(_point_camera))=>(),
|
||||||
|
Ok(Entity::PointClientcommand(_point_clientcommand))=>(),
|
||||||
|
Ok(Entity::PointDevshotCamera(_point_devshot_camera))=>(),
|
||||||
|
Ok(Entity::PointServercommand(_point_servercommand))=>(),
|
||||||
|
Ok(Entity::PointSpotlight(_point_spotlight))=>(),
|
||||||
|
Ok(Entity::PointSurroundtest(_point_surroundtest))=>(),
|
||||||
|
Ok(Entity::PointTemplate(_point_template))=>(),
|
||||||
|
Ok(Entity::PointTesla(_point_tesla))=>(),
|
||||||
|
Ok(Entity::PointViewcontrol(_point_viewcontrol))=>(),
|
||||||
|
Ok(Entity::PropDoorRotating(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropDynamic(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropDynamicOverride(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropPhysics(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropPhysicsMultiplayer(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropPhysicsOverride(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::PropRagdoll(brush))=>ent_brush_prop!(brush),
|
||||||
|
Ok(Entity::ShadowControl(_shadow_control))=>(),
|
||||||
|
Ok(Entity::SkyCamera(_sky_camera))=>(),
|
||||||
|
Ok(Entity::TriggerGravity(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerHurt(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerLook(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerMultiple(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE),
|
||||||
|
Ok(Entity::TriggerOnce(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerProximity(brush))=>ent_brush_trigger!(brush),
|
||||||
|
// TriggerPush is booster
|
||||||
|
Ok(Entity::TriggerPush(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerSoundscape(brush))=>ent_brush_trigger!(brush),
|
||||||
|
// TriggerTeleport is Trigger#
|
||||||
|
Ok(Entity::TriggerTeleport(brush))=>add_brush(mesh_deferred_loader,&mut world_models,&mut prop_models,brush.model.unwrap_or_default(),brush.origin,WHITE,ENTITY_TRIGGER_ATTRIBUTE),
|
||||||
|
Ok(Entity::TriggerVphysicsMotion(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::TriggerWind(brush))=>ent_brush_trigger!(brush),
|
||||||
|
Ok(Entity::WaterLodControl(_water_lod_control))=>(),
|
||||||
|
Ok(Entity::WeaponAk47(_weapon_ak47))=>(),
|
||||||
|
Ok(Entity::WeaponAwp(_weapon_awp))=>(),
|
||||||
|
Ok(Entity::WeaponDeagle(_weapon_deagle))=>(),
|
||||||
|
Ok(Entity::WeaponElite(_weapon_elite))=>(),
|
||||||
|
Ok(Entity::WeaponFamas(_weapon_famas))=>(),
|
||||||
|
Ok(Entity::WeaponFiveseven(_weapon_fiveseven))=>(),
|
||||||
|
Ok(Entity::WeaponFlashbang(_weapon_flashbang))=>(),
|
||||||
|
Ok(Entity::WeaponG3sg1(_weapon_g3sg1))=>(),
|
||||||
|
Ok(Entity::WeaponGlock(_weapon_glock))=>(),
|
||||||
|
Ok(Entity::WeaponHegrenade(_weapon_hegrenade))=>(),
|
||||||
|
Ok(Entity::WeaponKnife(_weapon_knife))=>(),
|
||||||
|
Ok(Entity::WeaponM249(_weapon_m249))=>(),
|
||||||
|
Ok(Entity::WeaponM3(_weapon_m3))=>(),
|
||||||
|
Ok(Entity::WeaponM4a1(_weapon_m4a1))=>(),
|
||||||
|
Ok(Entity::WeaponMac10(_weapon_mac10))=>(),
|
||||||
|
Ok(Entity::WeaponP228(_weapon_p228))=>(),
|
||||||
|
Ok(Entity::WeaponP90(_weapon_p90))=>(),
|
||||||
|
Ok(Entity::WeaponScout(_weapon_scout))=>(),
|
||||||
|
Ok(Entity::WeaponSg550(_weapon_sg550))=>(),
|
||||||
|
Ok(Entity::WeaponSmokegrenade(_weapon_smokegrenade))=>(),
|
||||||
|
Ok(Entity::WeaponTmp(_weapon_tmp))=>(),
|
||||||
|
Ok(Entity::WeaponUmp45(_weapon_ump45))=>(),
|
||||||
|
Ok(Entity::WeaponUsp(_weapon_usp))=>(),
|
||||||
|
Ok(Entity::WeaponXm1014(_weapon_xm1014))=>(),
|
||||||
|
Ok(Entity::Worldspawn(_worldspawn))=>(),
|
||||||
Err(e)=>{
|
Err(e)=>{
|
||||||
println!("Bsp Entity parse error: {e}");
|
println!("Bsp Entity parse error: {e}");
|
||||||
},
|
},
|
||||||
@@ -237,9 +420,27 @@ pub fn convert<'a>(
|
|||||||
|
|
||||||
// physics models
|
// physics models
|
||||||
for brush in &bsp.brushes{
|
for brush in &bsp.brushes{
|
||||||
if !brush.flags.contains(vbsp::BrushFlags::SOLID){
|
const RELEVANT:vbsp::BrushFlags=
|
||||||
|
vbsp::BrushFlags::SOLID
|
||||||
|
.union(vbsp::BrushFlags::PLAYERCLIP)
|
||||||
|
.union(vbsp::BrushFlags::WATER)
|
||||||
|
.union(vbsp::BrushFlags::MOVEABLE)
|
||||||
|
.union(vbsp::BrushFlags::LADDER);
|
||||||
|
if !brush.flags.intersects(RELEVANT){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
let is_ladder=brush.flags.contains(vbsp::BrushFlags::LADDER);
|
||||||
|
let is_water=brush.flags.contains(vbsp::BrushFlags::WATER);
|
||||||
|
let attributes=match (is_ladder,is_water){
|
||||||
|
(true,false)=>ATTRIBUTE_LADDER_DEFAULT,
|
||||||
|
(false,true)=>ATTRIBUTE_WATER_DEFAULT,
|
||||||
|
(false,false)=>ATTRIBUTE_CONTACT_DEFAULT,
|
||||||
|
(true,true)=>{
|
||||||
|
// water ladder? wtf
|
||||||
|
println!("brush is a water ladder o_o defaulting to ladder");
|
||||||
|
ATTRIBUTE_LADDER_DEFAULT
|
||||||
|
}
|
||||||
|
};
|
||||||
let mesh_result=crate::brush::brush_to_mesh(bsp,brush);
|
let mesh_result=crate::brush::brush_to_mesh(bsp,brush);
|
||||||
match mesh_result{
|
match mesh_result{
|
||||||
Ok(mesh)=>{
|
Ok(mesh)=>{
|
||||||
@@ -247,7 +448,7 @@ pub fn convert<'a>(
|
|||||||
world_meshes.push(mesh);
|
world_meshes.push(mesh);
|
||||||
world_models.push(model::Model{
|
world_models.push(model::Model{
|
||||||
mesh:mesh_id,
|
mesh:mesh_id,
|
||||||
attributes:ATTRIBUTE_CONTACT_DEFAULT,
|
attributes,
|
||||||
transform:integer::Planar64Affine3::new(
|
transform:integer::Planar64Affine3::new(
|
||||||
integer::mat3::identity(),
|
integer::mat3::identity(),
|
||||||
integer::vec3::ZERO,
|
integer::vec3::ZERO,
|
||||||
@@ -261,15 +462,12 @@ pub fn convert<'a>(
|
|||||||
|
|
||||||
let mut modes_list=Vec::new();
|
let mut modes_list=Vec::new();
|
||||||
if let Some(spawn_point)=found_spawn{
|
if let Some(spawn_point)=found_spawn{
|
||||||
// create a new mesh
|
|
||||||
let mesh_id=model::MeshId::new(world_meshes.len() as u32);
|
|
||||||
world_meshes.push(crate::brush::unit_cube());
|
|
||||||
// create a new model
|
// create a new model
|
||||||
let model_id=model::ModelId::new(world_models.len() as u32);
|
let model_id=model::ModelId::new(world_models.len() as u32);
|
||||||
world_models.push(model::Model{
|
world_models.push(model::Model{
|
||||||
mesh:mesh_id,
|
mesh:destination_mesh_id,
|
||||||
attributes:ATTRIBUTE_INTERSECT_DEFAULT,
|
attributes:ATTRIBUTE_INTERSECT_DEFAULT,
|
||||||
transform:integer::Planar64Affine3::from_translation(spawn_point),
|
transform:integer::Planar64Affine3::from_translation(valve_transform(spawn_point.into())),
|
||||||
color:glam::Vec4::W,
|
color:glam::Vec4::W,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -295,7 +493,7 @@ pub fn convert<'a>(
|
|||||||
|
|
||||||
//partially constructed map types
|
//partially constructed map types
|
||||||
pub struct PartialMap1{
|
pub struct PartialMap1{
|
||||||
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
attributes:Vec<attr::CollisionAttributes>,
|
||||||
prop_models:Vec<model::Model>,
|
prop_models:Vec<model::Model>,
|
||||||
world_meshes:Vec<model::Mesh>,
|
world_meshes:Vec<model::Mesh>,
|
||||||
world_models:Vec<model::Model>,
|
world_models:Vec<model::Model>,
|
||||||
@@ -317,7 +515,7 @@ impl PartialMap1{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub struct PartialMap2{
|
pub struct PartialMap2{
|
||||||
attributes:Vec<strafesnet_common::gameplay_attributes::CollisionAttributes>,
|
attributes:Vec<attr::CollisionAttributes>,
|
||||||
prop_meshes:Vec<(model::MeshId,model::Mesh)>,
|
prop_meshes:Vec<(model::MeshId,model::Mesh)>,
|
||||||
prop_models:Vec<model::Model>,
|
prop_models:Vec<model::Model>,
|
||||||
world_meshes:Vec<model::Mesh>,
|
world_meshes:Vec<model::Mesh>,
|
||||||
|
|||||||
@@ -529,12 +529,12 @@ impl StyleModifiers{
|
|||||||
|
|
||||||
pub fn source_bhop()->Self{
|
pub fn source_bhop()->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_mask:Controls::all()-Controls::MoveUp-Controls::MoveDown,
|
controls_mask:Controls::all(),
|
||||||
controls_mask_state:Controls::all(),
|
controls_mask_state:Controls::all(),
|
||||||
strafe:Some(StrafeSettings{
|
strafe:Some(StrafeSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
enable:ControlsActivation::full_2d(),
|
||||||
air_accel_limit:Some(Planar64::raw(150<<28)*100),
|
air_accel_limit:Some(Planar64::raw((150<<28)*100)),
|
||||||
mv:(Planar64::raw(30)*VALVE_SCALE).fix_1(),
|
mv:Planar64::raw(30<<28),
|
||||||
tick_rate:Ratio64::new(100,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(),
|
tick_rate:Ratio64::new(100,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(),
|
||||||
}),
|
}),
|
||||||
jump:Some(JumpSettings{
|
jump:Some(JumpSettings{
|
||||||
@@ -570,12 +570,12 @@ impl StyleModifiers{
|
|||||||
}
|
}
|
||||||
pub fn source_surf()->Self{
|
pub fn source_surf()->Self{
|
||||||
Self{
|
Self{
|
||||||
controls_mask:Controls::all()-Controls::MoveUp-Controls::MoveDown,
|
controls_mask:Controls::all(),
|
||||||
controls_mask_state:Controls::all(),
|
controls_mask_state:Controls::all(),
|
||||||
strafe:Some(StrafeSettings{
|
strafe:Some(StrafeSettings{
|
||||||
enable:ControlsActivation::full_2d(),
|
enable:ControlsActivation::full_2d(),
|
||||||
air_accel_limit:Some((int(150)*66*VALVE_SCALE).fix_1()),
|
air_accel_limit:Some((int(150)*66*VALVE_SCALE).fix_1()),
|
||||||
mv:(int(30)*VALVE_SCALE).fix_1(),
|
mv:Planar64::raw(30<<28),
|
||||||
tick_rate:Ratio64::new(66,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(),
|
tick_rate:Ratio64::new(66,AbsoluteTime::ONE_SECOND.get() as u64).unwrap(),
|
||||||
}),
|
}),
|
||||||
jump:Some(JumpSettings{
|
jump:Some(JumpSettings{
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ source = ["dep:strafesnet_deferred_loader", "dep:strafesnet_bsp_loader"]
|
|||||||
roblox = ["dep:strafesnet_deferred_loader", "dep:strafesnet_rbx_loader"]
|
roblox = ["dep:strafesnet_deferred_loader", "dep:strafesnet_rbx_loader"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.39"
|
|
||||||
glam = "0.30.0"
|
glam = "0.30.0"
|
||||||
parking_lot = "0.12.1"
|
parking_lot = "0.12.1"
|
||||||
pollster = "0.4.0"
|
pollster = "0.4.0"
|
||||||
@@ -29,8 +28,5 @@ strafesnet_rbx_loader = { path = "../lib/rbx_loader", registry = "strafesnet", o
|
|||||||
strafesnet_session = { path = "../engine/session", registry = "strafesnet" }
|
strafesnet_session = { path = "../engine/session", registry = "strafesnet" }
|
||||||
strafesnet_settings = { path = "../engine/settings", registry = "strafesnet" }
|
strafesnet_settings = { path = "../engine/settings", registry = "strafesnet" }
|
||||||
strafesnet_snf = { path = "../lib/snf", registry = "strafesnet", optional = true }
|
strafesnet_snf = { path = "../lib/snf", registry = "strafesnet", optional = true }
|
||||||
wasm-bindgen = "0.2.99"
|
|
||||||
wasm-bindgen-futures = "0.4.49"
|
|
||||||
web-sys = { version = "0.3.76", features = ["console"] }
|
|
||||||
wgpu = "24.0.0"
|
wgpu = "24.0.0"
|
||||||
winit = "0.30.7"
|
winit = "0.30.7"
|
||||||
|
|||||||
@@ -4,12 +4,12 @@ use strafesnet_common::instruction::TimedInstruction;
|
|||||||
use strafesnet_common::session::Time as SessionTime;
|
use strafesnet_common::session::Time as SessionTime;
|
||||||
|
|
||||||
pub struct App<'a>{
|
pub struct App<'a>{
|
||||||
root_time:chrono::DateTime<chrono::Utc>,
|
root_time:std::time::Instant,
|
||||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||||
}
|
}
|
||||||
impl<'a> App<'a>{
|
impl<'a> App<'a>{
|
||||||
pub fn new(
|
pub fn new(
|
||||||
root_time:chrono::DateTime<chrono::Utc>,
|
root_time:std::time::Instant,
|
||||||
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
window_thread:crate::compat_worker::QNWorker<'a,TimedInstruction<Instruction,SessionTime>>,
|
||||||
)->App<'a>{
|
)->App<'a>{
|
||||||
Self{
|
Self{
|
||||||
@@ -18,7 +18,7 @@ impl<'a> App<'a>{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn send_timed_instruction(&mut self,instruction:Instruction){
|
fn send_timed_instruction(&mut self,instruction:Instruction){
|
||||||
let time=integer::Time::from_nanos((chrono::Utc::now()-self.root_time).num_nanoseconds().unwrap());
|
let time=integer::Time::from_nanos(self.root_time.elapsed().as_nanos() as i64);
|
||||||
self.window_thread.send(TimedInstruction{time,instruction}).unwrap();
|
self.window_thread.send(TimedInstruction{time,instruction}).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ pub type INWorker<'a,Task>=CompatNWorker<'a,Task>;
|
|||||||
|
|
||||||
pub struct CompatNWorker<'a,Task>{
|
pub struct CompatNWorker<'a,Task>{
|
||||||
data:std::marker::PhantomData<Task>,
|
data:std::marker::PhantomData<Task>,
|
||||||
f:Box<dyn FnMut(Task)+'a>,
|
f:Box<dyn FnMut(Task)+Send+'a>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a,Task> CompatNWorker<'a,Task>{
|
impl<'a,Task> CompatNWorker<'a,Task>{
|
||||||
pub fn new(f:impl FnMut(Task)+'a)->CompatNWorker<'a,Task>{
|
pub fn new(f:impl FnMut(Task)+Send+'a)->CompatNWorker<'a,Task>{
|
||||||
Self{
|
Self{
|
||||||
data:std::marker::PhantomData,
|
data:std::marker::PhantomData,
|
||||||
f:Box::new(f),
|
f:Box::new(f),
|
||||||
|
|||||||
@@ -18,9 +18,6 @@ WorkerDescription{
|
|||||||
*/
|
*/
|
||||||
//up to three frames in flight, dropping new frame requests when all three are busy, and dropping output frames when one renders out of order
|
//up to three frames in flight, dropping new frame requests when all three are busy, and dropping output frames when one renders out of order
|
||||||
|
|
||||||
fn print(message:&str){
|
|
||||||
web_sys::console::log_1(&message.into());
|
|
||||||
}
|
|
||||||
pub fn new(
|
pub fn new(
|
||||||
mut graphics:graphics::GraphicsState,
|
mut graphics:graphics::GraphicsState,
|
||||||
mut config:wgpu::SurfaceConfiguration,
|
mut config:wgpu::SurfaceConfiguration,
|
||||||
@@ -36,20 +33,12 @@ pub fn new(
|
|||||||
},
|
},
|
||||||
Instruction::Resize(size,user_settings)=>{
|
Instruction::Resize(size,user_settings)=>{
|
||||||
println!("Resizing to {:?}",size);
|
println!("Resizing to {:?}",size);
|
||||||
//let t0=std::time::Instant::now();
|
let t0=std::time::Instant::now();
|
||||||
match size{
|
config.width=size.width.max(1);
|
||||||
winit::dpi::PhysicalSize{width:2560,height:1440}=>{
|
config.height=size.height.max(1);
|
||||||
config.width=size.width.clamp(1,2560);
|
|
||||||
config.height=size.height.clamp(1,1440);
|
|
||||||
},
|
|
||||||
_=>{
|
|
||||||
config.width=size.width.clamp(1,1280);
|
|
||||||
config.height=size.height.clamp(1,720);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
surface.configure(&device,&config);
|
surface.configure(&device,&config);
|
||||||
graphics.resize(&device,&config,&user_settings);
|
graphics.resize(&device,&config,&user_settings);
|
||||||
//println!("Resize took {:?}",t0.elapsed());
|
println!("Resize took {:?}",t0.elapsed());
|
||||||
}
|
}
|
||||||
Instruction::Render(frame_state)=>{
|
Instruction::Render(frame_state)=>{
|
||||||
//this has to go deeper somehow
|
//this has to go deeper somehow
|
||||||
|
|||||||
@@ -9,8 +9,5 @@ mod graphics_worker;
|
|||||||
const TITLE:&'static str=concat!("Strafe Client v",env!("CARGO_PKG_VERSION"));
|
const TITLE:&'static str=concat!("Strafe Client v",env!("CARGO_PKG_VERSION"));
|
||||||
|
|
||||||
fn main(){
|
fn main(){
|
||||||
#[cfg(target_arch="wasm32")]
|
setup::setup_and_start(TITLE);
|
||||||
wasm_bindgen_futures::spawn_local(setup::setup_and_start(TITLE));
|
|
||||||
#[cfg(not(target_arch="wasm32"))]
|
|
||||||
pollster::block_on(setup::setup_and_start(TITLE));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,16 +20,6 @@ struct SetupContextPartial1{
|
|||||||
fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Result<winit::window::Window,winit::error::OsError>{
|
fn create_window(title:&str,event_loop:&winit::event_loop::EventLoop<()>)->Result<winit::window::Window,winit::error::OsError>{
|
||||||
let mut attr=winit::window::WindowAttributes::default();
|
let mut attr=winit::window::WindowAttributes::default();
|
||||||
attr=attr.with_title(title);
|
attr=attr.with_title(title);
|
||||||
#[cfg(target_arch="wasm32")]
|
|
||||||
{
|
|
||||||
use wasm_bindgen::JsCast;
|
|
||||||
use winit::platform::web::WindowAttributesExtWebSys;
|
|
||||||
let canvas=web_sys::window().unwrap()
|
|
||||||
.document().unwrap()
|
|
||||||
.get_element_by_id("canvas").unwrap()
|
|
||||||
.dyn_into::<web_sys::HtmlCanvasElement>().unwrap();
|
|
||||||
attr=attr.with_canvas(Some(canvas));
|
|
||||||
}
|
|
||||||
event_loop.create_window(attr)
|
event_loop.create_window(attr)
|
||||||
}
|
}
|
||||||
fn create_instance()->SetupContextPartial1{
|
fn create_instance()->SetupContextPartial1{
|
||||||
@@ -54,18 +44,36 @@ struct SetupContextPartial2<'a>{
|
|||||||
surface:wgpu::Surface<'a>,
|
surface:wgpu::Surface<'a>,
|
||||||
}
|
}
|
||||||
impl<'a> SetupContextPartial2<'a>{
|
impl<'a> SetupContextPartial2<'a>{
|
||||||
async fn pick_adapter(self)->SetupContextPartial3<'a>{
|
fn pick_adapter(self)->SetupContextPartial3<'a>{
|
||||||
let adapter;
|
let adapter;
|
||||||
|
|
||||||
//TODO: prefer adapter that implements optional features
|
//TODO: prefer adapter that implements optional features
|
||||||
//let optional_features=optional_features();
|
//let optional_features=optional_features();
|
||||||
let required_features=required_features();
|
let required_features=required_features();
|
||||||
|
|
||||||
let chosen_adapter=self.instance.request_adapter(&wgpu::RequestAdapterOptions{
|
//no helper function smh gotta write it myself
|
||||||
power_preference:wgpu::PowerPreference::HighPerformance,
|
let adapters=self.instance.enumerate_adapters(self.backends);
|
||||||
force_fallback_adapter:false,
|
|
||||||
compatible_surface:Some(&self.surface),
|
let mut chosen_adapter=None;
|
||||||
}).await;
|
let mut chosen_adapter_score=0;
|
||||||
|
for adapter in adapters {
|
||||||
|
if !adapter.is_surface_supported(&self.surface) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let score=match adapter.get_info().device_type{
|
||||||
|
wgpu::DeviceType::IntegratedGpu=>3,
|
||||||
|
wgpu::DeviceType::DiscreteGpu=>4,
|
||||||
|
wgpu::DeviceType::VirtualGpu=>2,
|
||||||
|
wgpu::DeviceType::Other|wgpu::DeviceType::Cpu=>1,
|
||||||
|
};
|
||||||
|
|
||||||
|
let adapter_features=adapter.features();
|
||||||
|
if chosen_adapter_score<score&&adapter_features.contains(required_features) {
|
||||||
|
chosen_adapter_score=score;
|
||||||
|
chosen_adapter=Some(adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
if let Some(maybe_chosen_adapter)=chosen_adapter{
|
||||||
adapter=maybe_chosen_adapter;
|
adapter=maybe_chosen_adapter;
|
||||||
@@ -102,7 +110,7 @@ struct SetupContextPartial3<'a>{
|
|||||||
adapter:wgpu::Adapter,
|
adapter:wgpu::Adapter,
|
||||||
}
|
}
|
||||||
impl<'a> SetupContextPartial3<'a>{
|
impl<'a> SetupContextPartial3<'a>{
|
||||||
async fn request_device(self)->SetupContextPartial4<'a>{
|
fn request_device(self)->SetupContextPartial4<'a>{
|
||||||
let optional_features=optional_features();
|
let optional_features=optional_features();
|
||||||
let required_features=required_features();
|
let required_features=required_features();
|
||||||
|
|
||||||
@@ -110,7 +118,7 @@ impl<'a> SetupContextPartial3<'a>{
|
|||||||
let needed_limits=strafesnet_graphics::graphics::required_limits().using_resolution(self.adapter.limits());
|
let needed_limits=strafesnet_graphics::graphics::required_limits().using_resolution(self.adapter.limits());
|
||||||
|
|
||||||
let trace_dir=std::env::var("WGPU_TRACE");
|
let trace_dir=std::env::var("WGPU_TRACE");
|
||||||
let (device, queue)=self.adapter
|
let (device, queue)=pollster::block_on(self.adapter
|
||||||
.request_device(
|
.request_device(
|
||||||
&wgpu::DeviceDescriptor {
|
&wgpu::DeviceDescriptor {
|
||||||
label: None,
|
label: None,
|
||||||
@@ -119,7 +127,7 @@ impl<'a> SetupContextPartial3<'a>{
|
|||||||
memory_hints:wgpu::MemoryHints::Performance,
|
memory_hints:wgpu::MemoryHints::Performance,
|
||||||
},
|
},
|
||||||
trace_dir.ok().as_ref().map(std::path::Path::new),
|
trace_dir.ok().as_ref().map(std::path::Path::new),
|
||||||
).await
|
))
|
||||||
.expect("Unable to find a suitable GPU adapter!");
|
.expect("Unable to find a suitable GPU adapter!");
|
||||||
|
|
||||||
SetupContextPartial4{
|
SetupContextPartial4{
|
||||||
@@ -161,7 +169,7 @@ pub struct SetupContext<'a>{
|
|||||||
pub config:wgpu::SurfaceConfiguration,
|
pub config:wgpu::SurfaceConfiguration,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn setup_and_start(title:&str){
|
pub fn setup_and_start(title:&str){
|
||||||
let event_loop=winit::event_loop::EventLoop::new().unwrap();
|
let event_loop=winit::event_loop::EventLoop::new().unwrap();
|
||||||
|
|
||||||
println!("Initializing the surface...");
|
println!("Initializing the surface...");
|
||||||
@@ -172,9 +180,9 @@ pub async fn setup_and_start(title:&str){
|
|||||||
|
|
||||||
let partial_2=partial_1.create_surface(&window).unwrap();
|
let partial_2=partial_1.create_surface(&window).unwrap();
|
||||||
|
|
||||||
let partial_3=partial_2.pick_adapter().await;
|
let partial_3=partial_2.pick_adapter();
|
||||||
|
|
||||||
let partial_4=partial_3.request_device().await;
|
let partial_4=partial_3.request_device();
|
||||||
|
|
||||||
let size=window.inner_size();
|
let size=window.inner_size();
|
||||||
|
|
||||||
@@ -197,7 +205,7 @@ pub async fn setup_and_start(title:&str){
|
|||||||
|
|
||||||
println!("Entering event loop...");
|
println!("Entering event loop...");
|
||||||
let mut app=crate::app::App::new(
|
let mut app=crate::app::App::new(
|
||||||
chrono::Utc::now(),
|
std::time::Instant::now(),
|
||||||
window_thread
|
window_thread
|
||||||
);
|
);
|
||||||
event_loop.run_app(&mut app).unwrap();
|
event_loop.run_app(&mut app).unwrap();
|
||||||
|
|||||||
1
web-client/.gitignore
vendored
1
web-client/.gitignore
vendored
@@ -1 +0,0 @@
|
|||||||
/dist
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
[build]
|
|
||||||
target = "index.html"
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Strafe Client</title>
|
|
||||||
<style>
|
|
||||||
html, body {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
#wasm-container {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
canvas {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="wasm-container">
|
|
||||||
<canvas class="main-canvas" id="canvas"></canvas>
|
|
||||||
</div>
|
|
||||||
<link data-trunk rel="rust" href="../strafe-client/Cargo.toml"/>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Reference in New Issue
Block a user