From 8ea7dcfbcf25095375b8357d3570dec87a72e806 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 6 Mar 2020 13:44:13 +0100 Subject: [PATCH] Move noise functions to the clean header namespace. --- TODO.md | 1 - include/lol/math/noise.h | 22 +++++++++++++++++++ .../lol/math/private}/gradient.h | 0 .../lol/math/private}/perlin.h | 6 ++++- .../lol/math/private}/simplex.h | 5 +++-- 5 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 include/lol/math/noise.h rename {legacy/lol/math/noise => include/lol/math/private}/gradient.h (100%) rename {legacy/lol/math/noise => include/lol/math/private}/perlin.h (97%) rename {legacy/lol/math/noise => include/lol/math/private}/simplex.h (99%) diff --git a/TODO.md b/TODO.md index 32077412..e397c0a1 100644 --- a/TODO.md +++ b/TODO.md @@ -4,7 +4,6 @@ src/lol/base/types.h (vec_t shortcuts eg. vec2, ivec2, u8vec3 etc.) src/lol/math/constants.h src/lol/math/functions.h - src/lol/math/noise/* ## headers we could clean up and keep diff --git a/include/lol/math/noise.h b/include/lol/math/noise.h new file mode 100644 index 00000000..7699743d --- /dev/null +++ b/include/lol/math/noise.h @@ -0,0 +1,22 @@ +// +// Lol Engine +// +// Copyright © 2010—2020 Sam Hocevar +// +// Lol Engine is free software. It comes without any warranty, to +// the extent permitted by applicable law. You can redistribute it +// and/or modify it under the terms of the Do What the Fuck You Want +// to Public License, Version 2, as published by the WTFPL Task Force. +// See http://www.wtfpl.net/ for more details. +// + +#pragma once + +// +// Noise functions +// ——————————————— +// + +#include "private/perlin.h" +#include "private/simplex.h" + diff --git a/legacy/lol/math/noise/gradient.h b/include/lol/math/private/gradient.h similarity index 100% rename from legacy/lol/math/noise/gradient.h rename to include/lol/math/private/gradient.h diff --git a/legacy/lol/math/noise/perlin.h b/include/lol/math/private/perlin.h similarity index 97% rename from legacy/lol/math/noise/perlin.h rename to include/lol/math/private/perlin.h index 4b0c4c8c..ffebd987 100644 --- a/legacy/lol/math/noise/perlin.h +++ b/include/lol/math/private/perlin.h @@ -14,7 +14,9 @@ #pragma once -#include <../legacy/lol/math/noise/gradient.h> +#include "gradient.h" + +#include // std::sqrt namespace lol { @@ -36,6 +38,8 @@ public: /* Evaluate noise at a given point */ inline float eval(vec_t position) const { + using std::sqrt; + /* Compute the containing hypercube origin */ vec_t origin; for (int i = 0; i < N; ++i) diff --git a/legacy/lol/math/noise/simplex.h b/include/lol/math/private/simplex.h similarity index 99% rename from legacy/lol/math/noise/simplex.h rename to include/lol/math/private/simplex.h index 264dfa02..a857f6c0 100644 --- a/legacy/lol/math/noise/simplex.h +++ b/include/lol/math/private/simplex.h @@ -14,7 +14,8 @@ #pragma once -#include <../legacy/lol/math/noise/gradient.h> +#include "gradient.h" + #include // vec_t #include // mat_t @@ -408,5 +409,5 @@ private: } }; -} +} // namespace lol