From a6665ed988c8ea4d9168b6af7f54102dc4a5e686 Mon Sep 17 00:00:00 2001 From: Isse Date: Wed, 3 May 2023 15:17:25 +0200 Subject: [PATCH] some comments --- common/src/comp/body/ship.rs | 3 +++ server/src/events/interaction.rs | 8 +++++++- server/src/events/inventory_manip.rs | 8 +++++++- voxygen/src/hud/mod.rs | 9 +++++++-- voxygen/src/mesh/segment.rs | 3 +++ voxygen/src/scene/figure/mod.rs | 26 +++++++++++++------------- voxygen/src/scene/mod.rs | 3 +-- voxygen/src/session/interactable.rs | 8 ++++---- voxygen/src/session/mod.rs | 2 +- 9 files changed, 46 insertions(+), 24 deletions(-) diff --git a/common/src/comp/body/ship.rs b/common/src/comp/body/ship.rs index 788dc2238e..da1b494148 100644 --- a/common/src/comp/body/ship.rs +++ b/common/src/comp/body/ship.rs @@ -194,6 +194,9 @@ pub mod figuredata { pub bone2: ShipCentralSubSpec, pub bone3: ShipCentralSubSpec, + // TODO: Use StructureBlock here instead. Which would require passing `IndexRef` and + // `Calendar` when loading the voxel colliders, which wouldn't work while it's stored in a + // static. #[serde(default)] pub custom_indices: HashMap, } diff --git a/server/src/events/interaction.rs b/server/src/events/interaction.rs index d498161a4e..cbcc423913 100644 --- a/server/src/events/interaction.rs +++ b/server/src/events/interaction.rs @@ -146,7 +146,13 @@ pub fn handle_mount_volume(server: &mut Server, rider: EcsEntity, volume_pos: Vo let block_transform = volume_pos.get_block_and_transform( &state.terrain(), &state.ecs().read_resource(), - |e| state.read_storage().get(e).copied().zip(state.read_storage().get(e).copied()), + |e| { + state + .read_storage() + .get(e) + .copied() + .zip(state.read_storage().get(e).copied()) + }, &state.read_storage(), ); diff --git a/server/src/events/inventory_manip.rs b/server/src/events/inventory_manip.rs index fd452681d5..f506b43ff7 100644 --- a/server/src/events/inventory_manip.rs +++ b/server/src/events/inventory_manip.rs @@ -754,7 +754,13 @@ pub fn handle_inventory(server: &mut Server, entity: EcsEntity, manip: comp::Inv pos.get_block_and_transform( &state.terrain(), &state.ecs().read_resource(), - |e| state.read_storage().get(e).copied().zip(state.read_storage().get(e).copied()), + |e| { + state + .read_storage() + .get(e) + .copied() + .zip(state.read_storage().get(e).copied()) + }, &state.read_storage(), ) .map(|(mat, _)| mat.mul_point(Vec3::broadcast(0.5))) diff --git a/voxygen/src/hud/mod.rs b/voxygen/src/hud/mod.rs index 8bae2a789d..9f7cf65446 100644 --- a/voxygen/src/hud/mod.rs +++ b/voxygen/src/hud/mod.rs @@ -4749,8 +4749,13 @@ impl Hud { &client.state().terrain(), &client.state().ecs().read_resource(), |e| { - client.state().read_storage::().get(e) - .map(|interpolated| (comp::Pos(interpolated.pos), interpolated.ori)) + client + .state() + .read_storage::() + .get(e) + .map(|interpolated| { + (comp::Pos(interpolated.pos), interpolated.ori) + }) }, &client.state().read_storage(), ) diff --git a/voxygen/src/mesh/segment.rs b/voxygen/src/mesh/segment.rs index b46b9d1856..e731150120 100644 --- a/voxygen/src/mesh/segment.rs +++ b/voxygen/src/mesh/segment.rs @@ -117,6 +117,9 @@ where (Mesh::new(), Mesh::new(), Mesh::new(), bounds) } +// /// NOTE: bone_idx must be in [0, 15] (may be bumped to [0, 31] at some +// /// point). +// TODO: this function name... pub fn generate_mesh_base_vol_terrain<'a: 'b, 'b, V: 'a>( vol: V, (greedy, opaque_mesh, offs, scale, bone_idx): ( diff --git a/voxygen/src/scene/figure/mod.rs b/voxygen/src/scene/figure/mod.rs index 99759f280c..840474e6ce 100644 --- a/voxygen/src/scene/figure/mod.rs +++ b/voxygen/src/scene/figure/mod.rs @@ -47,7 +47,7 @@ use common::{ mounting::{Rider, VolumeRider}, resources::{DeltaTime, Time}, states::{equipping, idle, utils::StageSection, wielding}, - terrain::{Block, TerrainChunk, TerrainGrid, SpriteKind}, + terrain::{Block, SpriteKind, TerrainChunk, TerrainGrid}, uid::UidAllocator, util::Dir, vol::{ReadVol, RectRasterableVol}, @@ -2171,7 +2171,9 @@ impl FigureMgr { ) }, _ => { - if let Some(sprite) = is_volume_rider.and_then(|is_volume_rider| is_volume_rider.block.get_sprite()) { + if let Some(sprite) = is_volume_rider + .and_then(|is_volume_rider| is_volume_rider.block.get_sprite()) + { match sprite { SpriteKind::Helm => { anim::character::DanceAnimation::update_skeleton( @@ -2181,21 +2183,19 @@ impl FigureMgr { &mut state_animation_rate, skeleton_attr, ) - } - _ => { - anim::character::SitAnimation::update_skeleton( - &target_base, - (active_tool_kind, second_tool_kind, time), - state.state_time, - &mut state_animation_rate, - skeleton_attr, - ) - } + }, + _ => anim::character::SitAnimation::update_skeleton( + &target_base, + (active_tool_kind, second_tool_kind, time), + state.state_time, + &mut state_animation_rate, + skeleton_attr, + ), } } else { target_base } - } + }, }; state.skeleton = Lerp::lerp(&state.skeleton, &target_bones, dt_lerp); diff --git a/voxygen/src/scene/mod.rs b/voxygen/src/scene/mod.rs index 540c62ba8b..80e85fe7e5 100644 --- a/voxygen/src/scene/mod.rs +++ b/voxygen/src/scene/mod.rs @@ -719,8 +719,7 @@ impl Scene { .filter_map(|(entity, interpolated, body, collider)| { let vol = collider.get_vol(&voxel_colliders_manifest)?; let (blocks_of_interest, offset) = - figure_mgr - .get_blocks_of_interest(entity, body, Some(collider))?; + figure_mgr.get_blocks_of_interest(entity, body, Some(collider))?; let mat = Mat4::from(interpolated.ori.to_quat()) .translated_3d(interpolated.pos) diff --git a/voxygen/src/session/interactable.rs b/voxygen/src/session/interactable.rs index 787f5d20ce..14e9d1e5d6 100644 --- a/voxygen/src/session/interactable.rs +++ b/voxygen/src/session/interactable.rs @@ -16,7 +16,8 @@ use common::{ terrain::{Block, TerrainGrid, UnlockKind}, uid::{Uid, UidAllocator}, util::find_dist::{Cube, Cylinder, FindDist}, - vol::ReadVol, CachedSpatialGrid, + vol::ReadVol, + CachedSpatialGrid, }; use common_base::span; @@ -197,7 +198,6 @@ pub(super) fn select_interactable( player_char_state, ); - let spacial_grid = ecs.read_resource::(); let entities = ecs.entities(); @@ -211,9 +211,9 @@ pub(super) fn select_interactable( !&is_mount, (stats.mask() | items.mask()).maybe(), ) - .join(); + .join(); - let closest_interactable_entity = spacial_grid.0.in_circle_aabr(player_pos.xy(), MAX_PICKUP_RANGE) + let closest_interactable_entity = spacial_grid.0.in_circle_aabr(player_pos.xy(), MAX_PICKUP_RANGE) .filter(|&e| e != player_entity) // skip the player's entity .filter_map(|e| entity_data.get(e, &entities)) .filter_map(|(e, p, b, s, c, cs, _, has_stats_or_item)| { diff --git a/voxygen/src/session/mod.rs b/voxygen/src/session/mod.rs index fd530d1e30..0df137e6b7 100644 --- a/voxygen/src/session/mod.rs +++ b/voxygen/src/session/mod.rs @@ -350,7 +350,7 @@ impl SessionState { match inv_event { InventoryUpdateEvent::BlockCollectFailed { pos, reason } => { self.hud.add_failed_block_pickup( - // TODO: Support volumes. + // TODO: Possibly support volumes. VolumePos::terrain(pos), HudCollectFailedReason::from_server_reason( &reason,