summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-01-08 02:12:15 +0100
committermetamuffin <metamuffin@disroot.org>2025-01-08 02:12:15 +0100
commit18a47eebb5cd9a0a4847f48255a982b3c422e573 (patch)
tree4dd9dd878917360df47548ef879c8322ce750a02
parent605add9df358a14a6c34db2068fa648ec3c8c984 (diff)
downloadweareserver-18a47eebb5cd9a0a4847f48255a982b3c422e573.tar
weareserver-18a47eebb5cd9a0a4847f48255a982b3c422e573.tar.bz2
weareserver-18a47eebb5cd9a0a4847f48255a982b3c422e573.tar.zst
add skybox option
-rw-r--r--server/src/main.rs8
-rw-r--r--server/src/network.rs2
-rw-r--r--shared/src/resources.rs2
-rw-r--r--world/src/main.rs13
4 files changed, 18 insertions, 7 deletions
diff --git a/server/src/main.rs b/server/src/main.rs
index fc8583b..9ccab02 100644
--- a/server/src/main.rs
+++ b/server/src/main.rs
@@ -69,10 +69,10 @@ impl State {
})
}
pub fn prime_client(&self, conn: u128, net: &ServerNetwork) -> Result<()> {
- net.broadcast(
- Packet::PrefabIndex(self.store.set(&self.prefab_index)?),
- true,
- );
+ // net.broadcast(
+ // Packet::PrefabIndex(self.store.set(&self.prefab_index)?),
+ // true,
+ // );
for p in self.tree.prime_client() {
net.send(conn, p, true);
}
diff --git a/server/src/network.rs b/server/src/network.rs
index cbf5a66..b8be0b1 100644
--- a/server/src/network.rs
+++ b/server/src/network.rs
@@ -27,7 +27,7 @@ use std::{
thread::spawn,
time::Instant,
};
-use weareshared::packets::{Packet, ReadWrite};
+use weareshared::{helper::ReadWrite, packets::Packet};
pub struct ServerNetwork {
conns: Arc<Mutex<HashMap<u128, (SyncSender<Arc<Vec<u8>>>, Option<SocketAddr>)>>>,
diff --git a/shared/src/resources.rs b/shared/src/resources.rs
index 44d6e40..8854794 100644
--- a/shared/src/resources.rs
+++ b/shared/src/resources.rs
@@ -38,7 +38,7 @@ pub struct LightPart {
#[derive(Debug, Default, Clone)]
pub struct EnvironmentPart {
- pub skybox: Option<Resource>,
+ pub skybox: Option<Resource<Image>>,
pub sun: Option<(Vec3A, Vec3A)>,
}
diff --git a/world/src/main.rs b/world/src/main.rs
index c10f0b0..c8ef8c6 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -36,7 +36,7 @@ use weareshared::{
Vec3A,
helper::ReadWrite,
packets::{Data, Object, Packet, Resource},
- resources::{Image, LightPart, Prefab},
+ resources::{EnvironmentPart, Image, LightPart, Prefab},
store::ResourceStore,
vec3a,
};
@@ -64,6 +64,9 @@ struct Args {
/// Register to the prefab index
#[arg(short, long)]
name: Option<String>,
+ /// Add skybox
+ #[arg(short, long)]
+ skybox: Option<PathBuf>,
}
fn main() -> Result<()> {
@@ -111,6 +114,14 @@ fn main() -> Result<()> {
radius: Some(0.2),
})?,
));
+ if let Some(skybox) = args.skybox {
+ let mut buf = Vec::new();
+ File::open(skybox)?.read_to_end(&mut buf)?;
+ prefab.environment = Some(store.set(&EnvironmentPart {
+ skybox: Some(store.set(&Image(buf))?),
+ ..Default::default()
+ })?);
+ }
let pres = store.set(&prefab)?;