Skip to content

Commit

Permalink
restate proper type
Browse files Browse the repository at this point in the history
  • Loading branch information
raffaeleragni committed Jul 13, 2024
1 parent 59f97a1 commit 044f8da
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions src/server/initial_sync.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use std::{any::TypeId, error::Error};

use crate::{
binreflect::reflect_to_bin, lib_priv::SyncTrackerRes, networking::assets::SyncAssetTransfer,
binreflect::reflect_to_bin, lib_priv::{SkinnedMeshSyncMapper, SyncTrackerRes}, networking::assets::SyncAssetTransfer,
proto::Message, SyncEntity,
};
use bevy::{prelude::*, render::mesh::skinning::SkinnedMesh, utils::HashSet};
use bevy::{prelude::*, reflect::DynamicTypePath, render::mesh::skinning::SkinnedMesh, utils::HashSet};
use bevy_renet::renet::{ClientId, DefaultChannel, RenetServer};
use uuid::Uuid;

Expand Down Expand Up @@ -92,6 +92,11 @@ fn check_entity_components(world: &World, result: &mut Vec<Message>) -> Result<(
let entity = world.entity(arch_entity.id());
let e_id = entity.id();
let component = reflect_component.reflect(entity).ok_or("not registered")?;
let type_name = if component.type_id() == TypeId::of::<SkinnedMesh>() {
SkinnedMeshSyncMapper::default().reflect_type_path().to_string()
} else {
type_name.to_string()
};
let component = if component.type_id() == TypeId::of::<SkinnedMesh>() {
debug!("Initial sync: Converting SkinnedMesh to SkinnedMeshSyncMapper");
let compo = track
Expand All @@ -107,7 +112,7 @@ fn check_entity_components(world: &World, result: &mut Vec<Message>) -> Result<(
if let Some(sid) = track.entity_to_uuid.get(&e_id) {
result.push(Message::ComponentUpdated {
id: *sid,
name: type_name.into(),
name: type_name,
data: compo_bin,
});
}
Expand Down
3 changes: 0 additions & 3 deletions tests/component_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,11 +322,8 @@ fn test_skinned_mesh_component_from_initial() {
for i in 0..4 {
joints.push(world.spawn((SyncMark {}, Name::new(format!("{i}")))).id());
}
env.update(10);

let ib_handle = Uuid::new_v4();
let e_id = env.server.world_mut().spawn(SyncMark {}).id();
env.update(4);
let mut e = env.server.world_mut().entity_mut(e_id);
e.insert(SkinnedMesh {
inverse_bindposes: Handle::Weak(AssetId::Uuid { uuid: ib_handle }),
Expand Down

0 comments on commit 044f8da

Please sign in to comment.