45 lines
864 B
C++
45 lines
864 B
C++
#pragma once
|
|
|
|
#include "position.h"
|
|
#include "actions.hpp"
|
|
|
|
namespace world::iterator {
|
|
|
|
using pair = std::pair<glm::ivec3, float>;
|
|
|
|
class Abstract {
|
|
public:
|
|
virtual bool next(pair&) = 0;
|
|
|
|
protected:
|
|
static constexpr uint32_t Diam(uint16_t radius) { return radius * 2 + 1; }
|
|
};
|
|
|
|
/// From -radius to radius
|
|
std::unique_ptr<Abstract> Get(action::Shape, uint16_t radius);
|
|
|
|
class Cube final: public Abstract {
|
|
public:
|
|
bool next(pair&) override;
|
|
|
|
Cube(uint16_t radius): radius(radius), pos(-radius, -radius, -radius) { }
|
|
|
|
private:
|
|
const uint16_t radius;
|
|
glm::ivec3 pos;
|
|
};
|
|
|
|
/// Interger sphere
|
|
class RawSphere final: public Abstract {
|
|
public:
|
|
bool next(pair&) override;
|
|
|
|
RawSphere(uint16_t radius): radius(radius), pos(-radius, 0, 0), dy(0), dz(0) { }
|
|
|
|
private:
|
|
const uint16_t radius;
|
|
glm::ivec3 pos;
|
|
int dy;
|
|
int dz;
|
|
};
|
|
} |