diff options
| author | HampusM <hampus@hampusmat.com> | 2026-09-01 18:24:39 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-09-01 18:24:39 +0200 |
| commit | 12f7283b34b9504cafe9448ede110b1fc2a3ae41 (patch) | |
| tree | 529644b6722382e14461c41f28ae42f2f5404132 /engine/src/ui/dear_imgui.rs | |
| parent | 632a7188ea267c93b5317ceffd18f1dab0e97cbe (diff) | |
refactor(engine): replace MapVec with intmap crate
Diffstat (limited to 'engine/src/ui/dear_imgui.rs')
| -rw-r--r-- | engine/src/ui/dear_imgui.rs | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/engine/src/ui/dear_imgui.rs b/engine/src/ui/dear_imgui.rs index 0ae8a3b..b589696 100644 --- a/engine/src/ui/dear_imgui.rs +++ b/engine/src/ui/dear_imgui.rs @@ -20,6 +20,7 @@ use ecs::system::observer::Observe; use ecs::system::Into; use ecs::time::Time; use ecs::{Component, Query, Sole}; +use intmap::IntMap; use crate::asset::{Assets, Handle as AssetHandle, Label as AssetLabel}; use crate::data_types::dimens::Dimens; @@ -72,7 +73,6 @@ use crate::rendering::{ PRE_RENDER_PHASE, }; use crate::texture::Properties as TextureProperties; -use crate::util::MapVec; use crate::vector::Vec2; use crate::windowing::dpi::PhysicalSize; use crate::windowing::window::Window; @@ -95,7 +95,7 @@ pub struct Context { pub enabled: bool, ctx: inner_context_wrapper::InnerContextWrapper, - texture_lookup: MapVec<TextureLookupId, RenderingObjectId>, + texture_lookup: IntMap<TextureLookupId, RenderingObjectId>, texture_id_lookup: HashMap<dear_imgui_rs::SnapshotTextureId, dear_imgui_rs::TextureId>, } @@ -153,7 +153,7 @@ impl ecs::extension::Extension for Extension let mut context = Context { enabled: self.start_enabled, ctx: inner_context_wrapper::InnerContextWrapper::new(), - texture_lookup: MapVec::with_capacity(8), + texture_lookup: IntMap::with_capacity(8), texture_id_lookup: HashMap::with_capacity(8), }; @@ -585,7 +585,7 @@ fn add_drawing_render_pass( "Performing texture operation: Update" ); - let Some(texture_object_id) = texture_lookup.get(&texture_lookup_id) + let Some(texture_object_id) = texture_lookup.get(texture_lookup_id) else { tracing::error!( snapshot_tex_id = ?texture_request.texture(), @@ -741,7 +741,7 @@ fn add_drawing_render_pass( let tex_id = cmd_params.texture_id; let Some(texture_object_id) = - texture_lookup.get(&TextureLookupId::from(tex_id)) + texture_lookup.get(TextureLookupId::from(tex_id)) else { tracing::error!( "Unknown texture {}. Skipping skipping draw command", @@ -1046,6 +1046,18 @@ impl TextureLookupId } } +impl intmap::IntKey for TextureLookupId +{ + type Int = u64; + + const PRIME: Self::Int = <u64 as intmap::IntKey>::PRIME; + + fn into_int(self) -> Self::Int + { + self.inner + } +} + impl From<dear_imgui_rs::TextureId> for TextureLookupId { fn from(texture_id: dear_imgui_rs::TextureId) -> Self |
