Tatooine
renderable.h
Go to the documentation of this file.
1#ifndef TATOOINE_FLOWEXPLORER_RENDERABLE_H
2#define TATOOINE_FLOWEXPLORER_RENDERABLE_H
3//==============================================================================
4#include <chrono>
6#include <tatooine/ray.h>
8#include <tatooine/mat.h>
9//==============================================================================
10namespace tatooine::flowexplorer {
11//==============================================================================
12namespace base {
14 bool m_picked = false;
15 //============================================================================
16 renderable(std::string const& title, flowexplorer::scene& s);
17 template <typename T>
18 renderable(std::string const& title, flowexplorer::scene& s, T& ref)
19 : ui::base::node{title, s, ref} {}
20 renderable(renderable const& w) = delete;
21 renderable(renderable&& w) noexcept = delete;
22 auto operator=(renderable const& w) -> renderable& = delete;
23 auto operator=(renderable&& w) noexcept -> renderable& = delete;
24 virtual ~renderable() = default;
25
26 virtual auto render(mat4f const& projection_matrix,
27 mat4f const& view_matrix) -> void = 0;
28 virtual auto is_transparent() const -> bool { return false; }
29 virtual auto on_mouse_drag(int /*offset_x*/, int /*offset_y*/) -> bool {
30 return false;
31 }
32 auto on_mouse_clicked() -> void { m_picked = true; }
33 auto on_mouse_released() -> void { m_picked = false; }
34 auto is_picked() -> bool { return m_picked; }
35 virtual auto check_intersection(ray<float, 3> const& /*r*/) const
36 -> std::optional<intersection<double, 3>> {
37 return {};
38 }
39};
40} // namespace base
41template <typename Child>
45 //============================================================================
46 auto serialize() const -> toml::table override{
47 return serializer_t::serialize(*dynamic_cast<Child const*>(this));
48 }
49 //----------------------------------------------------------------------------
50 auto deserialize(toml::table const& serialization) -> void override {
51 return serializer_t::deserialize(*dynamic_cast<Child*>(this),
52 serialization);
53 }
54 //----------------------------------------------------------------------------
55 auto draw_properties() -> bool override {
56 return serializer_t::draw_properties(*dynamic_cast<Child*>(this));
57 }
58 //----------------------------------------------------------------------------
59 auto type_name() const -> std::string_view override {
61 }
62};
63//==============================================================================
64} // namespace tatooine::flowexplorer
65//==============================================================================
66#endif
Definition: directories.h:6
Definition: renderable.h:13
auto is_picked() -> bool
Definition: renderable.h:34
virtual auto check_intersection(ray< float, 3 > const &) const -> std::optional< intersection< double, 3 > >
Definition: renderable.h:35
renderable(renderable &&w) noexcept=delete
auto operator=(renderable &&w) noexcept -> renderable &=delete
bool m_picked
Definition: renderable.h:14
auto on_mouse_released() -> void
Definition: renderable.h:33
renderable(std::string const &title, flowexplorer::scene &s, T &ref)
Definition: renderable.h:18
renderable(renderable const &w)=delete
auto operator=(renderable const &w) -> renderable &=delete
virtual auto render(mat4f const &projection_matrix, mat4f const &view_matrix) -> void=0
auto on_mouse_clicked() -> void
Definition: renderable.h:32
virtual auto is_transparent() const -> bool
Definition: renderable.h:28
virtual auto on_mouse_drag(int, int) -> bool
Definition: renderable.h:29
renderable(std::string const &title, flowexplorer::scene &s)
Definition: renderable.h:42
auto deserialize(toml::table const &serialization) -> void override
Definition: renderable.h:50
auto draw_properties() -> bool override
Definition: renderable.h:55
auto type_name() const -> std::string_view override
Definition: renderable.h:59
auto serialize() const -> toml::table override
Definition: renderable.h:46
Definition: scene.h:17
auto title() const -> auto const &
Definition: node.h:69
auto deserialize(Child &t, toml::table const &serialized_node) -> void
Definition: node.h:189
constexpr auto type_name() const -> std::string_view
Definition: node.h:377
Definition: mat.h:14
Definition: ray.h:10