Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gizmo.h
Go to the documentation of this file.
1#pragma once
2
3#include "entt/meta/factory.hpp"
4#include <base/basetypes.hpp>
5#include <context/context.hpp>
9
10namespace unravel
11{
12class camera;
13
14struct gizmo : crtp_meta_type<gizmo>
15{
16 virtual ~gizmo() = default;
17
18 virtual void draw(rtti::context& ctx, entt::meta_any& var, const camera& cam, gfx::dd_raii& dd) = 0;
19 virtual void draw_billboard(rtti::context& ctx, entt::meta_any& var, const camera& cam, gfx::dd_raii& dd) = 0;
20
21 template<typename T>
22 static void create_and_register(const entt::meta_type& inspected_type,
23 std::unordered_map<entt::id_type, std::shared_ptr<gizmo>>& type_map)
24 {
25 type_map[inspected_type.info().index()] = std::make_shared<T>();
26 }
27};
28
30{
31 entt::meta_factory<gizmo>{}.type("gizmo"_hs);
32}
33#define GIZMO_REFLECT(gizmo_renderer_type, inspected_type) \
34 REFLECT_INLINE(gizmo_renderer_type) \
35 { \
36 entt::meta_factory<gizmo_renderer_type>{} \
37 .type(entt::hashed_string{#gizmo_renderer_type}) \
38 .custom<entt::attributes>( \
39 entt::attributes{entt::attribute{"inspected_type", entt::resolve<inspected_type>()}}) \
40 .base<gizmo>() \
41 .func<&gizmo::create_and_register<gizmo_renderer_type>>("create_and_register"_hs); \
42 }
43
44} // namespace unravel
Class representing a camera. Contains functionality for manipulating and updating a camera....
Definition camera.h:35
#define REFLECT_INLINE(cls)
Definition reflection.h:128
virtual ~gizmo()=default
virtual void draw(rtti::context &ctx, entt::meta_any &var, const camera &cam, gfx::dd_raii &dd)=0
virtual void draw_billboard(rtti::context &ctx, entt::meta_any &var, const camera &cam, gfx::dd_raii &dd)=0
static void create_and_register(const entt::meta_type &inspected_type, std::unordered_map< entt::id_type, std::shared_ptr< gizmo > > &type_map)
Definition gizmo.h:22