Unravel Engine C++ Reference
Loading...
Searching...
No Matches
gizmos.cpp
Go to the documentation of this file.
1#include "gizmos.h"
2
3#include <bx/math.h>
4namespace unravel
5{
6
7auto to_bx(const glm::vec3& data) -> bx::Vec3
8{
9 return {data.x, data.y, data.z};
10}
11
13{
14 bx::Sphere sphere;
15 sphere.center = to_bx(sh.center);
16 sphere.radius = sh.radius;
17 dde.draw(sphere);
18}
19
20// void draw(DebugDrawEncoder& dde, const physics_plane_shape& sh)
21// {
22// auto center = sh.normal * sh.constant;
23// dde.drawQuad(to_bx(-sh.normal), to_bx(center), 20);
24// }
25
27{
28 math::vec3 axis{0, 1, 0};
29 dde.drawCylinder(to_bx(sh.center + axis * -sh.length * 0.5f),
30 to_bx(sh.center + axis * sh.length * 0.5f),
31 sh.radius);
32}
33
35{
36 // auto axis = edyn::coordinate_axis_vector(sh.axis);
37 math::vec3 axis{0, 1, 0};
38 dde.drawCapsule(to_bx(sh.center + axis * -sh.length * 0.5f), to_bx(sh.center + axis * sh.length * 0.5f), sh.radius);
39}
40
42{
43 auto aabb = bx::Aabb{to_bx(sh.center - sh.extends * 0.5f), to_bx(sh.center + sh.extends * 0.5f)};
44 dde.draw(aabb);
45}
46
47// void draw(DebugDrawEncoder& dde, const physics_mesh_shape& sh)
48// {
49
50// }
51
53{
54 hpp::visit(
55 [&](auto&& s)
56 {
57 draw(dde, s);
58 },
59 sh.shape);
60}
61
62void draw(DebugDrawEncoder& dde, const std::vector<physics_compound_shape>& shapes)
63{
64 for(auto& shape : shapes)
65 {
66 draw(dde, shape);
67 }
68}
69
70
71} // namespace unravel
@ sphere
Sphere type reflection probe.
void draw(DebugDrawEncoder &dde, const physics_sphere_shape &sh)
Definition gizmos.cpp:12
auto to_bx(const glm::vec3 &data) -> bx::Vec3
Definition gizmos.cpp:7
void draw(const bx::Aabb &_aabb)
void drawCylinder(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
void drawCapsule(const bx::Vec3 &_from, const bx::Vec3 &_to, float _radius)
Represents a box shape for physics calculations.
math::vec3 extends
Extents of the box.
math::vec3 center
Center of the box.
Represents a capsule shape for physics calculations.
float length
Length of the capsule.
math::vec3 center
Center of the capsule.
float radius
Radius of the capsule.
Represents a compound shape that can contain multiple types of shapes.
shape_t shape
The shape contained in the compound shape.
Represents a cylinder shape for physics calculations.
float length
Length of the cylinder.
math::vec3 center
Center of the cylinder.
float radius
Radius of the cylinder.
Represents a sphere shape for physics calculations.
float radius
Radius of the sphere.
math::vec3 center
Center of the sphere.