mirror of
https://github.com/Relintai/voxelman.git
synced 2024-11-12 10:15:12 +01:00
-Implemented neighbour information query.
-Merged the needed things from the subvoxel helper classes into VoxelCubePoints. -Mesh generation kind of works.
This commit is contained in:
parent
79d54238c3
commit
d35efab890
2
SCsub
2
SCsub
@ -21,5 +21,3 @@ env.add_source_files(env.modules_sources,"world/voxel_chunk.cpp")
|
||||
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/voxel_mesher_cubic.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/voxel_cube_points.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/sub_voxel_side_points.cpp")
|
||||
env.add_source_files(env.modules_sources,"meshers/cubic_mesher/sub_voxel_face_points_helper.cpp")
|
||||
|
@ -1,293 +0,0 @@
|
||||
#include "sub_voxel_face_points_helper.h"
|
||||
|
||||
#include "voxel_cube_points.h"
|
||||
|
||||
Vector2i SubVoxelFacePointsHelper::gettlv2() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2i(_face, _tl);
|
||||
}
|
||||
Vector2i SubVoxelFacePointsHelper::gettrv2() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2i(_face, _tr);
|
||||
}
|
||||
Vector2i SubVoxelFacePointsHelper::getblv2() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2i(_face, _bl);
|
||||
}
|
||||
Vector2i SubVoxelFacePointsHelper::getbrv2() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2i(_face, _br);
|
||||
}
|
||||
|
||||
|
||||
Vector2 SubVoxelFacePointsHelper::gettlv2_bind() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2(_face, _tl.to_vec3());
|
||||
}
|
||||
Vector2 SubVoxelFacePointsHelper::gettrv2_bind() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2(_face, _tr.to_vec3());
|
||||
}
|
||||
Vector2 SubVoxelFacePointsHelper::getblv2_bind() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2(_face, _bl.to_vec3());
|
||||
}
|
||||
Vector2 SubVoxelFacePointsHelper::getbrv2_bind() {
|
||||
return SubVoxelFacePointsHelper::transform_to_vector2(_face, _br.to_vec3());
|
||||
}
|
||||
|
||||
|
||||
int SubVoxelFacePointsHelper::gettl_depth() {
|
||||
return SubVoxelFacePointsHelper::get_depth(_face, _tl);
|
||||
}
|
||||
|
||||
int SubVoxelFacePointsHelper::gettr_depth() {
|
||||
return SubVoxelFacePointsHelper::get_depth(_face, _tr);
|
||||
}
|
||||
|
||||
int SubVoxelFacePointsHelper::getbl_depth() {
|
||||
return SubVoxelFacePointsHelper::get_depth(_face, _bl);
|
||||
}
|
||||
|
||||
int SubVoxelFacePointsHelper::getbr_depth() {
|
||||
return SubVoxelFacePointsHelper::get_depth(_face, _br);
|
||||
}
|
||||
|
||||
SubVoxelFacePointsHelper::SubVoxelFacePointsHelper() {
|
||||
}
|
||||
|
||||
SubVoxelFacePointsHelper::~SubVoxelFacePointsHelper() {
|
||||
}
|
||||
|
||||
void SubVoxelFacePointsHelper::set_sub_voxel_points(int face, Ref<VoxelCubePoints> points) {
|
||||
_face = face;
|
||||
_tl = Vector3i(points->get_top_left_point(face));
|
||||
_tr = Vector3i(points->get_top_right_point(face));
|
||||
_bl = Vector3i(points->get_bottom_left_point(face));
|
||||
_br = Vector3i(points->get_bottom_right_point(face));
|
||||
}
|
||||
|
||||
bool SubVoxelFacePointsHelper::is_face_fully_covered() {
|
||||
if (!is_face_near_the_edges()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2i tlv = gettlv2();
|
||||
if ((tlv.x != 0) || (tlv.y != 255)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2i trv = gettrv2();
|
||||
if ((trv.x != 255) || (trv.y != 255)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2i blv = getblv2();
|
||||
if ((blv.x != 0) || (blv.y != 0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2i brv = getbrv2();
|
||||
return (brv.x == 255) && (brv.y == 0);
|
||||
}
|
||||
|
||||
bool SubVoxelFacePointsHelper::is_face_near_the_edges() {
|
||||
if (_face == VoxelCubePoints::VOXEL_FACE_FRONT) {
|
||||
if (gettl_depth() == 0 && gettr_depth() == 0 && getbl_depth() == 0 && getbr_depth() == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (_face == VoxelCubePoints::VOXEL_FACE_BACK) {
|
||||
if (gettl_depth() == 255 && gettr_depth() == 255 && getbl_depth() == 255 && getbr_depth() == 255) {
|
||||
return true;
|
||||
}
|
||||
} else if (_face == VoxelCubePoints::VOXEL_FACE_RIGHT) {
|
||||
if (gettl_depth() == 255 && gettr_depth() == 255 && getbl_depth() == 255 && getbr_depth() == 255) {
|
||||
return true;
|
||||
}
|
||||
} else if (_face == VoxelCubePoints::VOXEL_FACE_LEFT) {
|
||||
if (gettl_depth() == 0 && gettr_depth() == 0 && getbl_depth() == 0 && getbr_depth() == 0) {
|
||||
return true;
|
||||
}
|
||||
} else if (_face == VoxelCubePoints::VOXEL_FACE_TOP) {
|
||||
if (gettl_depth() == 255 && gettr_depth() == 255 && getbl_depth() == 255 && getbr_depth() == 255) {
|
||||
return true;
|
||||
}
|
||||
} else if (_face == VoxelCubePoints::VOXEL_FACE_BOTTOM) {
|
||||
if (gettl_depth() == 0 && gettr_depth() == 0 && getbl_depth() == 0 && getbr_depth() == 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SubVoxelFacePointsHelper::is_face_visible_against(Ref<SubVoxelFacePointsHelper> other) {
|
||||
if (!is_face_near_the_edges() || !other->is_face_near_the_edges()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i tlv = gettlv2();
|
||||
Vector2i tlv2 = other->gettlv2();
|
||||
|
||||
if ((tlv.x < tlv2.x) || (tlv.y > tlv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i trv = gettrv2();
|
||||
Vector2i trv2 = other->gettrv2();
|
||||
|
||||
if ((trv.x > trv2.x) || (trv.y > trv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i blv = getblv2();
|
||||
Vector2i blv2 = other->getblv2();
|
||||
|
||||
if ((blv.x < blv2.x) || (blv.y < blv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i brv = getbrv2();
|
||||
Vector2i brv2 = other->getbrv2();
|
||||
|
||||
return (brv.x > brv2.x) || (brv.y < brv2.y);
|
||||
}
|
||||
/*
|
||||
bool SubVoxelFacePointsHelper::is_face_visible_against(Ref<SubVoxelFacePointsHelper> other) {
|
||||
if (!is_face_near_the_edges() || !other.is_face_near_the_edges()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i tlv = gettlv2();
|
||||
Vector2i tlv2 = other.gettlv2();
|
||||
|
||||
if ((tlv.x < tlv2.x) || (tlv.y > tlv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i trv = gettrv2();
|
||||
Vector2i trv2 = other.gettrv2();
|
||||
|
||||
if ((trv.x > trv2.x) || (trv.y > trv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i blv = getblv2();
|
||||
Vector2i blv2 = other.getblv2();
|
||||
|
||||
if ((blv.x < blv2.x) || (blv.y < blv2.y)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Vector2i brv = getbrv2();
|
||||
Vector2i brv2 = other.getbrv2();
|
||||
|
||||
return (brv.x > brv2.x) || (brv.y < brv2.y);
|
||||
}
|
||||
*/
|
||||
int SubVoxelFacePointsHelper::get_depth(int face, Vector3i v3) {
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BACK) {
|
||||
return v3.z;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_FRONT) {
|
||||
return v3.z;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_RIGHT) {
|
||||
return v3.x;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_LEFT) {
|
||||
return v3.x;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_TOP) {
|
||||
return v3.y;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BOTTOM) {
|
||||
return v3.y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int SubVoxelFacePointsHelper::get_depth_bind(int face, Vector3 v3) {
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BACK) {
|
||||
return v3.z;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_FRONT) {
|
||||
return v3.z;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_RIGHT) {
|
||||
return v3.x;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_LEFT) {
|
||||
return v3.x;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_TOP) {
|
||||
return v3.y;
|
||||
}
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BOTTOM) {
|
||||
return v3.y;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vector2i SubVoxelFacePointsHelper::transform_to_vector2i(int face, Vector3i v3) {
|
||||
Vector2i result;
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BACK) {
|
||||
result = Vector2i(v3.x, v3.y);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_FRONT) {
|
||||
result = Vector2i(v3.x, v3.y);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_RIGHT) {
|
||||
result = Vector2i(v3.y, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_LEFT) {
|
||||
result = Vector2i(v3.y, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_TOP) {
|
||||
result = Vector2i(v3.x, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_BOTTOM) {
|
||||
result = Vector2i(v3.x, v3.z);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Vector2 SubVoxelFacePointsHelper::transform_to_vector2(int face, Vector3 v3) {
|
||||
Vector2 result;
|
||||
if (face == VoxelCubePoints::VOXEL_FACE_BACK) {
|
||||
result = Vector2(v3.x, v3.y);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_FRONT) {
|
||||
result = Vector2(v3.x, v3.y);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_RIGHT) {
|
||||
result = Vector2(v3.y, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_LEFT) {
|
||||
result = Vector2(v3.y, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_TOP) {
|
||||
result = Vector2(v3.x, v3.z);
|
||||
} else if (face == VoxelCubePoints::VOXEL_FACE_BOTTOM) {
|
||||
result = Vector2(v3.x, v3.z);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SubVoxelFacePointsHelper::equals(Ref<SubVoxelFacePointsHelper> other) {
|
||||
return ((((_tl == other->_tl) && (_tr == other->_tr)) && (_bl == other->_bl)) && (_br == other->_br)) && (_face == other->_face);
|
||||
}
|
||||
|
||||
int SubVoxelFacePointsHelper::get_hash_code() {
|
||||
//return ((((_tl->get_hash_code() / 100000) + (_tr->get_hash_code() / 100000)) + (_bl->get_hash_code() / 100000)) + (_br->get_hash_code() / 100000)) + _face;
|
||||
|
||||
return 123;
|
||||
}
|
||||
|
||||
void SubVoxelFacePointsHelper::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("gettlv2"), &SubVoxelFacePointsHelper::gettlv2_bind);
|
||||
ClassDB::bind_method(D_METHOD("gettrv2"), &SubVoxelFacePointsHelper::gettrv2_bind);
|
||||
ClassDB::bind_method(D_METHOD("getblv2"), &SubVoxelFacePointsHelper::getblv2_bind);
|
||||
ClassDB::bind_method(D_METHOD("getbrv2"), &SubVoxelFacePointsHelper::getbrv2_bind);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("gettl_depth"), &SubVoxelFacePointsHelper::gettl_depth);
|
||||
ClassDB::bind_method(D_METHOD("gettr_depth"), &SubVoxelFacePointsHelper::gettr_depth);
|
||||
ClassDB::bind_method(D_METHOD("getbl_depth"), &SubVoxelFacePointsHelper::getbl_depth);
|
||||
ClassDB::bind_method(D_METHOD("getbr_depth"), &SubVoxelFacePointsHelper::getbr_depth);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_sub_voxel_points", "face", "points"), &SubVoxelFacePointsHelper::set_sub_voxel_points);
|
||||
ClassDB::bind_method(D_METHOD("is_face_fully_covered"), &SubVoxelFacePointsHelper::is_face_fully_covered);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_face_near_the_edges"), &SubVoxelFacePointsHelper::is_face_near_the_edges);
|
||||
ClassDB::bind_method(D_METHOD("is_face_visible_against", "other"), &SubVoxelFacePointsHelper::is_face_visible_against);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_depth", "face", "v3"), &SubVoxelFacePointsHelper::get_depth_bind);
|
||||
ClassDB::bind_method(D_METHOD("transform_to_vector2"), &SubVoxelFacePointsHelper::transform_to_vector2);
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
#ifndef SUB_VOXEL_FACE_POINTS_HELPER_H
|
||||
#define SUB_VOXEL_FACE_POINTS_HELPER_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "../../math/vector3i.h"
|
||||
#include "core/math/vector2.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
class VoxelCubePoints;
|
||||
|
||||
class SubVoxelFacePointsHelper : public Reference {
|
||||
GDCLASS(SubVoxelFacePointsHelper, Reference);
|
||||
|
||||
public:
|
||||
Vector2i gettlv2();
|
||||
Vector2i gettrv2();
|
||||
Vector2i getblv2();
|
||||
Vector2i getbrv2();
|
||||
|
||||
Vector2 gettlv2_bind();
|
||||
Vector2 gettrv2_bind();
|
||||
Vector2 getblv2_bind();
|
||||
Vector2 getbrv2_bind();
|
||||
|
||||
int gettl_depth();
|
||||
int gettr_depth();
|
||||
int getbl_depth();
|
||||
int getbr_depth();
|
||||
|
||||
void set_sub_voxel_points(int face, Ref<VoxelCubePoints> points);
|
||||
bool is_face_fully_covered();
|
||||
bool is_face_near_the_edges();
|
||||
bool is_face_visible_against(Ref<SubVoxelFacePointsHelper> other);
|
||||
//bool is_face_visible_against(Ref<SubVoxelFacePointsHelper> other);
|
||||
int get_depth(int face, Vector3i v3);
|
||||
int get_depth_bind(int face, Vector3 v3);
|
||||
Vector2i transform_to_vector2i(int face, Vector3i v3);
|
||||
Vector2 transform_to_vector2(int face, Vector3 v3);
|
||||
|
||||
bool equals(Ref<SubVoxelFacePointsHelper> other);
|
||||
|
||||
int get_hash_code();
|
||||
|
||||
SubVoxelFacePointsHelper();
|
||||
~SubVoxelFacePointsHelper();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
int _face;
|
||||
|
||||
Vector3i _tl;
|
||||
Vector3i _tr;
|
||||
Vector3i _bl;
|
||||
Vector3i _br;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,59 +0,0 @@
|
||||
#include "sub_voxel_side_points.h"
|
||||
|
||||
|
||||
SubVoxelSidePoints::SubVoxelSidePoints() {
|
||||
}
|
||||
|
||||
SubVoxelSidePoints::~SubVoxelSidePoints() {
|
||||
}
|
||||
|
||||
bool SubVoxelSidePoints::is_sub_voxel_point_vec(Vector3i point) {
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (_points[i] == point) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool SubVoxelSidePoints::is_sub_voxel_point(int x, int y, int z) {
|
||||
for (int i = 0; i < 4; i += 1) {
|
||||
if (_points[i].x == x && _points[i].y == y && _points[i].z == z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector3 SubVoxelSidePoints::get_vector3_for_point(int index) {
|
||||
Vector3i a = _points[index];
|
||||
|
||||
Vector3 b(a.x, a.y, a.z);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Vector3 SubVoxelSidePoints::get_vertex_vector3_for_point(int index) {
|
||||
Vector3i a = _points[index];
|
||||
|
||||
Vector3 vector(a.x, a.y, a.z);
|
||||
|
||||
float num = (float)255;
|
||||
float num2 = num / (float)2;
|
||||
vector.x -= num2;
|
||||
vector.y -= num2;
|
||||
vector.z -= num2;
|
||||
vector /= num;
|
||||
return vector;
|
||||
}
|
||||
|
||||
void SubVoxelSidePoints::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("get_point", "index"), &SubVoxelSidePoints::get_point_bind);
|
||||
ClassDB::bind_method(D_METHOD("set_point", "index", "point"), &SubVoxelSidePoints::set_point_bind);
|
||||
ClassDB::bind_method(D_METHOD("get_point_count"), &SubVoxelSidePoints::get_point_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_sub_voxel_point", "x", "y", "z"), &SubVoxelSidePoints::is_sub_voxel_point);
|
||||
ClassDB::bind_method(D_METHOD("get_vector3_for_point", "index"), &SubVoxelSidePoints::get_vector3_for_point);
|
||||
ClassDB::bind_method(D_METHOD("get_vertex_vector3_for_point", "index"), &SubVoxelSidePoints::get_vertex_vector3_for_point);
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
#ifndef SUB_VOXEL_SIDE_POINTS_H
|
||||
#define SUB_VOXEL_SIDE_POINTS_H
|
||||
|
||||
#include "../../math/vector3i.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
class SubVoxelSidePoints : public Reference {
|
||||
GDCLASS(SubVoxelSidePoints, Reference);
|
||||
|
||||
public:
|
||||
Vector3i get_point(int index) { return _points[index]; }
|
||||
Vector3 get_point_bind(int index) { return _points[index].to_vec3(); }
|
||||
void set_point(int index, Vector3i point) { _points[index] = point; }
|
||||
void set_point_bind(int index, Vector3 point) { _points[index] = point; }
|
||||
int get_point_count() { return 4; }
|
||||
|
||||
bool is_sub_voxel_point_vec(Vector3i point);
|
||||
bool is_sub_voxel_point(int x, int y, int z);
|
||||
Vector3 get_vector3_for_point(int pointIndex);
|
||||
Vector3 get_vertex_vector3_for_point(int pointIndex);
|
||||
|
||||
SubVoxelSidePoints();
|
||||
~SubVoxelSidePoints();
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
private:
|
||||
|
||||
Vector3i _points[4];
|
||||
};
|
||||
|
||||
#endif
|
@ -1,6 +1,22 @@
|
||||
#include "voxel_cube_points.h"
|
||||
|
||||
#include "sub_voxel_face_points_helper.h"
|
||||
const unsigned int VoxelCubePoints::index_table[6][4] = {
|
||||
{ P000, P010, P110, P100 }, //VOXEL_FACE_FRONT 0
|
||||
{ P100, P110, P111, P101 }, //VOXEL_FACE_RIGHT 1
|
||||
{ P101, P111, P011, P001 }, //VOXEL_FACE_BACK 2
|
||||
{ P001, P011, P010, P000 }, //VOXEL_FACE_LEFT 3
|
||||
{ P111, P110, P010, P011 }, //VOXEL_FACE_TOP 4
|
||||
{ P001, P000, P100, P101 }, //VOXEL_FACE_BOTTOM 5
|
||||
};
|
||||
|
||||
const unsigned int VoxelCubePoints::visibility_table[6] = {
|
||||
VOXEL_NEIGHBOUR_FRONT, //VOXEL_FACE_FRONT 0
|
||||
VOXEL_NEIGHBOUR_RIGHT, //VOXEL_FACE_RIGHT 1
|
||||
VOXEL_NEIGHBOUR_BACK, //VOXEL_FACE_BACK 2
|
||||
VOXEL_NEIGHBOUR_LEFT, //VOXEL_FACE_LEFT 3
|
||||
VOXEL_NEIGHBOUR_TOP, //VOXEL_FACE_TOP 4
|
||||
VOXEL_NEIGHBOUR_BOTTOM //VOXEL_FACE_BOTTOM 5
|
||||
};
|
||||
|
||||
int VoxelCubePoints::get_x() {
|
||||
return _x;
|
||||
@ -120,9 +136,253 @@ void VoxelCubePoints::refresh_point_full(int index, int vectx, int vecty, int ve
|
||||
_points[index] = vector3i;
|
||||
}
|
||||
|
||||
void VoxelCubePoints::refresh_neighbours(const Ref<VoxelBuffer> buffer) {
|
||||
int neighbours = 0;
|
||||
|
||||
int x = _x;
|
||||
int y = _y;
|
||||
int z = _z;
|
||||
|
||||
//000
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT;
|
||||
|
||||
_point_neighbours[P000] = neighbours;
|
||||
|
||||
neighbours = 0;
|
||||
x = _x + 1;
|
||||
y = _y;
|
||||
z = _z;
|
||||
|
||||
//100
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT;
|
||||
|
||||
_point_neighbours[P100] = neighbours;
|
||||
|
||||
neighbours = 0;
|
||||
x = _x;
|
||||
y = _y + 1;
|
||||
z = _z;
|
||||
|
||||
//010
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_FRONT;
|
||||
|
||||
_point_neighbours[P010] = neighbours;
|
||||
|
||||
neighbours = 0;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z;
|
||||
|
||||
//110
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT;
|
||||
|
||||
_point_neighbours[P110] = neighbours;
|
||||
|
||||
neighbours = 0;
|
||||
x = _x;
|
||||
y = _y;
|
||||
z = _z + 1;
|
||||
|
||||
//001
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK;
|
||||
|
||||
_point_neighbours[P001] = neighbours;
|
||||
|
||||
|
||||
neighbours = 0;
|
||||
x = _x + 1;
|
||||
y = _y;
|
||||
z = _z + 1;
|
||||
|
||||
//101
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK;
|
||||
|
||||
_point_neighbours[P101] = neighbours;
|
||||
|
||||
neighbours = 0;
|
||||
x = _x;
|
||||
y = _y + 1;
|
||||
z = _z + 1;
|
||||
|
||||
//011
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_BACK;
|
||||
|
||||
_point_neighbours[P011] = neighbours;
|
||||
|
||||
|
||||
neighbours = 0;
|
||||
x = _x + 1;
|
||||
y = _y + 1;
|
||||
z = _z + 1;
|
||||
|
||||
//111
|
||||
if (buffer->get_voxel(x - 1, y, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP;
|
||||
|
||||
if (buffer->get_voxel(x, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT;
|
||||
|
||||
if (buffer->get_voxel(x, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK;
|
||||
|
||||
if (buffer->get_voxel(x - 1, y - 1, z - 1, VoxelBuffer::CHANNEL_TYPE) != 0)
|
||||
neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_BACK;
|
||||
|
||||
_point_neighbours[P111] = neighbours;
|
||||
}
|
||||
|
||||
void VoxelCubePoints::setup(const Ref<VoxelBuffer> buffer, int x, int y, int z, int size) {
|
||||
ERR_FAIL_COND(size <= 0);
|
||||
|
||||
reset();
|
||||
|
||||
_x = x;
|
||||
_y = y;
|
||||
_z = z;
|
||||
_size = size;
|
||||
|
||||
_point_types[P000] = buffer->get_voxel(x, y, z, VoxelBuffer::CHANNEL_TYPE);
|
||||
_point_types[P100] = buffer->get_voxel(x + size, y, z, VoxelBuffer::CHANNEL_TYPE);
|
||||
_point_types[P010] = buffer->get_voxel(x, y + size, z, VoxelBuffer::CHANNEL_TYPE);
|
||||
@ -144,80 +404,58 @@ void VoxelCubePoints::setup(const Ref<VoxelBuffer> buffer, int x, int y, int z,
|
||||
_point_fills[P101] = buffer->get_voxel(x + size, y, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
|
||||
_point_fills[P111] = buffer->get_voxel(x + size, y + size, z + size, VoxelBuffer::CHANNEL_ISOLEVEL);
|
||||
|
||||
refresh_neighbours(buffer);
|
||||
|
||||
|
||||
refresh_points();
|
||||
}
|
||||
|
||||
|
||||
Ref<SubVoxelSidePoints> VoxelCubePoints::get_points_for_face(int face) {
|
||||
|
||||
if (face == VOXEL_FACE_FRONT) {
|
||||
_face_helper->set_point(0, get_point(P000));
|
||||
_face_helper->set_point(1, get_point(P010));
|
||||
_face_helper->set_point(2, get_point(P110));
|
||||
_face_helper->set_point(3, get_point(P100));
|
||||
} else if (face == VOXEL_FACE_BACK) {
|
||||
_face_helper->set_point(0, get_point(P101));
|
||||
_face_helper->set_point(1, get_point(P111));
|
||||
_face_helper->set_point(2, get_point(P011));
|
||||
_face_helper->set_point(3, get_point(P001));
|
||||
} else if (face == VOXEL_FACE_RIGHT) {
|
||||
_face_helper->set_point(0, get_point(P100));
|
||||
_face_helper->set_point(1, get_point(P110));
|
||||
_face_helper->set_point(2, get_point(P111));
|
||||
_face_helper->set_point(3, get_point(P101));
|
||||
} else if (face == VOXEL_FACE_LEFT) {
|
||||
_face_helper->set_point(0, get_point(P001));
|
||||
_face_helper->set_point(1, get_point(P011));
|
||||
_face_helper->set_point(2, get_point(P010));
|
||||
_face_helper->set_point(3, get_point(P000));
|
||||
} else if (face == VOXEL_FACE_TOP) {
|
||||
_face_helper->set_point(0, get_point(P111));
|
||||
_face_helper->set_point(1, get_point(P110));
|
||||
_face_helper->set_point(2, get_point(P010));
|
||||
_face_helper->set_point(3, get_point(P011));
|
||||
} else if (face == VOXEL_FACE_BOTTOM) {
|
||||
_face_helper->set_point(0, get_point(P001));
|
||||
_face_helper->set_point(1, get_point(P000));
|
||||
_face_helper->set_point(2, get_point(P100));
|
||||
_face_helper->set_point(3, get_point(P101));
|
||||
void VoxelCubePoints::reset() {
|
||||
for (int i = 0; i < POINT_COUNT; ++i) {
|
||||
_point_types[i] = 0;
|
||||
_point_fills[i] = 0;
|
||||
_point_neighbours[i] = 0;
|
||||
}
|
||||
|
||||
return _face_helper;
|
||||
_x = 0;
|
||||
_y = 0;
|
||||
_z = 0;
|
||||
_size = 1;
|
||||
}
|
||||
|
||||
bool VoxelCubePoints::face_fully_covered(int face) {
|
||||
Ref<SubVoxelFacePointsHelper> avp;
|
||||
avp.instance();
|
||||
int VoxelCubePoints::get_point_index(int face, int index) {
|
||||
ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, 0);
|
||||
ERR_FAIL_INDEX_V(index, 4, 0);
|
||||
|
||||
avp->set_sub_voxel_points(face, this);
|
||||
|
||||
return avp->is_face_fully_covered();
|
||||
return index_table[face][index];
|
||||
}
|
||||
|
||||
bool VoxelCubePoints::face_should_be_visible_against_full(int face) {
|
||||
Ref<SubVoxelFacePointsHelper> avp;
|
||||
avp.instance();
|
||||
|
||||
avp->set_sub_voxel_points(face, this);
|
||||
|
||||
return !avp->is_face_near_the_edges();
|
||||
Vector3i VoxelCubePoints::get_points_for_face(int face, int index) {
|
||||
return _points[get_point_index(face, index)];
|
||||
}
|
||||
|
||||
bool VoxelCubePoints::face_should_be_visible_against(int face, Ref<VoxelCubePoints> other) {
|
||||
Ref<SubVoxelFacePointsHelper> avp;
|
||||
avp.instance();
|
||||
|
||||
avp->set_sub_voxel_points(face, this);
|
||||
|
||||
Ref<SubVoxelFacePointsHelper> other2;
|
||||
other2.instance();
|
||||
|
||||
other2->set_sub_voxel_points(get_opposite_face(face), other);
|
||||
|
||||
return avp->is_face_visible_against(other2);
|
||||
Vector3 VoxelCubePoints::get_points_for_face_bind(int face, int index) {
|
||||
return _points[get_point_index(face, index)].to_vec3();
|
||||
}
|
||||
|
||||
|
||||
bool VoxelCubePoints::is_face_visible(int face) {
|
||||
ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, false);
|
||||
|
||||
int target_neighbour = visibility_table[face];
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
int indx = get_point_index(face, i);
|
||||
int neighbour_mask = _point_neighbours[indx];
|
||||
|
||||
if ((neighbour_mask & target_neighbour) == 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool VoxelCubePoints::is_sub_voxel_point_vec(Vector3i point) {
|
||||
for (int i = 0; i < POINT_COUNT; i += 1) {
|
||||
if (get_point(i) == (point)) {
|
||||
@ -258,6 +496,30 @@ int VoxelCubePoints::get_point_id(int x, int y, int z) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Vector3 VoxelCubePoints::get_vector3_for_point(int face, int index) {
|
||||
Vector3i a = get_point_index(face, index);
|
||||
|
||||
Vector3 b(a.x, a.y, a.z);
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
Vector3 VoxelCubePoints::get_vertex_vector3_for_point(int face, int index) {
|
||||
int point_index = get_point_index(face, index);
|
||||
|
||||
Vector3i a = get_point(point_index);
|
||||
|
||||
Vector3 vector(a.x, a.y, a.z);
|
||||
|
||||
float num = (float)255;
|
||||
float num2 = num / (float)2;
|
||||
vector.x -= num2;
|
||||
vector.y -= num2;
|
||||
vector.z -= num2;
|
||||
vector /= num;
|
||||
return vector;
|
||||
}
|
||||
|
||||
Vector3i VoxelCubePoints::get_point(int index) {
|
||||
return _points[index];
|
||||
}
|
||||
@ -468,11 +730,10 @@ int VoxelCubePoints::get_opposite_face(int face) {
|
||||
}
|
||||
|
||||
VoxelCubePoints::VoxelCubePoints() {
|
||||
_face_helper.instance();
|
||||
reset();
|
||||
}
|
||||
|
||||
VoxelCubePoints::~VoxelCubePoints() {
|
||||
_face_helper.unref();
|
||||
}
|
||||
|
||||
|
||||
@ -494,20 +755,21 @@ void VoxelCubePoints::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("set_size", "value"), &VoxelCubePoints::set_size);
|
||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size");
|
||||
|
||||
|
||||
ClassDB::bind_method(D_METHOD("refresh_points"), &VoxelCubePoints::refresh_points);
|
||||
ClassDB::bind_method(D_METHOD("setup", "buffer", "x", "y", "z", "size"), &VoxelCubePoints::setup, DEFVAL(1));
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_points_for_face", "face"), &VoxelCubePoints::get_points_for_face);
|
||||
ClassDB::bind_method(D_METHOD("get_point_index", "face", "index"), &VoxelCubePoints::get_point_index);
|
||||
ClassDB::bind_method(D_METHOD("get_points_for_face", "face", "index"), &VoxelCubePoints::get_points_for_face_bind);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("face_fully_covered", "face"), &VoxelCubePoints::face_fully_covered);
|
||||
ClassDB::bind_method(D_METHOD("face_should_be_visible_against_full", "face"), &VoxelCubePoints::face_should_be_visible_against_full);
|
||||
//ClassDB::bind_method(D_METHOD("face_should_be_visible_against", "face", "other"), &VoxelCubePoints::face_should_be_visible_against);
|
||||
ClassDB::bind_method(D_METHOD("face_fully_covered", "face"), &VoxelCubePoints::is_face_visible);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("is_sub_voxel_point", "x", "y", "z"), &VoxelCubePoints::is_sub_voxel_point);
|
||||
ClassDB::bind_method(D_METHOD("set_point", "point", "x", "y", "z"), &VoxelCubePoints::set_point);
|
||||
ClassDB::bind_method(D_METHOD("get_point_id", "x", "y", "z"), &VoxelCubePoints::get_point_id);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_vector3_for_point", "face", "index"), &VoxelCubePoints::get_vector3_for_point);
|
||||
ClassDB::bind_method(D_METHOD("get_vertex_vector3_for_point", "face", "index"), &VoxelCubePoints::get_vertex_vector3_for_point);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_point", "index"), &VoxelCubePoints::get_point_bind);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_top_left_point", "face"), &VoxelCubePoints::get_top_left_point_bind);
|
||||
|
@ -1,12 +1,10 @@
|
||||
#ifndef SUB_VOXEL_POINTS_H
|
||||
#define SUB_VOXEL_POINTS_H
|
||||
|
||||
#include "core/reference.h"
|
||||
#include "../../math/vector3i.h"
|
||||
#include "core/vector.h"
|
||||
#include "../../world/voxel_buffer.h"
|
||||
|
||||
#include "sub_voxel_side_points.h"
|
||||
#include "core/reference.h"
|
||||
#include "core/vector.h"
|
||||
|
||||
class SubVoxelFacePointsHelper;
|
||||
|
||||
@ -79,7 +77,6 @@ public:
|
||||
VOXEL_FULL_SIDE_NEIGHBOURS_DOWN = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_BOTTOM,
|
||||
};
|
||||
|
||||
|
||||
int get_x();
|
||||
void set_x(int value);
|
||||
|
||||
@ -93,18 +90,24 @@ public:
|
||||
void set_size(int value);
|
||||
|
||||
void refresh_points();
|
||||
void refresh_neighbours(const Ref<VoxelBuffer> buffer);
|
||||
void setup(const Ref<VoxelBuffer> buffer, int x, int y, int z, int size = 1);
|
||||
|
||||
Ref<SubVoxelSidePoints> get_points_for_face(int face);
|
||||
bool face_fully_covered(int face);
|
||||
bool face_should_be_visible_against_full(int face);
|
||||
bool face_should_be_visible_against(int face, Ref<VoxelCubePoints> other);
|
||||
void reset();
|
||||
|
||||
int get_point_index(int face, int index);
|
||||
Vector3i get_points_for_face(int face, int index);
|
||||
Vector3 get_points_for_face_bind(int face, int index);
|
||||
bool is_face_visible(int face);
|
||||
bool is_sub_voxel_point_vec(Vector3i point);
|
||||
bool is_sub_voxel_point(int x, int y, int z);
|
||||
void set_point(int point, int x, int y, int z);
|
||||
int get_point_id_vec(Vector3i point);
|
||||
int get_point_id(int x, int y, int z);
|
||||
|
||||
Vector3 get_vector3_for_point(int face, int pointIndex);
|
||||
Vector3 get_vertex_vector3_for_point(int face, int pointIndex);
|
||||
|
||||
Vector3i get_point(int index);
|
||||
Vector3i get_top_left_point(int face);
|
||||
Vector3i get_top_right_point(int face);
|
||||
@ -130,14 +133,15 @@ protected:
|
||||
void refresh_point_full(int index, int vectx, int vecty, int vectz, int axisx, int axis2x, int axis3x, int axisy, int axis2y, int axis3y, int axis4y, int axisz, int axis2z, int axis3z);
|
||||
|
||||
private:
|
||||
static const unsigned int index_table[6][4];
|
||||
static const unsigned int visibility_table[6];
|
||||
|
||||
Vector3i _points[POINT_COUNT];
|
||||
|
||||
uint8_t _point_types[POINT_COUNT];
|
||||
uint8_t _point_fills[POINT_COUNT];
|
||||
unsigned int _point_neighbours[POINT_COUNT];
|
||||
|
||||
Ref<SubVoxelSidePoints> _face_helper;
|
||||
|
||||
int _size;
|
||||
int _x;
|
||||
int _y;
|
||||
@ -148,5 +152,4 @@ VARIANT_ENUM_CAST(VoxelCubePoints::Points);
|
||||
VARIANT_ENUM_CAST(VoxelCubePoints::VoxelFaces);
|
||||
VARIANT_ENUM_CAST(VoxelCubePoints::VoxelNeighbours);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "meshers/cubic_mesher/voxel_mesher_cubic.h"
|
||||
#include "meshers/cubic_mesher/voxel_cube_points.h"
|
||||
#include "meshers/cubic_mesher/sub_voxel_side_points.h"
|
||||
#include "meshers/cubic_mesher/sub_voxel_face_points_helper.h"
|
||||
|
||||
void register_voxelman_types() {
|
||||
ClassDB::register_class<VoxelMesher>();
|
||||
@ -35,8 +33,6 @@ void register_voxelman_types() {
|
||||
|
||||
ClassDB::register_class<VoxelMesherCubic>();
|
||||
ClassDB::register_class<VoxelCubePoints>();
|
||||
ClassDB::register_class<SubVoxelSidePoints>();
|
||||
ClassDB::register_class<SubVoxelFacePointsHelper>();
|
||||
}
|
||||
|
||||
void unregister_voxelman_types() {
|
||||
|
Loading…
Reference in New Issue
Block a user