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