tirbofish/dropbear · commit
d0ccd546c105a52cb9890a2212d7943cfce0fa37
feature: TRS (translation, rotation, scale) animation implemented
fix: use string id instead of typeid for storing editor tab IDs
Signature present but could not be verified.
Unverified
@@ -40,6 +40,7 @@ impl SceneGlobalsBindGroup { globals_buffer: &UniformBuffer<Globals>, camera_buffer: &Buffer, ) { + puffin::profile_function!(); self.bind_group = graphics .device .create_bind_group(&wgpu::BindGroupDescriptor { @@ -146,6 +146,7 @@ impl HdrPipeline { /// This renders the internal HDR texture to the [TextureView] /// supplied as parameter. pub fn process(&self, encoder: &mut wgpu::CommandEncoder, output: &wgpu::TextureView) { + puffin::profile_function!(); let mut pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("Hdr::process"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -56,6 +56,7 @@ semver.workspace = true serde.workspace = true bitflags.workspace = true downcast-rs.workspace = true +puffin.workspace = true [target.'cfg(unix)'.dependencies] daemonize = "0.5.0" @@ -1372,6 +1372,7 @@ pub struct AssetViewerDock; impl EditorTabDock for AssetViewerDock { fn desc() -> EditorTabDockDescriptor { EditorTabDockDescriptor { + id: "asset_viewer", title: "Asset Viewer".to_string(), } } @@ -147,8 +147,7 @@ pub struct BuildConsoleDock; impl EditorTabDock for BuildConsoleDock { fn desc() -> EditorTabDockDescriptor { - EditorTabDockDescriptor { - title: "Build Output".to_string(), + EditorTabDockDescriptor { id: "build_console", title: "Build Output".to_string(), } } @@ -1,7 +1,7 @@ use super::*; use crate::editor::ViewportMode; use std::hash::Hasher; -use std::{any::TypeId, collections::HashMap, hash::Hash, path::PathBuf, sync::LazyLock}; +use std::{collections::HashMap, hash::Hash, path::PathBuf, sync::LazyLock}; use crate::editor::console::EucalyptusConsole; use crate::plugin::PluginRegistry; use dropbear_engine::entity::{EntityTransform, Transform}; @@ -169,7 +169,7 @@ impl EditorTabRegistry { D: EditorTabDock + Send + Sync + 'static, { let desc = D::desc(); - let id = Self::id_for_type::<D>(); + let id = Self::id_for_desc(&desc); self.title_to_id.insert(desc.title.to_string(), id); self.descriptors.insert(id, desc); @@ -200,13 +200,9 @@ impl EditorTabRegistry { true } - fn id_for_type<T: 'static>() -> EditorTabId { - Self::numeric_id(TypeId::of::<T>()) - } - - fn numeric_id(type_id: TypeId) -> EditorTabId { + fn id_for_desc(desc: &EditorTabDockDescriptor) -> EditorTabId { let mut hasher = std::collections::hash_map::DefaultHasher::new(); - type_id.hash(&mut hasher); + desc.id.hash(&mut hasher); Self::normalize_id(hasher.finish()) } @@ -227,6 +223,7 @@ impl Default for EditorTabRegistry { pub struct EditorTabDockDescriptor { + pub id: &'static str, pub title: String, } @@ -348,6 +345,7 @@ pub struct ConsoleDock; impl EditorTabDock for ConsoleDock { fn desc() -> EditorTabDockDescriptor { EditorTabDockDescriptor { + id: "console", title: "Console".to_string(), } } @@ -209,8 +209,7 @@ pub struct EntityListDock; impl EditorTabDock for EntityListDock { fn desc() -> EditorTabDockDescriptor { - EditorTabDockDescriptor { - title: "Model/Entity List".to_string(), + EditorTabDockDescriptor { id: "entity_list", title: "Model/Entity List".to_string(), } } @@ -89,8 +89,7 @@ pub struct ResourceInspectorDock; impl EditorTabDock for ResourceInspectorDock { fn desc() -> EditorTabDockDescriptor { - EditorTabDockDescriptor { - title: "Resource Inspector".to_string(), + EditorTabDockDescriptor { id: "inspector", title: "Resource Inspector".to_string(), } } @@ -333,6 +333,7 @@ impl Scene for Editor { log_once::debug_once!("Pipeline ready"); { + puffin::profile_scope!("Clearing viewport"); let _ = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("viewport clear pass"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -367,6 +368,7 @@ impl Scene for Editor { } let lights = { + puffin::profile_scope!("Locating lights"); let mut lights = Vec::new(); let mut query = self.world.query::<&Light>(); for light in query.iter() { @@ -376,6 +378,7 @@ impl Scene for Editor { }; if let Some(globals) = &mut self.shader_globals { + puffin::profile_scope!("Fetching globals"); let enabled_count = lights .iter() .filter(|light| light.component.enabled) @@ -388,6 +391,7 @@ impl Scene for Editor { let mut animated_instances: Vec<(u64, InstanceRaw, wgpu::Buffer)> = Vec::new(); { + puffin::profile_scope!("Locating all renderers and animation components"); let mut query = self .world .query::<(&MeshRenderer, Option<&AnimationComponent>)>(); @@ -410,6 +414,7 @@ impl Scene for Editor { let registry = ASSET_REGISTRY.read(); let mut prepared_models = Vec::new(); for (handle, instances) in static_batches { + puffin::profile_scope!("preparing models"); let Some(model) = registry.get_model(Handle::new(handle)) else { log_once::error_once!("Missing model handle {} in registry", handle); continue; @@ -429,6 +434,7 @@ impl Scene for Editor { } { + puffin::profile_scope!("light cube render pass"); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("light cube render pass"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -519,6 +525,7 @@ impl Scene for Editor { let scene_globals_bind_group = self.scene_globals_bind_group.as_ref().unwrap(); if let Some(lcp) = &self.light_cube_pipeline { + puffin::profile_scope!("model render pass"); for (model, handle, instance_count) in prepared_models { let light_skin_bind_group = graphics @@ -578,6 +585,7 @@ impl Scene for Editor { } if let Some(lcp) = &self.light_cube_pipeline { + puffin::profile_scope!("animated model render pass"); for (handle, instance, skin_buffer) in animated_instances { let Some(model) = registry.get_model(Handle::new(handle)) else { log_once::error_once!("Missing model handle {} in registry", handle); @@ -649,6 +657,7 @@ impl Scene for Editor { } if let Some(sky) = &self.sky_pipeline { + puffin::profile_scope!("sky render pass"); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("sky render pass"), color_attachments: &[Some(wgpu::RenderPassColorAttachment { @@ -693,6 +702,7 @@ impl Scene for Editor { .unwrap_or(false); if show_hitboxes { + puffin::profile_scope!("collider wireframe pipeline"); if let Some(collider_pipeline) = &self.collider_wireframe_pipeline { log_once::debug_once!("Found collider wireframe pipeline"); let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { @@ -268,6 +268,7 @@ pub struct ViewportDock; impl EditorTabDock for ViewportDock { fn desc() -> EditorTabDockDescriptor { EditorTabDockDescriptor { + id: "viewport", title: "Viewport".to_string(), } }