private void ClearWorkspace() { foreach (var render in DataCache.ModelCache.Values) { render.Dispose(); } foreach (var render in Pipeline.SceneObjects) { render.Dispose(); } foreach (var tex in Runtime.TextureCache) { tex.RenderableTex?.Dispose(); } TimelineWindow.Reset(); Outliner.ActiveFileFormat = null; TimelineWindow.Reset(); Outliner.Nodes.Clear(); Outliner.SelectedNodes.Clear(); Pipeline.Files.Clear(); Pipeline.SceneObjects.Clear(); Pipeline._context.Scene.PickableObjects.Clear(); DataCache.ModelCache.Clear(); Runtime.TextureCache.Clear(); BfresEditor.BfresRender.ClearShaderCache(); GC.Collect(); }
private void DrawViewportMenu() { if (ImGui.BeginMenu("View Setting")) { if (ImGui.BeginMenu("Background")) { ImGui.Checkbox("Display", ref DrawableBackground.Display); ImGui.ColorEdit3("Color Top", ref DrawableBackground.BackgroundTop); ImGui.ColorEdit3("Color Bottom", ref DrawableBackground.BackgroundBottom); ImGui.EndMenu(); } if (ImGui.BeginMenu("Grid")) { ImGui.Checkbox("Display", ref DrawableFloor.Display); ImGui.ColorEdit4("Grid Color", ref DrawableFloor.GridColor); ImGui.InputInt("Grid Cell Count", ref Toolbox.Core.Runtime.GridSettings.CellAmount); ImGui.InputFloat("Grid Cell Size", ref Toolbox.Core.Runtime.GridSettings.CellSize); ImGui.EndMenu(); } if (ImGui.BeginMenu("Bones")) { ImGui.Checkbox("Display", ref Runtime.DisplayBones); ImGui.InputFloat("Point Size", ref Runtime.BonePointSize); ImGui.EndMenu(); } if (ImGui.Checkbox("Mesh Picking", ref Pipeline._context.ColorPicker.EnablePicking)) { if (!Pipeline._context.ColorPicker.EnablePicking) { Pipeline._context.Scene.ResetSelected(); } } ImGui.Checkbox("Wireframe", ref Toolbox.Core.Runtime.RenderSettings.Wireframe); ImGui.Checkbox("WireframeOverlay", ref Toolbox.Core.Runtime.RenderSettings.WireframeOverlay); ImGui.Checkbox("Bounding Boxes", ref Toolbox.Core.Runtime.RenderBoundingBoxes); ImGui.Checkbox("Enable Bloom", ref Pipeline._context.EnableBloom); ImGui.EndMenu(); } if (ImGui.BeginMenu($"Shading: [{Runtime.DebugRendering}]")) { foreach (var mode in Enum.GetValues(typeof(Runtime.DebugRender))) { bool isSelected = (Runtime.DebugRender)mode == Runtime.DebugRendering; if (ImGui.Selectable(mode.ToString(), isSelected)) { Runtime.DebugRendering = (Runtime.DebugRender)mode; } if (isSelected) { ImGui.SetItemDefaultFocus(); } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Camera")) { if (ImGui.Button("Reset Transform")) { Pipeline._context.Camera.ResetViewportTransform(); } ImGuiHelper.ComboFromEnum <Camera.FaceDirection>("Direction", Pipeline._context.Camera, "Direction"); if (ImGuiHelper.ComboFromEnum <Camera.CameraMode>("Mode", Pipeline._context.Camera, "Mode")) { Pipeline._context.Camera.ResetViewportTransform(); } ImGuiHelper.InputFromBoolean("Orthographic", Pipeline._context.Camera, "IsOrthographic"); ImGuiHelper.InputFromBoolean("Lock Rotation", Pipeline._context.Camera, "LockRotation"); ImGuiHelper.InputFromFloat("Fov (Degrees)", Pipeline._context.Camera, "FovDegrees", true, 1f); if (Pipeline._context.Camera.FovDegrees != 45) { ImGui.SameLine(); if (ImGui.Button("Reset")) { Pipeline._context.Camera.FovDegrees = 45; } } ImGuiHelper.InputFromFloat("ZFar", Pipeline._context.Camera, "ZFar", true, 1f); if (Pipeline._context.Camera.ZFar != 100000.0f) { ImGui.SameLine(); if (ImGui.Button("Reset")) { Pipeline._context.Camera.ZFar = 100000.0f; } } ImGuiHelper.InputFromFloat("ZNear", Pipeline._context.Camera, "ZNear", true, 0.1f); if (Pipeline._context.Camera.ZNear != 0.1f) { ImGui.SameLine(); if (ImGui.Button("Reset")) { Pipeline._context.Camera.ZNear = 0.1f; } } ImGuiHelper.InputFromFloat("Zoom Speed", Pipeline._context.Camera, "ZoomSpeed", true, 0.1f); if (Pipeline._context.Camera.ZoomSpeed != 1.0f) { ImGui.SameLine(); if (ImGui.Button("Reset")) { Pipeline._context.Camera.ZoomSpeed = 1.0f; } } ImGuiHelper.InputFromFloat("Pan Speed", Pipeline._context.Camera, "PanSpeed", true, 0.1f); if (Pipeline._context.Camera.PanSpeed != 1.0f) { ImGui.SameLine(); if (ImGui.Button("Reset")) { Pipeline._context.Camera.PanSpeed = 1.0f; } } ImGuiHelper.InputFromFloat("Key Move Speed", Pipeline._context.Camera, "KeyMoveSpeed", true, 0.1f); if (Pipeline._context.Camera.PanSpeed != 1.0f) { ImGui.SameLine(); if (ImGui.Button("KeyMoveSpeed")) { Pipeline._context.Camera.KeyMoveSpeed = 1.0f; } } ImGui.EndMenu(); } if (ImGui.BeginMenu("Reset Animations")) { TimelineWindow.Reset(); ImGui.EndMenu(); } ImGui.AlignTextToFramePadding(); ImGui.Text("Active Model(s)"); ImGui.SameLine(); ImGui.PushItemWidth(250); if (ImGui.BeginCombo("##model_select", selectedModel)) { bool isSelected = "All Models" == selectedModel; if (ImGui.Selectable("All Models", isSelected)) { selectedModel = "All Models"; ToggleModel(); } if (isSelected) { ImGui.SetItemDefaultFocus(); } foreach (var file in Pipeline.Files) { foreach (var model in file.Renderer.Models) { string name = $"{file.Renderer.Name}.{model.Name}"; isSelected = name == selectedModel; if (ImGui.Selectable(name, isSelected)) { selectedModel = name; ToggleModel(); } if (isSelected) { ImGui.SetItemDefaultFocus(); } } } ImGui.EndCombo(); } ImGui.PopItemWidth(); }