summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--draw/quad-floor.cpp28
-rw-r--r--draw/quad-floor.hpp (renamed from draw/quad.hpp)4
-rw-r--r--draw/quad-wall-n.cpp28
-rw-r--r--draw/quad-wall-n.hpp29
-rw-r--r--draw/quad-wall-w.cpp28
-rw-r--r--draw/quad-wall-w.hpp29
-rw-r--r--draw/quad.cpp27
-rw-r--r--editor/app.hpp8
-rw-r--r--editor/draw.cpp2
9 files changed, 152 insertions, 31 deletions
diff --git a/draw/quad-floor.cpp b/draw/quad-floor.cpp
new file mode 100644
index 00000000..8d072a90
--- /dev/null
+++ b/draw/quad-floor.cpp
@@ -0,0 +1,28 @@
+#include "quad-floor.hpp"
+#include <array>
+#include <Magnum/GL/Renderer.h>
+
+namespace floormat::wireframe {
+
+auto quad_floor::make_vertex_array() const -> vertex_array
+{
+ const float x = size[0]*.5f, y = size[1]*.5f;
+ const auto cx = center[0], cy = center[1], cz = center[2];
+ return {{
+ { -x + cx, -y + cy, cz },
+ { x + cx, -y + cy, cz },
+ { x + cx, y + cy, cz },
+ { -x + cx, y + cy, cz },
+ }};
+}
+
+quad_floor::quad_floor(Vector3 center, Vector2 size, float line_width) :
+ center(center), size(size), line_width{line_width}
+{}
+
+void quad_floor::on_draw() const
+{
+ GL::Renderer::setLineWidth(line_width);
+}
+
+} // namespace floormat::wireframe
diff --git a/draw/quad.hpp b/draw/quad-floor.hpp
index 050eeb78..7a8ec59a 100644
--- a/draw/quad.hpp
+++ b/draw/quad-floor.hpp
@@ -8,9 +8,9 @@
namespace floormat::wireframe {
-struct quad final
+struct quad_floor final
{
- quad(Vector3 center, Vector2 size, float line_width);
+ quad_floor(Vector3 center, Vector2 size, float line_width);
static constexpr std::size_t num_vertices = 4, num_indexes = 0;
static constexpr GL::MeshPrimitive primitive = GL::MeshPrimitive::LineLoop;
diff --git a/draw/quad-wall-n.cpp b/draw/quad-wall-n.cpp
new file mode 100644
index 00000000..2db11eb7
--- /dev/null
+++ b/draw/quad-wall-n.cpp
@@ -0,0 +1,28 @@
+#include "quad-wall-n.hpp"
+#include <array>
+#include <Magnum/GL/Renderer.h>
+
+namespace floormat::wireframe {
+
+auto quad_wall_n::make_vertex_array() const -> vertex_array
+{
+ const float x = size[0]*.5f, y = size[1]*.5f, z = size[2];
+ const auto cx = center[0], cy = center[1], cz = center[2];
+ return {{
+ { -x + cx, -y + cy, cz },
+ { x + cx, -y + cy, cz },
+ { x + cx, -y + cy, z + cz },
+ { -x + cx, -y + cy, z + cz },
+ }};
+}
+
+quad_wall_n::quad_wall_n(Vector3 center, Vector3 size, float line_width) :
+ center(center), size(size), line_width{line_width}
+{}
+
+void quad_wall_n::on_draw() const
+{
+ GL::Renderer::setLineWidth(line_width);
+}
+
+} // namespace floormat::wireframe
diff --git a/draw/quad-wall-n.hpp b/draw/quad-wall-n.hpp
new file mode 100644
index 00000000..30d69e01
--- /dev/null
+++ b/draw/quad-wall-n.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <array>
+#include <Magnum/Math/Vector3.h>
+#include <Magnum/GL/Mesh.h>
+#include <Corrade/Containers/ArrayViewStl.h>
+
+namespace floormat::wireframe {
+
+struct quad_wall_n final
+{
+ quad_wall_n(Vector3 center, Vector3 size, float line_width);
+
+ static constexpr std::size_t num_vertices = 4, num_indexes = 0;
+ static constexpr GL::MeshPrimitive primitive = GL::MeshPrimitive::LineLoop;
+
+ using vertex_array = std::array<Vector3, num_vertices>;
+
+ static ArrayView<const void> make_index_array() { return {}; }
+ vertex_array make_vertex_array() const;
+ void on_draw() const;
+
+private:
+ Vector3 center;
+ Vector3 size;
+ float line_width;
+};
+
+} // namespace floormat::wireframe
diff --git a/draw/quad-wall-w.cpp b/draw/quad-wall-w.cpp
new file mode 100644
index 00000000..ad0e2ca0
--- /dev/null
+++ b/draw/quad-wall-w.cpp
@@ -0,0 +1,28 @@
+#include "quad-wall-w.hpp"
+#include <array>
+#include <Magnum/GL/Renderer.h>
+
+namespace floormat::wireframe {
+
+auto quad_wall_w::make_vertex_array() const -> vertex_array
+{
+ const float x = size[0]*.5f, y = size[1]*.5f, z = size[2];
+ const auto cx = center[0], cy = center[1], cz = center[2];
+ return {{
+ { -x + cx, -y + cy, cz },
+ { -x + cx, y + cy, cz },
+ { -x + cx, y + cy, z + cz },
+ { -x + cx, -y + cy, z + cz },
+ }};
+}
+
+quad_wall_w::quad_wall_w(Vector3 center, Vector3 size, float line_width) :
+ center(center), size(size), line_width{line_width}
+{}
+
+void quad_wall_w::on_draw() const
+{
+ GL::Renderer::setLineWidth(line_width);
+}
+
+} // namespace floormat::wireframe
diff --git a/draw/quad-wall-w.hpp b/draw/quad-wall-w.hpp
new file mode 100644
index 00000000..fb087865
--- /dev/null
+++ b/draw/quad-wall-w.hpp
@@ -0,0 +1,29 @@
+#pragma once
+
+#include <array>
+#include <Magnum/Math/Vector3.h>
+#include <Magnum/GL/Mesh.h>
+#include <Corrade/Containers/ArrayViewStl.h>
+
+namespace floormat::wireframe {
+
+struct quad_wall_w final
+{
+ quad_wall_w(Vector3 center, Vector3 size, float line_width);
+
+ static constexpr std::size_t num_vertices = 4, num_indexes = 0;
+ static constexpr GL::MeshPrimitive primitive = GL::MeshPrimitive::LineLoop;
+
+ using vertex_array = std::array<Vector3, num_vertices>;
+
+ static ArrayView<const void> make_index_array() { return {}; }
+ vertex_array make_vertex_array() const;
+ void on_draw() const;
+
+private:
+ Vector3 center;
+ Vector3 size;
+ float line_width;
+};
+
+} // namespace floormat::wireframe
diff --git a/draw/quad.cpp b/draw/quad.cpp
deleted file mode 100644
index dee53a75..00000000
--- a/draw/quad.cpp
+++ /dev/null
@@ -1,27 +0,0 @@
-#include "quad.hpp"
-#include <array>
-#include <Magnum/GL/Renderer.h>
-
-namespace floormat::wireframe {
-
-quad::vertex_array quad::make_vertex_array() const
-{
- const float X = size[0]*.5f, Y = size[1]*.5f;
- return {{
- { -X + center[0], -Y + center[1], center[2] },
- { X + center[0], -Y + center[1], center[2] },
- { X + center[0], Y + center[1], center[2] },
- { -X + center[0], Y + center[1], center[2] },
- }};
-}
-
-quad::quad(Vector3 center, Vector2 size, float line_width) :
- center(center), size(size), line_width{line_width}
-{}
-
-void quad::on_draw() const
-{
- GL::Renderer::setLineWidth(line_width);
-}
-
-} // namespace floormat::wireframe
diff --git a/editor/app.hpp b/editor/app.hpp
index f63f7014..de7ffc14 100644
--- a/editor/app.hpp
+++ b/editor/app.hpp
@@ -4,7 +4,9 @@
#include "editor.hpp"
#include "src/global-coords.hpp"
#include "draw/wireframe.hpp"
-#include "draw/quad.hpp"
+#include "draw/quad-floor.hpp"
+#include "draw/quad-wall-n.hpp"
+#include "draw/quad-wall-w.hpp"
#include "draw/box.hpp"
#include "floormat/app.hpp"
@@ -97,7 +99,9 @@ struct app final : floormat_app
Containers::Pointer<floormat_main> M;
ImGuiIntegration::Context _imgui{NoCreate};
std::shared_ptr<tile_atlas> _floor1, _floor2, _wall1, _wall2;
- wireframe_mesh<wireframe::quad> _wireframe_quad;
+ wireframe_mesh<wireframe::quad_floor> _wireframe_quad;
+ wireframe_mesh<wireframe::quad_wall_n> _wireframe_wall_n;
+ wireframe_mesh<wireframe::quad_wall_w> _wireframe_wall_w;
wireframe_mesh<wireframe::box> _wireframe_box;
editor _editor;
enum_bitset<key> keys, keys_repeat;
diff --git a/editor/draw.cpp b/editor/draw.cpp
index 0c356268..535d95da 100644
--- a/editor/draw.cpp
+++ b/editor/draw.cpp
@@ -16,6 +16,8 @@ void app::draw_wireframe_quad(global_coords pos)
const Vector3 center{pt[0]*TILE_SIZE[0], pt[1]*TILE_SIZE[1], 0};
shader.set_tint({1, 0, 0, 1});
_wireframe_quad.draw(shader, {center, {TILE_SIZE[0], TILE_SIZE[1]}, LINE_WIDTH});
+ //_wireframe_wall_n.draw(shader, {center, {TILE_SIZE[0], TILE_SIZE[1], TILE_SIZE[2]}, LINE_WIDTH});
+ //_wireframe_wall_w.draw(shader, {center, {TILE_SIZE[0], TILE_SIZE[1], TILE_SIZE[2]}, LINE_WIDTH});
}
}