#ifndef __SAMPLE_SPARSE_META_BALL__
#define __SAMPLE_SPARSE_META_BALL__

#include "../sleek/start.h"
#include "../sleek/driver/mesh.h"
#include <vector>

namespace sample
{
    struct SparseMetaBallPosition
    {
        sleek::math::vec3f position;
        sleek::f32 squaredRadius;
    };

    struct SparseVoxelCube
    {
        sleek::math::vec3f position[8];
        sleek::math::vec3f normal[8];
        sleek::f32 value[8];
    };

    class SparseMetaball : public sleek::driver::MeshBuffer
    {
        public:
            SparseMetaball(int size = 40);
            ~SparseMetaball();

            void setThreshold(sleek::f32);
            sleek::f32 getThreshold() const noexcept;

            std::vector<SparseMetaBallPosition> balls;

            void move();

            void update();
        protected:
            std::vector<SparseVoxelCube> cubes;
        protected:
            sleek::f32 threshold;
            sleek::u32 gridsize;
    };
}

#endif