|
|
@ -9,16 +9,36 @@ |
|
|
|
|
|
|
|
#include "Octree/voxel/Voxel.h" |
|
|
|
|
|
|
|
Octree::Voxel::Voxel(const std::vector<bool> &value, int _x, int _y, int _z): voxels(value), _x(_x), _y(_y), _z(_z) { |
|
|
|
Octree::Voxel::Voxel(const std::vector<bool> &value, int _x, int _y, int _z, int expand) |
|
|
|
: voxels(value), _x(_x), _y(_y), _z(_z), expand(expand), _x_exp(_x + 2 * expand), _y_exp(_y + 2 * expand), _z_exp(_z + 2 * expand) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
Octree::Voxel::Voxel(int _x, int _y, int _z): Voxel(std::vector<bool>(_x * _y * _z, false), _x, _y, _z) { |
|
|
|
Octree::Voxel::Voxel(int _x, int _y, int _z, int expand) : |
|
|
|
Voxel(std::vector<bool>((_x + 2 * expand) * (_y + 2 * expand) * (+2 * expand), false), |
|
|
|
_x, _y, _z, expand) { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
int Octree::Voxel::id_at(int x, int y, int z) const { |
|
|
|
return ((z * _y) + y) * _x + x; |
|
|
|
x += expand; |
|
|
|
y += expand; |
|
|
|
z += expand; |
|
|
|
|
|
|
|
return ((z * _y_exp) + y) * _x_exp + x; |
|
|
|
// return ((z * _y) + y) * _x + x;
|
|
|
|
} |
|
|
|
bool Octree::Voxel::at(int x, int y, int z) const { |
|
|
|
return voxels[id_at(x,y,z)]; |
|
|
|
return voxels[id_at(x, y, z)]; |
|
|
|
} |
|
|
|
|
|
|
|
void Octree::Voxel::create_voxels(int _x, int _y, int _z, int expand) { |
|
|
|
this->_x = _x; |
|
|
|
this->_y = _y; |
|
|
|
this->_z = _z; |
|
|
|
this->_x_exp = _x + 2 * expand; |
|
|
|
this->_y_exp = _y + 2 * expand; |
|
|
|
this->_z_exp = _z + 2 * expand; |
|
|
|
this->expand = expand; |
|
|
|
voxels = std::vector<bool>(_x_exp * _y_exp * _z_exp, false); |
|
|
|
} |
|
|
|