// Copyright (C) 2015 Rémi Bèges
// This file is part of the "Nazara Engine - Noise module"
// For conditions of distribution and use, see copyright notice in Config.hpp

#pragma once

#ifndef SIMPLEX2D_HPP
#define SIMPLEX2D_HPP

#include <Nazara/Prerequesites.hpp>
#include <Nazara/Noise/NoiseBase.hpp>
#include <Nazara/Noise/Abstract2DNoise.hpp>
#include <Nazara/Math/Vector2.hpp>

namespace Nz
{
	class NAZARA_NOISE_API Simplex2D : public Abstract2DNoise
	{
		public:
			Simplex2D();
			Simplex2D(unsigned int seed);
			virtual ~Simplex2D() = default;

			float GetValue(float x, float y, float resolution);

		private:
			int ii,jj;
			int gi0,gi1,gi2;
			Vector2i skewedCubeOrigin,off1;
			float n1,n2,n3;
			float c1,c2,c3;
			float gradient2[8][2];
			float UnskewCoeff2D;
			float SkewCoeff2D;
			float sum;
			Vector2<float> unskewedCubeOrigin, unskewedDistToOrigin;
			Vector2<float> d1,d2,d3;
	};
}

#endif // SIMPLEX2D_HPP

