Skip to content

Commit

Permalink
fix: laggy 30fps (originally from 150fps) due to oversized Entity id …
Browse files Browse the repository at this point in the history
…offset in client.
  • Loading branch information
Dreamtowards committed Feb 9, 2024
1 parent 097d43f commit e12d507
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,15 @@ impl<'w,'s> EthertiaClient<'w,'s> {


fn startup(
mut commands: Commands,
mut cmds: Commands,
// mut meshes: ResMut<Assets<Mesh>>,
// mut materials: ResMut<Assets<StandardMaterial>>,
// cli: Res<ClientInfo>,
) {
info!("Load World. setup Player, Camera, Sun.");

// Logical Player
// spawn_player();
// crate::net::spawn_player(Entity::from_raw(1000), true, &cli.username, &mut cmds, &mut meshes, &mut materials);
// commands.spawn((
// PbrBundle {
// mesh: meshes.add(Mesh::from(shape::Capsule {
Expand All @@ -181,7 +184,7 @@ fn startup(
// ));

// Camera
commands.spawn((
cmds.spawn((
Camera3dBundle {
projection: Projection::Perspective(PerspectiveProjection { fov: TAU / 4.6, ..default() }),
camera: Camera { hdr: true, ..default() },
Expand All @@ -199,7 +202,7 @@ fn startup(
// .insert(TemporalAntiAliasBundle::default());

// Sun
commands.spawn((
cmds.spawn((
DirectionalLightBundle {
directional_light: DirectionalLight {
shadows_enabled: true,
Expand Down
2 changes: 1 addition & 1 deletion src/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl EntityId {
}

pub fn client_entity(&self) -> Entity {
Entity::from_raw(1_000_000 + self.0)
Entity::from_raw(10_000 + self.0)
}

pub fn raw(&self) -> u32 {
Expand Down

0 comments on commit e12d507

Please sign in to comment.