godot_voxel/meshers/blocky/voxel_mesher_blocky.h

57 lines
1.6 KiB
C
Raw Normal View History

#ifndef VOXEL_MESHER_BLOCKY_H
#define VOXEL_MESHER_BLOCKY_H
#include "../../util/zprofiling.h"
#include "../../voxel.h"
#include "../../voxel_buffer.h"
#include "../../voxel_library.h"
2018-09-19 21:25:04 +02:00
#include <core/reference.h>
2017-08-13 01:19:39 +02:00
#include <scene/resources/mesh.h>
// TODO Should be renamed VoxelMesherBlocky or something like that
class VoxelMesherBlocky : public Reference {
GDCLASS(VoxelMesherBlocky, Reference)
public:
2017-01-01 04:40:16 +01:00
static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed.
static const int MINIMUM_PADDING = 1;
VoxelMesherBlocky();
2017-01-01 04:40:16 +01:00
void set_library(Ref<VoxelLibrary> library);
2017-01-01 05:23:22 +01:00
Ref<VoxelLibrary> get_library() const { return _library; }
2017-01-01 04:40:16 +01:00
void set_occlusion_darkness(float darkness);
2017-01-01 05:23:22 +01:00
float get_occlusion_darkness() const { return _baked_occlusion_darkness; }
2017-01-01 04:40:16 +01:00
void set_occlusion_enabled(bool enable);
2017-01-01 05:23:22 +01:00
bool get_occlusion_enabled() const { return _bake_occlusion; }
2017-01-01 04:40:16 +01:00
Array build(const VoxelBuffer &buffer_ref, unsigned int channel, int padding);
Ref<ArrayMesh> build_mesh(Ref<VoxelBuffer> buffer_ref, unsigned int channel, Array materials, Ref<ArrayMesh> mesh = Ref<ArrayMesh>());
protected:
2017-01-01 04:40:16 +01:00
static void _bind_methods();
2017-01-01 05:23:22 +01:00
private:
struct Arrays {
Vector<Vector3> positions;
Vector<Vector3> normals;
Vector<Vector2> uvs;
Vector<Color> colors;
Vector<int> indices;
};
2017-01-01 05:23:22 +01:00
Ref<VoxelLibrary> _library;
Arrays _arrays[MAX_MATERIALS];
2017-01-01 05:23:22 +01:00
float _baked_occlusion_darkness;
bool _bake_occlusion;
#ifdef VOXEL_PROFILING
ZProfiler _zprofiler;
Dictionary get_profiling_info() const { return _zprofiler.get_all_serialized_info(); }
#endif
};
#endif // VOXEL_MESHER_BLOCKY_H