Compare commits
6 Commits
scripts
...
recalculat
Author | SHA1 | Date | |
---|---|---|---|
da8492d559 | |||
46db92acd0 | |||
35076f5c17 | |||
63395d3928 | |||
ce47f01375 | |||
fb14e023df |
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -1587,9 +1587,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rbx_dom_weak"
|
||||
version = "2.9.0"
|
||||
version = "2.7.0"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "2a6b916687c98aaea36f9c03e80906bfafab057bebee248628c8c04def807f43"
|
||||
checksum = "850d0a6c8d22592b125c9a82f8654857a7aba10f061b930cc2b86438e54157f1"
|
||||
dependencies = [
|
||||
"rbx_types",
|
||||
"serde",
|
||||
@ -1607,9 +1607,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rbx_reflection"
|
||||
version = "4.7.0"
|
||||
version = "4.5.0"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "c1b43fe592a4ce6fe54eb215fb82735efbb516d2cc045a94e3dc0234ff293620"
|
||||
checksum = "80d31f6675c27c9f60b2322feb5565f4a4389ccbb75de4e737915e9208f0831f"
|
||||
dependencies = [
|
||||
"rbx_types",
|
||||
"serde",
|
||||
@ -1618,9 +1618,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rbx_reflection_database"
|
||||
version = "0.2.12+roblox-638"
|
||||
version = "0.2.10+roblox-607"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "2e772bb9e1bc0ebe65d338f876d1bb1ea22e15a8f9a82e8245028010c2fea3c9"
|
||||
checksum = "f4da9f73ca317c158b922b757fe02317f7d3bc31d3f9fdb4a748d48b3951b8b8"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
"rbx_reflection",
|
||||
@ -1630,9 +1630,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "rbx_types"
|
||||
version = "1.10.0"
|
||||
version = "1.8.0"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "d7a390c44034fa448c53bd0983dfc2d70d8d6b2f65be4f164d4bec8b6a2a2d09"
|
||||
checksum = "6d0d394018a8df53fcd91e990301fe6e47b94e15067edfcb019e6238ae60e8bb"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bitflags 1.3.2",
|
||||
@ -1912,9 +1912,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "strafesnet_common"
|
||||
version = "0.4.1"
|
||||
version = "0.4.0"
|
||||
source = "sparse+https://git.itzana.me/api/packages/strafesnet/cargo/"
|
||||
checksum = "9a2621612e675a8f804abbbbe3b60caeafe58a2422cccbe453268d6f457df4f3"
|
||||
checksum = "ea4126f6fbf9aecf89c9e319290f0221d177dcaa8659b4b9e3d82acc37829f12"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
"bitflags 2.6.0",
|
||||
|
@ -66,9 +66,7 @@ pub fn load<P:AsRef<std::path::Path>>(path:P)->Result<strafesnet_common::map::Co
|
||||
#[cfg(feature="snf")]
|
||||
DataStructure::StrafesNET(map)=>Ok(map),
|
||||
#[cfg(feature="roblox")]
|
||||
DataStructure::Roblox(mut dom)=>{
|
||||
dom=dom.run_scripts();
|
||||
|
||||
DataStructure::Roblox(dom)=>{
|
||||
let mut loader=strafesnet_deferred_loader::roblox_legacy();
|
||||
|
||||
let (texture_loader,mesh_loader)=loader.get_inner_mut();
|
||||
|
@ -6,6 +6,12 @@ use strafesnet_common::model::{self, ColorId, NormalId, PolygonIter, PositionId,
|
||||
use wgpu::{util::DeviceExt,AstcBlock,AstcChannel};
|
||||
use crate::model_graphics::{self,IndexedGraphicsMeshOwnedRenderConfig,IndexedGraphicsMeshOwnedRenderConfigId,GraphicsMeshOwnedRenderConfig,GraphicsModelColor4,GraphicsModelOwned,GraphicsVertex};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GraphicsModelUpdate{
|
||||
transform:Option<glam::Mat4>,
|
||||
color:Option<glam::Vec4>,
|
||||
}
|
||||
|
||||
struct Indices{
|
||||
count:u32,
|
||||
buf:wgpu::Buffer,
|
||||
@ -26,6 +32,7 @@ impl Indices{
|
||||
}
|
||||
struct GraphicsModel{
|
||||
indices:Indices,
|
||||
model_buf:wgpu::Buffer,
|
||||
vertex_buf:wgpu::Buffer,
|
||||
bind_group:wgpu::BindGroup,
|
||||
instance_count:u32,
|
||||
@ -58,12 +65,12 @@ struct GraphicsCamera{
|
||||
#[inline]
|
||||
fn perspective_rh(fov_x_slope:f32,fov_y_slope:f32,z_near:f32,z_far:f32)->glam::Mat4{
|
||||
//glam_assert!(z_near > 0.0 && z_far > 0.0);
|
||||
let r=z_far/(z_near-z_far);
|
||||
let r=z_far / (z_near-z_far);
|
||||
glam::Mat4::from_cols(
|
||||
glam::Vec4::new(1.0/fov_x_slope,0.0,0.0,0.0),
|
||||
glam::Vec4::new(0.0,1.0/fov_y_slope,0.0,0.0),
|
||||
glam::Vec4::new(0.0,0.0,r,-1.0),
|
||||
glam::Vec4::new(0.0,0.0,r*z_near,0.0),
|
||||
glam::Vec4::new(0.0,0.0,r * z_near,0.0),
|
||||
)
|
||||
}
|
||||
impl GraphicsCamera{
|
||||
@ -72,10 +79,10 @@ impl GraphicsCamera{
|
||||
}
|
||||
pub fn world(&self,pos:glam::Vec3,angles:glam::Vec2)->glam::Mat4{
|
||||
//f32 good enough for view matrix
|
||||
glam::Mat4::from_translation(pos)*glam::Mat4::from_euler(glam::EulerRot::YXZ,angles.x,angles.y,0f32)
|
||||
glam::Mat4::from_translation(pos) * glam::Mat4::from_euler(glam::EulerRot::YXZ,angles.x,angles.y,0f32)
|
||||
}
|
||||
|
||||
pub fn to_uniform_data(&self,pos:glam::Vec3,angles:glam::Vec2)->[f32;16*4]{
|
||||
pub fn to_uniform_data(&self,(pos,angles):(glam::Vec3,glam::Vec2))->[f32; 16 * 4]{
|
||||
let proj=self.proj();
|
||||
let proj_inv=proj.inverse();
|
||||
let view_inv=self.world(pos,angles);
|
||||
@ -98,12 +105,6 @@ impl std::default::Default for GraphicsCamera{
|
||||
}
|
||||
}
|
||||
|
||||
pub struct FrameState{
|
||||
pub body:crate::physics::Body,
|
||||
pub camera:crate::physics::PhysicsCamera,
|
||||
pub time:integer::Time,
|
||||
}
|
||||
|
||||
pub struct GraphicsState{
|
||||
pipelines:GraphicsPipelines,
|
||||
bind_groups:GraphicsBindGroups,
|
||||
@ -506,6 +507,7 @@ impl GraphicsState{
|
||||
model_graphics::Indices::U16(indices)=>Indices::new(device,indices,wgpu::IndexFormat::Uint16),
|
||||
},
|
||||
bind_group,
|
||||
model_buf,
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -814,7 +816,7 @@ impl GraphicsState{
|
||||
});
|
||||
|
||||
let camera=GraphicsCamera::default();
|
||||
let camera_uniforms=camera.to_uniform_data(glam::Vec3::ZERO,glam::Vec2::ZERO);
|
||||
let camera_uniforms=camera.to_uniform_data(crate::physics::PhysicsOutputState::default().extrapolate(strafesnet_common::mouse::MouseState::default()));
|
||||
let camera_buf=device.create_buffer_init(&wgpu::util::BufferInitDescriptor{
|
||||
label:Some("Camera"),
|
||||
contents:bytemuck::cast_slice(&camera_uniforms),
|
||||
@ -882,17 +884,16 @@ impl GraphicsState{
|
||||
view:&wgpu::TextureView,
|
||||
device:&wgpu::Device,
|
||||
queue:&wgpu::Queue,
|
||||
frame_state:FrameState,
|
||||
physics_output:crate::physics::PhysicsOutputState,
|
||||
predicted_time:integer::Time,
|
||||
mouse_pos:glam::IVec2,
|
||||
){
|
||||
//TODO:use scheduled frame times to create beautiful smoothing simulation physics extrapolation assuming no input
|
||||
|
||||
let mut encoder=device.create_command_encoder(&wgpu::CommandEncoderDescriptor{label:None});
|
||||
|
||||
// update rotation
|
||||
let camera_uniforms=self.camera.to_uniform_data(
|
||||
frame_state.body.extrapolated_position(frame_state.time).into(),
|
||||
frame_state.camera.simulate_move_angles(glam::IVec2::ZERO)
|
||||
);
|
||||
let camera_uniforms=self.camera.to_uniform_data(physics_output.extrapolate(strafesnet_common::mouse::MouseState{pos:mouse_pos,time:predicted_time}));
|
||||
self.staging_belt
|
||||
.write_buffer(
|
||||
&mut encoder,
|
||||
|
@ -1,5 +1,7 @@
|
||||
use strafesnet_common::integer;
|
||||
|
||||
pub enum Instruction{
|
||||
Render(crate::graphics::FrameState),
|
||||
Render(crate::physics::PhysicsOutputState,integer::Time,glam::IVec2),
|
||||
//UpdateModel(crate::graphics::GraphicsModelUpdate),
|
||||
Resize(winit::dpi::PhysicalSize<u32>,crate::settings::UserSettings),
|
||||
ChangeMap(strafesnet_common::map::CompleteMap),
|
||||
@ -15,12 +17,12 @@ 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
|
||||
|
||||
pub fn new<'a>(
|
||||
mut graphics:crate::graphics::GraphicsState,
|
||||
mut config:wgpu::SurfaceConfiguration,
|
||||
surface:wgpu::Surface<'a>,
|
||||
device:wgpu::Device,
|
||||
queue:wgpu::Queue,
|
||||
)->crate::compat_worker::INWorker<'a,Instruction>{
|
||||
mut graphics:crate::graphics::GraphicsState,
|
||||
mut config:wgpu::SurfaceConfiguration,
|
||||
surface:wgpu::Surface<'a>,
|
||||
device:wgpu::Device,
|
||||
queue:wgpu::Queue,
|
||||
)->crate::compat_worker::INWorker<'a,Instruction>{
|
||||
let mut resize=None;
|
||||
crate::compat_worker::INWorker::new(move |ins:Instruction|{
|
||||
match ins{
|
||||
@ -31,16 +33,18 @@ pub fn new<'a>(
|
||||
Instruction::Resize(size,user_settings)=>{
|
||||
resize=Some((size,user_settings));
|
||||
}
|
||||
Instruction::Render(frame_state)=>{
|
||||
if let Some((size,user_settings))=resize.take(){
|
||||
Instruction::Render(physics_output,predicted_time,mouse_pos)=>{
|
||||
if let Some((size,user_settings))=&resize{
|
||||
println!("Resizing to {:?}",size);
|
||||
let t0=std::time::Instant::now();
|
||||
config.width=size.width.max(1);
|
||||
config.height=size.height.max(1);
|
||||
surface.configure(&device,&config);
|
||||
graphics.resize(&device,&config,&user_settings);
|
||||
graphics.resize(&device,&config,user_settings);
|
||||
println!("Resize took {:?}",t0.elapsed());
|
||||
}
|
||||
//clear every time w/e
|
||||
resize=None;
|
||||
//this has to go deeper somehow
|
||||
let frame=match surface.get_current_texture(){
|
||||
Ok(frame)=>frame,
|
||||
@ -56,7 +60,7 @@ pub fn new<'a>(
|
||||
..wgpu::TextureViewDescriptor::default()
|
||||
});
|
||||
|
||||
graphics.render(&view,&device,&queue,frame_state);
|
||||
graphics.render(&view,&device,&queue,physics_output,predicted_time,mouse_pos);
|
||||
|
||||
frame.present();
|
||||
}
|
||||
|
@ -462,7 +462,7 @@ pub struct TransformedMesh<'a>{
|
||||
transform:&'a PhysicsMeshTransform,
|
||||
}
|
||||
impl TransformedMesh<'_>{
|
||||
pub const fn new<'a>(
|
||||
pub fn new<'a>(
|
||||
view:PhysicsMeshView<'a>,
|
||||
transform:&'a PhysicsMeshTransform,
|
||||
)->TransformedMesh<'a>{
|
||||
|
@ -419,7 +419,7 @@ impl HitboxMesh{
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
const fn transformed_mesh(&self)->TransformedMesh{
|
||||
fn transformed_mesh(&self)->TransformedMesh{
|
||||
TransformedMesh::new(self.mesh.complete_mesh_view(),&self.transform)
|
||||
}
|
||||
}
|
||||
@ -613,6 +613,19 @@ impl MoveState{
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone,Default)]
|
||||
pub struct PhysicsOutputState{
|
||||
body:Body,
|
||||
camera:PhysicsCamera,
|
||||
camera_offset:Planar64Vec3,
|
||||
mouse_pos:glam::IVec2,
|
||||
}
|
||||
impl PhysicsOutputState{
|
||||
pub fn extrapolate(&self,mouse:MouseState)->(glam::Vec3,glam::Vec2){
|
||||
((self.body.extrapolated_position(mouse.time)+self.camera_offset).into(),self.camera.simulate_move_angles(mouse.pos-self.mouse_pos))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone,Hash,Eq,PartialEq)]
|
||||
enum PhysicsCollisionAttributes{
|
||||
Contact(gameplay_attributes::ContactAttributes),
|
||||
@ -909,7 +922,7 @@ impl VirtualBody<'_>{
|
||||
pub struct PhysicsState{
|
||||
time:Time,
|
||||
body:Body,
|
||||
_world:WorldState,//currently there is only one state the world can be in
|
||||
world:WorldState,//currently there is only one state the world can be in
|
||||
touching:TouchingState,
|
||||
//camera must exist in state because wormholes modify the camera, also camera punch
|
||||
camera:PhysicsCamera,
|
||||
@ -946,7 +959,7 @@ impl Default for PhysicsState{
|
||||
move_state:MoveState::Air,
|
||||
camera:PhysicsCamera::default(),
|
||||
input_state:InputState::default(),
|
||||
_world:WorldState{},
|
||||
world:WorldState{},
|
||||
mode_state:ModeState::default(),
|
||||
run:run::Run::new(),
|
||||
}
|
||||
@ -1034,15 +1047,14 @@ impl instruction::InstructionEmitter<PhysicsInternalInstruction> for PhysicsCont
|
||||
}
|
||||
}
|
||||
impl PhysicsContext{
|
||||
pub fn camera_body(&self)->Body{
|
||||
Body{
|
||||
position:self.state.body.position+self.state.style.camera_offset,
|
||||
..self.state.body
|
||||
pub const fn output(&self)->PhysicsOutputState{
|
||||
PhysicsOutputState{
|
||||
body:self.state.body,
|
||||
camera:self.state.camera,
|
||||
camera_offset:self.state.style.camera_offset,
|
||||
mouse_pos:self.state.input_state.mouse.pos,
|
||||
}
|
||||
}
|
||||
pub const fn camera(&self)->PhysicsCamera{
|
||||
self.state.camera
|
||||
}
|
||||
pub const fn get_next_mouse(&self)->&MouseState{
|
||||
self.state.input_state.get_next_mouse()
|
||||
}
|
||||
@ -1472,9 +1484,9 @@ fn run_teleport_behaviour(
|
||||
match stage_element.behaviour(){
|
||||
gameplay_modes::StageElementBehaviour::SpawnAt=>(),
|
||||
gameplay_modes::StageElementBehaviour::Trigger
|
||||
|gameplay_modes::StageElementBehaviour::Teleport=>if let Some(mode_state_stage)=mode.get_stage(mode_state.get_stage_id()){
|
||||
|gameplay_modes::StageElementBehaviour::Teleport=>{
|
||||
//I guess this is correct behaviour when trying to teleport to a non-existent spawn but it's still weird
|
||||
let _=teleport_to_spawn(mode_state_stage,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time);
|
||||
let _=teleport_to_spawn(stage,move_state,body,touching,run,mode_state,mode,models,hitbox_mesh,bvh,style,camera,input_state,time);
|
||||
return;
|
||||
},
|
||||
gameplay_modes::StageElementBehaviour::Platform=>(),
|
||||
@ -1884,7 +1896,6 @@ fn atomic_input_instruction(state:&mut PhysicsState,data:&PhysicsData,ins:TimedI
|
||||
if b_refresh_walk_target{
|
||||
state.apply_input_and_body(data);
|
||||
state.cull_velocity(data,state.body.velocity);
|
||||
//also check if accelerating away from surface
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,12 +180,8 @@ impl MouseInterpolator{
|
||||
self.empty_queue();
|
||||
}
|
||||
}
|
||||
pub fn get_frame_state(&self,time:Time)->crate::graphics::FrameState{
|
||||
crate::graphics::FrameState{
|
||||
body:self.physics.camera_body(),
|
||||
camera:self.physics.camera(),
|
||||
time:self.timer.time(time),
|
||||
}
|
||||
pub fn get_render_stuff(&self,time:Time)->(crate::physics::PhysicsOutputState,Time,glam::IVec2){
|
||||
(self.physics.output(),self.timer.time(time),self.physics.get_next_mouse().pos)
|
||||
}
|
||||
pub fn change_map(&mut self,time:Time,map:&strafesnet_common::map::CompleteMap){
|
||||
//dump any pending interpolation state
|
||||
@ -225,8 +221,8 @@ pub fn new<'a>(
|
||||
interpolator.handle_instruction(&ins);
|
||||
match ins.instruction{
|
||||
Instruction::Render=>{
|
||||
let frame_state=interpolator.get_frame_state(ins.time);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(frame_state)).unwrap();
|
||||
let (physics_output,time,mouse_pos)=interpolator.get_render_stuff(ins.time);
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Render(physics_output,time,mouse_pos)).unwrap();
|
||||
},
|
||||
Instruction::Resize(size)=>{
|
||||
graphics_worker.send(crate::graphics_worker::Instruction::Resize(size,interpolator.user_settings().clone())).unwrap();
|
||||
|
Reference in New Issue
Block a user