Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gizmos_bindings.cpp
Go to the documentation of this file.
1
#include "
script_glue_common.h
"
2
#include "
script_bindings.h
"
3
4
#include "
../script_interop.h
"
5
6
#include <
engine/rendering/ecs/systems/rendering_system.h
>
7
8
namespace
unravel
9
{
10
namespace
11
{
12
13
void
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
{
20
DebugDrawEncoderScopePush
scope(dd.
encoder
);
21
dd.
encoder
.
setColor
(
color
);
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;
29
dd.
encoder
.
draw
(
sphere
);
30
});
31
}
32
33
void
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
{
43
DebugDrawEncoderScopePush
scope(dd.
encoder
);
44
dd.
encoder
.
setColor
(
color
);
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
65
void
register_gizmos_script_bindings
()
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
DebugDrawEncoderScopePush
Definition
debugdraw.h:234
position
math::vec3 position
Definition
defaults.cpp:52
APPLOG_TRACE
#define APPLOG_TRACE(...)
Definition
logging.h:17
unravel
Definition
crash.cpp:21
unravel::probe_type::sphere
@ sphere
Sphere type reflection probe.
unravel::register_gizmos_script_bindings
void register_gizmos_script_bindings()
Definition
gizmos_bindings.cpp:65
color
std::vector< math::color > color
Definition
particle_system_soa.cpp:375
rendering_system.h
script_bindings.h
script_glue_common.h
script_interop.h
DebugDrawEncoder::draw
void draw(const bx::Aabb &_aabb)
Definition
debugdraw.cpp:2443
DebugDrawEncoder::lineTo
void lineTo(float _x, float _y, float _z=0.0f)
Definition
debugdraw.cpp:2428
DebugDrawEncoder::pop
void pop()
Definition
debugdraw.cpp:2348
DebugDrawEncoder::setColor
void setColor(uint32_t _abgr)
Definition
debugdraw.cpp:2363
DebugDrawEncoder::setWireframe
void setWireframe(bool _wireframe)
Definition
debugdraw.cpp:2373
DebugDrawEncoder::push
void push()
Definition
debugdraw.cpp:2343
DebugDrawEncoder::moveTo
void moveTo(float _x, float _y, float _z=0.0f)
Definition
debugdraw.cpp:2418
gfx::dd_raii
Definition
debugdraw.h:10
gfx::dd_raii::encoder
DebugDrawEncoder encoder
Definition
debugdraw.h:15
math::color
Definition
color.h:12
unravel::engine::context
static auto context() -> rtti::context &
Definition
engine.cpp:111
engine
engine
scripting
ecs
systems
bindings
gizmos_bindings.cpp
Generated by
1.12.0