From d0de60dc33df75fbcacb53a09568b14d0fd48cb9 Mon Sep 17 00:00:00 2001 From: Mel Date: Mon, 12 Jun 2023 17:09:55 +0200 Subject: Multithreaded world generation with Perlin --- src/Math/Grid.hpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Math/Grid.hpp (limited to 'src/Math/Grid.hpp') diff --git a/src/Math/Grid.hpp b/src/Math/Grid.hpp new file mode 100644 index 0000000..1c1a7ca --- /dev/null +++ b/src/Math/Grid.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include "Common.hpp" +#include "Matrix.hpp" + +namespace Math { + +struct GridCellBoundaries { + float x1, x2, y1, y2; + + [[nodiscard]] Vector<2> top_left() const; + [[nodiscard]] Vector<2> top_right() const; + [[nodiscard]] Vector<2> bottom_left() const; + [[nodiscard]] Vector<2> bottom_right() const; +}; + +GridCellBoundaries grid_cell_for_point(Vector<2> point); + +struct CubeCellBoundaries { + float x1, x2, y1, y2, z1, z2; + + [[nodiscard]] Vector<3> front_top_left() const; + [[nodiscard]] Vector<3> front_top_right() const; + [[nodiscard]] Vector<3> front_bottom_left() const; + [[nodiscard]] Vector<3> front_bottom_right() const; + [[nodiscard]] Vector<3> back_top_left() const; + [[nodiscard]] Vector<3> back_top_right() const; + [[nodiscard]] Vector<3> back_bottom_left() const; + [[nodiscard]] Vector<3> back_bottom_right() const; + + [[nodiscard]] GridCellBoundaries grid_cell() const; +}; + +CubeCellBoundaries cube_cell_for_point(Vector<3> point); + +} \ No newline at end of file -- cgit 1.4.1