#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" #include #include #include class VoxelMesherBlocky : public VoxelMesher { GDCLASS(VoxelMesherBlocky, VoxelMesher) public: static const unsigned int MAX_MATERIALS = 8; // Arbitrary. Tweak if needed. static const int MINIMUM_PADDING = 1; VoxelMesherBlocky(); void set_library(Ref library); Ref get_library() const { return _library; } void set_occlusion_darkness(float darkness); float get_occlusion_darkness() const { return _baked_occlusion_darkness; } void set_occlusion_enabled(bool enable); bool get_occlusion_enabled() const { return _bake_occlusion; } void build(VoxelMesher::Output &output, const VoxelBuffer &voxels, int padding) override; int get_minimum_padding() const override; protected: static void _bind_methods(); private: // 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 { std::vector positions; std::vector normals; std::vector uvs; std::vector colors; std::vector indices; }; Ref _library; Arrays _arrays[MAX_MATERIALS]; 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