Line data Source code
1 : #pragma once
2 :
3 : #include <imgui.h>
4 : #include <imgui_impl_vulkan.h>
5 : #include <imgui_internal.h>
6 :
7 : #include <filesystem>
8 : #include <memory>
9 : #include <tracy/Tracy.hpp>
10 : #include <vulkan/vulkan.hpp>
11 : #include <wren/application.hpp>
12 : #include <wren/math/vector.hpp>
13 : #include <wren/mesh.hpp>
14 : #include <wren/scene/components/mesh.hpp>
15 : #include <wren/scene/deserialization.hpp>
16 : #include <wren/scene/scene.hpp>
17 : #include <wren/scene/serialization.hpp>
18 : #include <wren/utils/result.hpp>
19 :
20 : #include "camera.hpp"
21 : #include "context.hpp"
22 : #include "ui.hpp"
23 :
24 : namespace editor {
25 :
26 : class Editor {
27 : public:
28 : static auto create(const std::shared_ptr<wren::Application>& app,
29 : const std::filesystem::path& project_path)
30 : -> wren::expected<std::shared_ptr<Editor>>;
31 :
32 : Editor(const std::shared_ptr<wren::Context>& ctx);
33 :
34 : void on_update();
35 :
36 : private:
37 : auto load_scene() -> wren::expected<void>;
38 :
39 : auto build_render_graph(const std::shared_ptr<wren::Context>& ctx)
40 : -> wren::expected<wren::GraphBuilder>;
41 :
42 : // Project
43 : Context editor_context_;
44 :
45 : // Editor camera
46 : Camera camera_;
47 :
48 : // Panels
49 : std::optional<flecs::entity> selected_entity_;
50 :
51 : // Scene management
52 : std::shared_ptr<wren::scene::Scene> scene_;
53 :
54 : std::shared_ptr<wren::Context> wren_ctx_;
55 :
56 : std::shared_ptr<wren::vk::Shader> mesh_shader_;
57 : std::shared_ptr<wren::vk::Shader> viewer_shader_;
58 :
59 : // Scene viewer
60 0 : std::vector<VkDescriptorSet> dset_{};
61 : vk::Sampler texture_sampler_;
62 :
63 : std::optional<wren::math::Vec2f> scene_resized_;
64 : wren::math::Vec2f last_scene_size_;
65 : };
66 :
67 : } // namespace editor
|