forked from StrafesNET/strafe-client
rename body to physics
This commit is contained in:
parent
f2e4286a08
commit
12a4bf7948
@ -1,11 +1,11 @@
|
|||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct TimedInstruction<I> {
|
pub struct TimedInstruction<I> {
|
||||||
pub time: crate::body::TIME,
|
pub time: crate::physics::TIME,
|
||||||
pub instruction: I,
|
pub instruction: I,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait InstructionEmitter<I> {
|
pub trait InstructionEmitter<I> {
|
||||||
fn next_instruction(&self, time_limit:crate::body::TIME) -> Option<TimedInstruction<I>>;
|
fn next_instruction(&self, time_limit:crate::physics::TIME) -> Option<TimedInstruction<I>>;
|
||||||
}
|
}
|
||||||
pub trait InstructionConsumer<I> {
|
pub trait InstructionConsumer<I> {
|
||||||
fn process_instruction(&mut self, instruction:TimedInstruction<I>);
|
fn process_instruction(&mut self, instruction:TimedInstruction<I>);
|
||||||
@ -13,11 +13,11 @@ pub trait InstructionConsumer<I> {
|
|||||||
|
|
||||||
//PROPER PRIVATE FIELDS!!!
|
//PROPER PRIVATE FIELDS!!!
|
||||||
pub struct InstructionCollector<I> {
|
pub struct InstructionCollector<I> {
|
||||||
time: crate::body::TIME,
|
time: crate::physics::TIME,
|
||||||
instruction: Option<I>,
|
instruction: Option<I>,
|
||||||
}
|
}
|
||||||
impl<I> InstructionCollector<I> {
|
impl<I> InstructionCollector<I> {
|
||||||
pub fn new(time:crate::body::TIME) -> Self {
|
pub fn new(time:crate::physics::TIME) -> Self {
|
||||||
Self{
|
Self{
|
||||||
time,
|
time,
|
||||||
instruction:None
|
instruction:None
|
||||||
|
30
src/main.rs
30
src/main.rs
@ -1,17 +1,17 @@
|
|||||||
use std::{borrow::Cow, time::Instant};
|
use std::{borrow::Cow, time::Instant};
|
||||||
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
|
use wgpu::{util::DeviceExt, AstcBlock, AstcChannel};
|
||||||
use model::{Vertex,ModelInstance,ModelGraphicsInstance};
|
use model::{Vertex,ModelInstance,ModelGraphicsInstance};
|
||||||
use body::{InputInstruction, PhysicsInstruction};
|
use physics::{InputInstruction, PhysicsInstruction};
|
||||||
use instruction::{TimedInstruction, InstructionConsumer};
|
use instruction::{TimedInstruction, InstructionConsumer};
|
||||||
|
|
||||||
mod body;
|
|
||||||
mod model;
|
mod model;
|
||||||
mod zeroes;
|
mod zeroes;
|
||||||
|
mod worker;
|
||||||
|
mod physics;
|
||||||
mod framework;
|
mod framework;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
mod instruction;
|
mod instruction;
|
||||||
mod load_roblox;
|
mod load_roblox;
|
||||||
mod worker;
|
|
||||||
|
|
||||||
struct Entity {
|
struct Entity {
|
||||||
index_count: u32,
|
index_count: u32,
|
||||||
@ -67,7 +67,7 @@ pub struct GlobalState{
|
|||||||
start_time: std::time::Instant,
|
start_time: std::time::Instant,
|
||||||
manual_mouse_lock:bool,
|
manual_mouse_lock:bool,
|
||||||
graphics:GraphicsState,
|
graphics:GraphicsState,
|
||||||
physics:body::PhysicsState,
|
physics:physics::PhysicsState,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GlobalState{
|
impl GlobalState{
|
||||||
@ -103,7 +103,7 @@ impl GlobalState{
|
|||||||
for model in &indexed_models.models{
|
for model in &indexed_models.models{
|
||||||
//make aabb and run vertices to get realistic bounds
|
//make aabb and run vertices to get realistic bounds
|
||||||
for model_instance in &model.instances{
|
for model_instance in &model.instances{
|
||||||
if let Some(model_physics)=body::ModelPhysics::from_model(model,model_instance){
|
if let Some(model_physics)=physics::ModelPhysics::from_model(model,model_instance){
|
||||||
let model_id=self.physics.models.len() as u32;
|
let model_id=self.physics.models.len() as u32;
|
||||||
self.physics.models.push(model_physics);
|
self.physics.models.push(model_physics);
|
||||||
for attr in &model_instance.temp_indexing{
|
for attr in &model_instance.temp_indexing{
|
||||||
@ -408,7 +408,7 @@ fn get_instances_buffer_data(instances:&[ModelGraphicsInstance]) -> Vec<f32> {
|
|||||||
raw
|
raw
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_uniform_data(camera: &body::Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] {
|
fn to_uniform_data(camera: &physics::Camera, pos: glam::Vec3) -> [f32; 16 * 3 + 4] {
|
||||||
let proj=camera.proj();
|
let proj=camera.proj();
|
||||||
let proj_inv = proj.inverse();
|
let proj_inv = proj.inverse();
|
||||||
let view=camera.view(pos);
|
let view=camera.view(pos);
|
||||||
@ -582,21 +582,21 @@ impl framework::Example for GlobalState {
|
|||||||
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader.wgsl"))),
|
||||||
});
|
});
|
||||||
|
|
||||||
let physics = body::PhysicsState {
|
let physics = physics::PhysicsState {
|
||||||
spawn_point:glam::vec3(0.0,50.0,0.0),
|
spawn_point:glam::vec3(0.0,50.0,0.0),
|
||||||
body: body::Body::with_pva(glam::vec3(0.0,50.0,0.0),glam::vec3(0.0,0.0,0.0),glam::vec3(0.0,-100.0,0.0)),
|
body: physics::Body::with_pva(glam::vec3(0.0,50.0,0.0),glam::vec3(0.0,0.0,0.0),glam::vec3(0.0,-100.0,0.0)),
|
||||||
time: 0,
|
time: 0,
|
||||||
style:body::StyleModifiers::default(),
|
style:physics::StyleModifiers::default(),
|
||||||
grounded: false,
|
grounded: false,
|
||||||
contacts: std::collections::HashMap::new(),
|
contacts: std::collections::HashMap::new(),
|
||||||
intersects: std::collections::HashMap::new(),
|
intersects: std::collections::HashMap::new(),
|
||||||
models: Vec::new(),
|
models: Vec::new(),
|
||||||
walk: body::WalkState::new(),
|
walk: physics::WalkState::new(),
|
||||||
camera: body::Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)),
|
camera: physics::Camera::from_offset(glam::vec3(0.0,4.5-2.5,0.0),(config.width as f32)/(config.height as f32)),
|
||||||
mouse_interpolation: body::MouseInterpolationState::new(),
|
mouse_interpolation: physics::MouseInterpolationState::new(),
|
||||||
controls: 0,
|
controls: 0,
|
||||||
world:body::WorldState{},
|
world:physics::WorldState{},
|
||||||
game:body::GameMechanicsState::default(),
|
game:physics::GameMechanicsState::default(),
|
||||||
modes:Vec::new(),
|
modes:Vec::new(),
|
||||||
mode_from_mode_id:std::collections::HashMap::new(),
|
mode_from_mode_id:std::collections::HashMap::new(),
|
||||||
};
|
};
|
||||||
@ -921,7 +921,7 @@ impl framework::Example for GlobalState {
|
|||||||
let time=self.physics.time;
|
let time=self.physics.time;
|
||||||
instruction::InstructionConsumer::process_instruction(&mut self.physics, instruction::TimedInstruction{
|
instruction::InstructionConsumer::process_instruction(&mut self.physics, instruction::TimedInstruction{
|
||||||
time,
|
time,
|
||||||
instruction: body::PhysicsInstruction::Input(body::InputInstruction::Reset),
|
instruction: PhysicsInstruction::Input(InputInstruction::Reset),
|
||||||
});
|
});
|
||||||
}else{
|
}else{
|
||||||
println!("No modeldatas were generated");
|
println!("No modeldatas were generated");
|
||||||
|
@ -51,15 +51,15 @@ impl<Task:Send+'static,Value:Clone+Send+'static> Worker<Task,Value> {
|
|||||||
fn test_worker() {
|
fn test_worker() {
|
||||||
println!("hiiiii");
|
println!("hiiiii");
|
||||||
// Create the worker thread
|
// Create the worker thread
|
||||||
let worker = Worker::new(crate::body::Body::with_pva(glam::Vec3::ZERO,glam::Vec3::ZERO,glam::Vec3::ZERO),
|
let worker = Worker::new(crate::physics::Body::with_pva(glam::Vec3::ZERO,glam::Vec3::ZERO,glam::Vec3::ZERO),
|
||||||
|_|crate::body::Body::with_pva(glam::Vec3::ONE,glam::Vec3::ONE,glam::Vec3::ONE)
|
|_|crate::physics::Body::with_pva(glam::Vec3::ONE,glam::Vec3::ONE,glam::Vec3::ONE)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Send tasks to the worker
|
// Send tasks to the worker
|
||||||
for i in 0..5 {
|
for i in 0..5 {
|
||||||
let task = crate::instruction::TimedInstruction{
|
let task = crate::instruction::TimedInstruction{
|
||||||
time:0,
|
time:0,
|
||||||
instruction:crate::body::PhysicsInstruction::StrafeTick,
|
instruction:crate::physics::PhysicsInstruction::StrafeTick,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ fn test_worker() {
|
|||||||
// Send a new task
|
// Send a new task
|
||||||
let task = crate::instruction::TimedInstruction{
|
let task = crate::instruction::TimedInstruction{
|
||||||
time:0,
|
time:0,
|
||||||
instruction:crate::body::PhysicsInstruction::StrafeTick,
|
instruction:crate::physics::PhysicsInstruction::StrafeTick,
|
||||||
};
|
};
|
||||||
worker.send(task).unwrap();
|
worker.send(task).unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user