Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gizmos_bindings.cpp
Go to the documentation of this file.
2#include "script_bindings.h"
3
4#include "../script_interop.h"
5
7
8namespace unravel
9{
10namespace
11{
12
13void internal_m2n_gizmos_add_sphere(const math::color& color, const math::vec3& position, float radius)
14{
15 auto& ctx = engine::context();
16 auto& path = ctx.get_cached<rendering_system>();
17 path.add_debugdraw_call(
18 [color, position, radius](gfx::dd_raii& dd)
19 {
22 dd.encoder.setWireframe(true);
23
24 bx::Sphere sphere;
25 sphere.center.x = position.x;
26 sphere.center.y = position.y;
27 sphere.center.z = position.z;
28 sphere.radius = radius;
30 });
31}
32
33void internal_m2n_gizmos_add_ray(const math::color& color,
34 const math::vec3& position,
35 const math::vec3& direction,
36 float max_distance)
37{
38 auto& ctx = engine::context();
39 auto& path = ctx.get_cached<rendering_system>();
40 path.add_debugdraw_call(
41 [color, position, direction, max_distance](gfx::dd_raii& dd)
42 {
45 dd.encoder.setWireframe(true);
46
47 bx::Ray ray;
48 ray.pos.x = position.x;
49 ray.pos.y = position.y;
50 ray.pos.z = position.z;
51
52 ray.dir.x = direction.x;
53 ray.dir.y = direction.y;
54 ray.dir.z = direction.z;
55
56 dd.encoder.push();
57 dd.encoder.moveTo(ray.pos);
58 dd.encoder.lineTo(bx::mul(ray.dir, max_distance));
59 dd.encoder.pop();
60 });
61}
62
63} // namespace
64
66{
67 APPLOG_TRACE("{}", __func__);
68
69 auto reg = dotnet::internal_call_registry("Unravel.Core.Gizmos");
70 reg.add_internal_call("internal_m2n_gizmos_add_sphere", dotnet_internal_call(internal_m2n_gizmos_add_sphere));
71 reg.add_internal_call("internal_m2n_gizmos_add_ray", dotnet_internal_call(internal_m2n_gizmos_add_ray));
72}
73
74} // namespace unravel
math::vec3 position
Definition defaults.cpp:52
#define APPLOG_TRACE(...)
Definition logging.h:17
@ sphere
Sphere type reflection probe.
void register_gizmos_script_bindings()
std::vector< math::color > color
void draw(const bx::Aabb &_aabb)
void lineTo(float _x, float _y, float _z=0.0f)
void setColor(uint32_t _abgr)
void setWireframe(bool _wireframe)
void moveTo(float _x, float _y, float _z=0.0f)
DebugDrawEncoder encoder
Definition debugdraw.h:15
static auto context() -> rtti::context &
Definition engine.cpp:111