summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-07 16:08:39 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-07 16:08:39 +0100
commit111b2e89fec8d035dc5cbb54cd0a4197c18b947e (patch)
treed78359d5fdeaf3f452ad6cf6089455ff11ea3bc3
parentd7fdcfd791f011e33fb9720e7451e56410411e4f (diff)
downloadweareserver-111b2e89fec8d035dc5cbb54cd0a4197c18b947e.tar
weareserver-111b2e89fec8d035dc5cbb54cd0a4197c18b947e.tar.bz2
weareserver-111b2e89fec8d035dc5cbb54cd0a4197c18b947e.tar.zst
new pose packet
-rw-r--r--shared/src/packets.rs12
-rw-r--r--shared/src/tree.rs20
-rw-r--r--world/src/main.rs27
-rw-r--r--world/src/mesh.rs12
4 files changed, 43 insertions, 28 deletions
diff --git a/shared/src/packets.rs b/shared/src/packets.rs
index b979460..021fcd0 100644
--- a/shared/src/packets.rs
+++ b/shared/src/packets.rs
@@ -19,7 +19,7 @@ use crate::{
resources::{Prefab, PrefabIndex},
};
use anyhow::{Result, bail};
-use glam::Vec3A;
+use glam::{Affine3A, Vec3A};
use std::{
fmt::{Debug, Display},
hash::Hash,
@@ -59,7 +59,7 @@ pub enum Packet {
Add(Object, Resource<Prefab>),
Remove(Object),
Position(Object, Vec3A, Vec3A),
- Pose(Object, Vec<f32>),
+ Pose(Object, Vec<(u16, Affine3A)>),
Parent(Object, Object),
Sound(Object, Data),
PrefabIndex(Resource<PrefabIndex>),
@@ -115,6 +115,10 @@ impl Packet {
w.write_all(&[0x06])?;
w.write_all(&object.0.to_le_bytes())?;
w.write_all(&(vec.len() as u16).to_le_bytes())?;
+ for (i, a) in vec {
+ i.write(w)?;
+ a.write(w)?;
+ }
}
Packet::Parent(parent, child) => {
w.write_all(&[0x07])?;
@@ -186,13 +190,13 @@ fn read_u128(r: &mut dyn Read) -> Result<u128> {
Ok(u128::from_le_bytes(buf))
}
-fn read_params(r: &mut dyn Read) -> Result<Vec<f32>> {
+fn read_params(r: &mut dyn Read) -> Result<Vec<(u16, Affine3A)>> {
let mut size = [0; 2];
r.read_exact(&mut size)?;
let size = u16::from_le_bytes(size);
let mut v = Vec::with_capacity(size as usize);
for _ in 0..size {
- v.push(f32::read(r)?);
+ v.push((u16::read(r)?, Affine3A::read(r)?));
}
Ok(v)
}
diff --git a/shared/src/tree.rs b/shared/src/tree.rs
index 72e4c24..d6c1138 100644
--- a/shared/src/tree.rs
+++ b/shared/src/tree.rs
@@ -51,11 +51,11 @@ impl SceneTree {
o.rot = *rot;
}
}
- Packet::Pose(object, pose) => {
- if let Some(o) = self.objects.get_mut(object) {
- o.pose = pose.to_vec();
- }
- }
+ // Packet::Pose(object, pose) => {
+ // if let Some(o) = self.objects.get_mut(object) {
+ // o.pose = pose.to_vec();
+ // }
+ // }
Packet::Parent(parent, child) => {
self.reparent(*parent, *child);
}
@@ -134,11 +134,11 @@ impl SceneTree {
Packet::Position(*object, data.pos, data.rot),
]
.into_iter()
- .chain(if data.pose.is_empty() {
- None
- } else {
- Some(Packet::Pose(*object, data.pose.clone()))
- })
+ // .chain(if data.pose.is_empty() {
+ // None
+ // } else {
+ // Some(Packet::Pose(*object, data.pose.clone()))
+ // })
})
}
}
diff --git a/world/src/main.rs b/world/src/main.rs
index 37ea88a..081aa09 100644
--- a/world/src/main.rs
+++ b/world/src/main.rs
@@ -58,9 +58,7 @@ pub struct Args {
/// Send all resources to the server then quit
#[arg(short, long)]
push: bool,
- /// Spin the object
- #[arg(long)]
- spin: bool,
+
/// Remove all other object from the world
#[arg(short, long)]
clear: bool,
@@ -84,8 +82,15 @@ pub struct Args {
#[arg(long)]
use_cache: bool,
+ /// Spins the object
+ #[arg(long)]
+ debug_spin: bool,
+ /// Adds a light
#[arg(long)]
debug_light: bool,
+ /// Wiggles joint index 6
+ #[arg(long)]
+ debug_armature: bool,
}
fn main() -> Result<()> {
@@ -291,7 +296,7 @@ fn main() -> Result<()> {
sock.flush()?;
}
- if args.spin {
+ if args.debug_spin {
let ob = obs[0];
let mut sock2 = sock.try_clone().unwrap();
thread::spawn(move || {
@@ -306,6 +311,20 @@ fn main() -> Result<()> {
}
});
}
+ if args.debug_armature {
+ let ob = obs[0];
+ let mut sock2 = sock.try_clone().unwrap();
+ thread::spawn(move || {
+ let mut x = 0f32;
+ loop {
+ let a = Affine3A::from_rotation_y(x.sin());
+ Packet::Pose(ob, vec![(6, a)]).write(&mut sock2).unwrap();
+ sock2.flush().unwrap();
+ x += 0.1;
+ sleep(Duration::from_millis(50));
+ }
+ });
+ }
if args.push {
if args.use_cache {
diff --git a/world/src/mesh.rs b/world/src/mesh.rs
index fa5dc4d..6fff9c4 100644
--- a/world/src/mesh.rs
+++ b/world/src/mesh.rs
@@ -18,10 +18,7 @@ use crate::{Args, TextureCache, load_texture};
use anyhow::Result;
use gltf::{Mesh, Node, buffer::Data};
use log::{debug, info, warn};
-use std::{
- collections::{BTreeMap, BTreeSet},
- path::Path,
-};
+use std::{collections::BTreeMap, path::Path};
use weareshared::{
Affine3A, Vec3A,
resources::{MeshPart, Prefab},
@@ -91,11 +88,6 @@ pub fn import_mesh(
.map(|x| x.map(|x| joint_index_map[&(si, x)]))
.collect::<Vec<_>>();
debug!("{} vertex joint indecies", a.len());
- eprintln!(
- "index {:?} {:?}",
- node.name(),
- a.iter().flatten().collect::<BTreeSet<_>>()
- );
if a.len() != num_vertex {
warn!("joint index count does not vertex count")
}
@@ -356,7 +348,7 @@ pub fn import_mesh(
None
};
- let armature = node.skin().map(|s| 0);
+ let armature = node.skin().map(|_| 0);
let mesh = store.set(&MeshPart {
name,