godot_voxel/meshers/blocky/voxel_mesher_blocky.h

56 lines
1.5 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_library.h"
#include "../voxel_mesher.h"
2018-09-19 12:25:04 -07:00
#include <core/reference.h>
2017-08-12 16:19:39 -07:00
#include <scene/resources/mesh.h>
2019-04-28 13:02:42 -07:00
#include <vector>
class VoxelMesherBlocky : public VoxelMesher {
GDCLASS(VoxelMesherBlocky, VoxelMesher)
public:
2016-12-31 19:40:16 -08:00
static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed.
static const int MINIMUM_PADDING = 1;
VoxelMesherBlocky();
2016-12-31 19:40:16 -08:00
void set_library(Ref<VoxelLibrary> library);
2016-12-31 20:23:22 -08:00
Ref<VoxelLibrary> get_library() const { return _library; }
2016-12-31 19:40:16 -08:00
void set_occlusion_darkness(float darkness);
2016-12-31 20:23:22 -08:00
float get_occlusion_darkness() const { return _baked_occlusion_darkness; }
2016-12-31 19:40:16 -08:00
void set_occlusion_enabled(bool enable);
2016-12-31 20:23:22 -08:00
bool get_occlusion_enabled() const { return _bake_occlusion; }
2016-12-31 19:40:16 -08:00
void build(VoxelMesher::Output &output, const VoxelBuffer &voxels, int padding) override;
int get_minimum_padding() const override;
VoxelMesher *clone() override;
protected:
2016-12-31 19:40:16 -08:00
static void _bind_methods();
2016-12-31 20:23:22 -08:00
private:
2019-04-28 13:02:42 -07:00
// Using std::vector because they make this mesher twice as fast than Godot Vectors.
// See why: https://github.com/godotengine/godot/issues/24731
struct Arrays {
2019-04-28 13:02:42 -07:00
std::vector<Vector3> positions;
std::vector<Vector3> normals;
std::vector<Vector2> uvs;
std::vector<Color> colors;
std::vector<int> indices;
};
2016-12-31 20:23:22 -08:00
Ref<VoxelLibrary> _library;
Arrays _arrays[MAX_MATERIALS];
2016-12-31 20:23:22 -08:00
float _baked_occlusion_darkness;
bool _bake_occlusion;
};
#endif // VOXEL_MESHER_BLOCKY_H