mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-11-11 20:35:08 +01:00
43 lines
1019 B
C++
43 lines
1019 B
C++
#ifndef VOXEL_MESHER_SMOOTH_H
|
|
#define VOXEL_MESHER_SMOOTH_H
|
|
|
|
#include "voxel_buffer.h"
|
|
#include <scene/resources/mesh.h>
|
|
|
|
class VoxelMesherSmooth : public Reference {
|
|
GDCLASS(VoxelMesherSmooth, Reference)
|
|
|
|
public:
|
|
VoxelMesherSmooth();
|
|
|
|
Ref<Mesh> build_ref(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<Mesh> mesh=Ref<Mesh>());
|
|
Ref<Mesh> build(const VoxelBuffer & voxels, unsigned int channel, Ref<Mesh> mesh=Ref<Mesh>());
|
|
|
|
protected:
|
|
static void _bind_methods();
|
|
|
|
private:
|
|
struct ReuseCell {
|
|
int vertices[4];
|
|
int case_index;
|
|
ReuseCell();
|
|
};
|
|
|
|
void build_mesh(const VoxelBuffer & voxels, unsigned int channel);
|
|
ReuseCell & get_reuse_cell(Vector3i pos);
|
|
void emit_vertex(Vector3 primary, Vector3 normal);
|
|
|
|
private:
|
|
const Vector3i PAD = Vector3i(1,1,1);
|
|
|
|
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
|