#ifndef WORLD_CHUNK_H
#define WORLD_CHUNK_H
#include <core/math/vector3.h>
#include <core/math/aabb.h>
#include <core/vector.h>
#include <core/list.h>
#include <modules/opensimplex/open_simplex_noise.h>
#include <core/math/random_number_generator.h>
#include <modules/voxel/util/math/vector3i.h>
#include "world_terrain_lod.h"
class WorldTerrainLod;
class WorldChunk {
	AABB aabb;
	Vector3i loc;
	Vector<Vector3> points;
	Vector<Transform> transforms;
	Vector<float> variance;
	int lod;
	bool dirty;
public:
	static WorldChunk create(const Vector3i &loc, const Vector<Vector3> &points);
	void randomize_transforms(Ref<OpenSimplexNoise> dnoise,
			Ref<OpenSimplexNoise> vnoise,
			Ref<RandomNumberGenerator> rnd_offset,
			float density_scaler);
	AABB get_aabb() const;
	void update_lod(const Transform &vxform, const List<WorldTerrainLod> &lod_list);
	inline const Vector3 *get_points() const
	{
		return points.ptr();
	}
	inline int get_points_count() const
	{
		return points.size();
	}
	inline int get_transforms_count() const
	{
		return transforms.size();
	}
	inline const Transform *get_transforms() const
	{
		return transforms.ptr();
	}
	inline const float *get_variance() const
	{
		return variance.ptr();
	}
	inline int get_lod() const
	{
		return lod;
	}
	inline bool is_dirty() const
	{
		return dirty;
	}
	inline void set_dirty()
	{
		dirty = true;
	}
	inline void clear_dirty()
	{
		dirty = false;
	}
	inline Vector3i get_loc() const
	{
		return loc;
	}
};
#endif

