mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2025-07-04 00:36:14 +00:00
switched over to glam and simplified some imports
This commit is contained in:
parent
dc61d4649c
commit
8e1d235dee
134
Cargo.lock
generated
134
Cargo.lock
generated
@ -65,15 +65,6 @@ version = "1.0.75"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "approx"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "argh"
|
name = "argh"
|
||||||
version = "0.1.12"
|
version = "0.1.12"
|
||||||
@ -164,10 +155,10 @@ dependencies = [
|
|||||||
"crossterm",
|
"crossterm",
|
||||||
"flate2",
|
"flate2",
|
||||||
"futures",
|
"futures",
|
||||||
|
"glam",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"mlua",
|
"mlua",
|
||||||
"nalgebra",
|
|
||||||
"num_enum",
|
"num_enum",
|
||||||
"pretty_env_logger",
|
"pretty_env_logger",
|
||||||
"ratatui",
|
"ratatui",
|
||||||
@ -208,12 +199,6 @@ version = "3.14.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
checksum = "7f30e7476521f6f8af1a1c4c0b8cc94f0bee37d91763d0ca2665f299b6cd8aec"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytemuck"
|
|
||||||
version = "1.14.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "374d28ec25809ee0e23827c2ab573d729e293f281dfe393500e7ad618baa61c6"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@ -467,6 +452,12 @@ version = "0.28.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
|
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "glam"
|
||||||
|
version = "0.24.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b5418c17512bdf42730f9032c74e1ae39afc408745ebb2acf72fbc4691c17945"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.3.21"
|
version = "0.3.21"
|
||||||
@ -764,16 +755,6 @@ dependencies = [
|
|||||||
"which",
|
"which",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "matrixmultiply"
|
|
||||||
version = "0.3.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7574c1cf36da4798ab73da5b215bbf444f50718207754cb522201d78d1cd0ff2"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"rawpointer",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.6.4"
|
version = "2.6.4"
|
||||||
@ -833,63 +814,6 @@ dependencies = [
|
|||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nalgebra"
|
|
||||||
version = "0.31.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "20bd243ab3dbb395b39ee730402d2e5405e448c75133ec49cc977762c4cba3d1"
|
|
||||||
dependencies = [
|
|
||||||
"approx",
|
|
||||||
"matrixmultiply",
|
|
||||||
"nalgebra-macros",
|
|
||||||
"num-complex",
|
|
||||||
"num-rational",
|
|
||||||
"num-traits",
|
|
||||||
"simba",
|
|
||||||
"typenum",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "nalgebra-macros"
|
|
||||||
version = "0.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "01fcc0b8149b4632adc89ac3b7b31a12fb6099a0317a4eb2ebff574ef7de7218"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-complex"
|
|
||||||
version = "0.4.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1ba157ca0885411de85d6ca030ba7e2a83a28636056c7c699b07c8b6f7383214"
|
|
||||||
dependencies = [
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-integer"
|
|
||||||
version = "0.1.45"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "num-rational"
|
|
||||||
version = "0.4.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0"
|
|
||||||
dependencies = [
|
|
||||||
"autocfg",
|
|
||||||
"num-integer",
|
|
||||||
"num-traits",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.17"
|
version = "0.2.17"
|
||||||
@ -1060,12 +984,6 @@ dependencies = [
|
|||||||
"unicode-width",
|
"unicode-width",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rawpointer"
|
|
||||||
version = "0.2.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "60a357793950651c4ed0f3f52338f53b2f809f32d83a07f72909fa13e4c6c1e3"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.4.1"
|
version = "0.4.1"
|
||||||
@ -1227,15 +1145,6 @@ version = "1.0.15"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "safe_arch"
|
|
||||||
version = "0.7.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f398075ce1e6a179b46f51bd88d0598b92b00d3551f1a2d4ac49e771b56ac354"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.2.0"
|
version = "1.2.0"
|
||||||
@ -1336,19 +1245,6 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "simba"
|
|
||||||
version = "0.7.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2f3fd720c48c53cace224ae62bef1bbff363a70c68c4802a78b5cc6159618176"
|
|
||||||
dependencies = [
|
|
||||||
"approx",
|
|
||||||
"num-complex",
|
|
||||||
"num-traits",
|
|
||||||
"paste",
|
|
||||||
"wide",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
@ -1588,12 +1484,6 @@ version = "0.2.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "typenum"
|
|
||||||
version = "1.17.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-bidi"
|
name = "unicode-bidi"
|
||||||
version = "0.3.13"
|
version = "0.3.13"
|
||||||
@ -1765,16 +1655,6 @@ dependencies = [
|
|||||||
"rustix",
|
"rustix",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wide"
|
|
||||||
version = "0.7.13"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242"
|
|
||||||
dependencies = [
|
|
||||||
"bytemuck",
|
|
||||||
"safe_arch",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
|
@ -14,7 +14,7 @@ argh = "0.1.12"
|
|||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
|
|
||||||
anyhow = "1.0.66"
|
anyhow = "1.0.66"
|
||||||
nalgebra = "0.31"
|
glam = "0.24.2"
|
||||||
num_enum = "0.5.7"
|
num_enum = "0.5.7"
|
||||||
|
|
||||||
async-trait = "0.1.58"
|
async-trait = "0.1.58"
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use nalgebra::*;
|
use glam::*;
|
||||||
|
|
||||||
use std::time::{Instant, Duration};
|
use std::time::Instant;
|
||||||
|
|
||||||
#[derive(Default, Clone, Debug)]
|
#[derive(Default, Clone, Debug)]
|
||||||
pub struct Car {
|
pub struct Car {
|
||||||
pub car_json: String,
|
pub car_json: String,
|
||||||
|
|
||||||
pub pos: Vector3<f64>,
|
pub pos: DVec3,
|
||||||
pub rot: Quaternion<f64>,
|
pub rot: DQuat,
|
||||||
pub vel: Vector3<f64>,
|
pub vel: DVec3,
|
||||||
pub rvel: Vector3<f64>,
|
pub rvel: DVec3,
|
||||||
pub tim: f64,
|
pub tim: f64,
|
||||||
pub ping: f64,
|
pub ping: f64,
|
||||||
pub last_pos_update: Option<Instant>,
|
pub last_pos_update: Option<Instant>,
|
||||||
@ -24,12 +24,12 @@ impl Car {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pos(&self) -> Vector3<f64> {
|
pub fn position(&self) -> DVec3 {
|
||||||
self.pos + self.vel * self.last_pos_update.map(|t| t.elapsed().as_secs_f64()).unwrap_or(0.0)
|
self.pos + self.vel * self.last_pos_update.map(|t| t.elapsed().as_secs_f64()).unwrap_or(0.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rotation(&self) -> Quaternion<f64> {
|
pub fn rotation(&self) -> DQuat {
|
||||||
let t = self.last_pos_update.map(|t| t.elapsed().as_secs_f64()).unwrap_or(0.0);
|
let t = self.last_pos_update.map(|t| t.elapsed().as_secs_f64()).unwrap_or(0.0);
|
||||||
self.rot + UnitQuaternion::from_euler_angles(self.rvel.x * t, self.rvel.y * t, self.rvel.z * t).quaternion()
|
self.rot + DQuat::from_euler(glam::EulerRot::YXZ, self.rvel.x * t, self.rvel.y * t, self.rvel.z * t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,7 @@ use std::collections::HashMap;
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::ops::DerefMut;
|
use std::ops::DerefMut;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::atomic::{AtomicU8, Ordering};
|
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::{
|
use tokio::net::{
|
||||||
@ -15,10 +13,7 @@ use tokio::sync::mpsc::{Receiver, Sender};
|
|||||||
use tokio::sync::Mutex;
|
use tokio::sync::Mutex;
|
||||||
use tokio::task::JoinHandle;
|
use tokio::task::JoinHandle;
|
||||||
|
|
||||||
use nalgebra::*;
|
|
||||||
|
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use serde_aux::prelude::*;
|
|
||||||
use crate::fs_util;
|
use crate::fs_util;
|
||||||
|
|
||||||
use super::backend::*;
|
use super::backend::*;
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
use std::sync::{Arc, atomic::{AtomicBool, Ordering}};
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
||||||
use tokio::net::{TcpListener, UdpSocket};
|
use tokio::net::{TcpListener, UdpSocket};
|
||||||
use tokio::task::{JoinHandle, JoinSet};
|
use tokio::task::{JoinHandle, JoinSet};
|
||||||
use tokio::sync::{Mutex, mpsc, oneshot};
|
use tokio::sync::{mpsc, oneshot};
|
||||||
|
|
||||||
use num_enum::IntoPrimitive;
|
use glam::*;
|
||||||
|
|
||||||
use nalgebra::*;
|
|
||||||
|
|
||||||
mod backend;
|
mod backend;
|
||||||
mod car;
|
mod car;
|
||||||
@ -27,7 +25,6 @@ pub use plugins::*;
|
|||||||
pub use http::*;
|
pub use http::*;
|
||||||
|
|
||||||
pub use crate::config::Config;
|
pub use crate::config::Config;
|
||||||
use crate::config::GeneralSettings;
|
|
||||||
|
|
||||||
fn load_plugins(server_resource_folder: String) -> Vec<Plugin> {
|
fn load_plugins(server_resource_folder: String) -> Vec<Plugin> {
|
||||||
let mut plugins = Vec::new();
|
let mut plugins = Vec::new();
|
||||||
@ -686,11 +683,11 @@ impl Server {
|
|||||||
ServerBoundPluginEvent::RequestPositionRaw((pid, vid, responder)) => {
|
ServerBoundPluginEvent::RequestPositionRaw((pid, vid, responder)) => {
|
||||||
if let Some(client) = self.clients.iter().find(|client| client.id == pid) {
|
if let Some(client) = self.clients.iter().find(|client| client.id == pid) {
|
||||||
if let Some((_id, vehicle)) = client.cars.iter().find(|(id, _car)| *id == vid) {
|
if let Some((_id, vehicle)) = client.cars.iter().find(|(id, _car)| *id == vid) {
|
||||||
// let pos_rot = PositionRaw {
|
let pos_rot = PositionRaw {
|
||||||
// pos: vehicle.pos().
|
pos: vehicle.position().as_vec3().to_array(),
|
||||||
// };
|
rot: vehicle.rotation().as_f32().to_array(),
|
||||||
todo!()
|
};
|
||||||
// let _ = responder.send(PluginBoundPluginEvent::PositionRaw(pos_rot));
|
let _ = responder.send(PluginBoundPluginEvent::PositionRaw(pos_rot));
|
||||||
} else {
|
} else {
|
||||||
let _ = responder.send(PluginBoundPluginEvent::None);
|
let _ = responder.send(PluginBoundPluginEvent::None);
|
||||||
}
|
}
|
||||||
@ -972,11 +969,11 @@ impl Server {
|
|||||||
.get_car_mut(car_id)
|
.get_car_mut(car_id)
|
||||||
.ok_or(ServerError::CarDoesntExist)?;
|
.ok_or(ServerError::CarDoesntExist)?;
|
||||||
car.pos = pos_data.pos.into();
|
car.pos = pos_data.pos.into();
|
||||||
car.rot = Quaternion::new(
|
car.rot = DQuat::from_xyzw(
|
||||||
pos_data.rot[3],
|
|
||||||
pos_data.rot[0],
|
pos_data.rot[0],
|
||||||
pos_data.rot[1],
|
pos_data.rot[1],
|
||||||
pos_data.rot[2],
|
pos_data.rot[2],
|
||||||
|
pos_data.rot[3],
|
||||||
);
|
);
|
||||||
car.vel = pos_data.vel.into();
|
car.vel = pos_data.vel.into();
|
||||||
car.rvel = pos_data.rvel.into();
|
car.rvel = pos_data.rvel.into();
|
||||||
|
@ -174,10 +174,13 @@ impl UserData for Context {
|
|||||||
let message = rx.blocking_recv();
|
let message = rx.blocking_recv();
|
||||||
if let Ok(message) = message {
|
if let Ok(message) = message {
|
||||||
if let PluginBoundPluginEvent::PositionRaw(pos_raw) = message {
|
if let PluginBoundPluginEvent::PositionRaw(pos_raw) = message {
|
||||||
|
let pos_table = lua.create_table()?;
|
||||||
|
pos_table.set("x", pos_raw.pos[0])?;
|
||||||
|
pos_table.set("y", pos_raw.pos[1])?;
|
||||||
|
pos_table.set("z", pos_raw.pos[2])?;
|
||||||
|
|
||||||
let table = lua.create_table()?;
|
let table = lua.create_table()?;
|
||||||
// for (vid, veh_json) in vehicles {
|
table.set("pos", pos_table)?;
|
||||||
// table.set(vid, veh_json)?;
|
|
||||||
// }
|
|
||||||
Ok(table)
|
Ok(table)
|
||||||
} else {
|
} else {
|
||||||
unreachable!() // This really should never be reachable
|
unreachable!() // This really should never be reachable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user