2017-04-06 23:44:11 +02:00
|
|
|
#ifndef VOXEL_MESHER_SMOOTH_H
|
|
|
|
#define VOXEL_MESHER_SMOOTH_H
|
|
|
|
|
2018-09-29 18:51:09 +02:00
|
|
|
#include "../voxel_buffer.h"
|
2017-04-06 23:44:11 +02:00
|
|
|
#include <scene/resources/mesh.h>
|
|
|
|
|
2019-04-21 15:47:50 +02:00
|
|
|
class VoxelMesherTransvoxel : public Reference {
|
|
|
|
GDCLASS(VoxelMesherTransvoxel, Reference)
|
2017-04-06 23:44:11 +02:00
|
|
|
|
|
|
|
public:
|
2019-04-21 15:47:50 +02:00
|
|
|
VoxelMesherTransvoxel();
|
2017-04-06 23:44:11 +02:00
|
|
|
|
2018-09-25 01:54:07 +02:00
|
|
|
Ref<ArrayMesh> build_mesh(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh = Ref<ArrayMesh>());
|
|
|
|
Array build(const VoxelBuffer &voxels, unsigned int channel);
|
2017-04-06 23:44:11 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct ReuseCell {
|
|
|
|
int vertices[4];
|
|
|
|
int case_index;
|
|
|
|
ReuseCell();
|
|
|
|
};
|
|
|
|
|
2018-09-25 01:54:07 +02:00
|
|
|
void build_internal(const VoxelBuffer &voxels, unsigned int channel);
|
2017-08-13 01:19:39 +02:00
|
|
|
ReuseCell &get_reuse_cell(Vector3i pos);
|
2017-04-06 23:44:11 +02:00
|
|
|
void emit_vertex(Vector3 primary, Vector3 normal);
|
|
|
|
|
|
|
|
private:
|
2017-08-13 01:19:39 +02:00
|
|
|
const Vector3i PAD = Vector3i(1, 1, 1);
|
2017-04-06 23:44:11 +02:00
|
|
|
|
|
|
|
Vector<ReuseCell> m_cache[2];
|
|
|
|
Vector3i m_block_size;
|
|
|
|
|
|
|
|
Vector<Vector3> m_output_vertices;
|
|
|
|
//Vector<Vector3> m_output_vertices_secondary;
|
|
|
|
Vector<Vector3> m_output_normals;
|
|
|
|
Vector<int> m_output_indices;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_MESHER_SMOOTH_H
|