2019-09-08 19:42:25 +01:00
|
|
|
#ifndef VOXEL_TOOL_TERRAIN_H
|
|
|
|
#define VOXEL_TOOL_TERRAIN_H
|
|
|
|
|
|
|
|
#include "voxel_tool.h"
|
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
namespace zylann::voxel {
|
|
|
|
|
2019-09-08 19:42:25 +01:00
|
|
|
class VoxelTerrain;
|
2022-01-09 23:23:59 +00:00
|
|
|
class VoxelBlockyLibrary;
|
2022-01-08 23:04:49 +00:00
|
|
|
class VoxelDataMap;
|
|
|
|
|
2019-09-08 19:42:25 +01:00
|
|
|
class VoxelToolTerrain : public VoxelTool {
|
|
|
|
GDCLASS(VoxelToolTerrain, VoxelTool)
|
|
|
|
public:
|
2020-07-28 20:32:33 +01:00
|
|
|
VoxelToolTerrain();
|
2020-11-21 18:28:06 +00:00
|
|
|
VoxelToolTerrain(VoxelTerrain *terrain);
|
2019-09-08 19:42:25 +01:00
|
|
|
|
2021-05-31 17:10:54 +01:00
|
|
|
bool is_area_editable(const Box3i &box) const override;
|
2021-12-13 21:38:10 +00:00
|
|
|
Ref<VoxelRaycastResult> raycast(
|
|
|
|
Vector3 p_pos, Vector3 p_dir, float p_max_distance, uint32_t p_collision_mask) override;
|
2019-09-08 19:42:25 +01:00
|
|
|
|
2020-08-10 19:03:01 +01:00
|
|
|
void set_voxel_metadata(Vector3i pos, Variant meta) override;
|
2021-09-09 18:52:00 +01:00
|
|
|
Variant get_voxel_metadata(Vector3i pos) const override;
|
2020-08-10 19:03:01 +01:00
|
|
|
|
2022-02-15 21:49:20 +00:00
|
|
|
void copy(Vector3i pos, Ref<gd::VoxelBuffer> dst, uint8_t channels_mask) const override;
|
|
|
|
void paste(Vector3i pos, Ref<gd::VoxelBuffer> p_voxels, uint8_t channels_mask, bool use_mask,
|
2021-12-13 21:38:10 +00:00
|
|
|
uint64_t mask_value) override;
|
2021-02-21 18:22:40 +00:00
|
|
|
|
2021-05-29 23:28:11 +01:00
|
|
|
void do_sphere(Vector3 center, float radius) override;
|
|
|
|
|
2020-08-10 19:03:01 +01:00
|
|
|
// Specialized API
|
|
|
|
|
2021-12-13 21:38:10 +00:00
|
|
|
void run_blocky_random_tick(
|
|
|
|
AABB voxel_area, int voxel_count, const Callable &callback, int block_batch_count) const;
|
2022-01-06 22:06:43 +00:00
|
|
|
|
|
|
|
// For easier unit testing (the regular one needs a terrain setup etc, harder to test atm)
|
|
|
|
// The `_static` suffix is because it otherwise conflicts with the non-static method when registering the class
|
2022-01-09 23:23:59 +00:00
|
|
|
static void run_blocky_random_tick_static(VoxelDataMap &map, Box3i voxel_box, const VoxelBlockyLibrary &lib,
|
2022-01-09 22:13:10 +00:00
|
|
|
int voxel_count, int batch_count, void *callback_data, bool (*callback)(void *, Vector3i, int64_t));
|
2022-01-06 22:06:43 +00:00
|
|
|
|
2021-12-13 21:38:10 +00:00
|
|
|
void for_each_voxel_metadata_in_area(AABB voxel_area, const Callable &callback);
|
2020-07-28 20:32:33 +01:00
|
|
|
|
2019-09-08 19:42:25 +01:00
|
|
|
protected:
|
2020-12-30 20:09:31 +00:00
|
|
|
uint64_t _get_voxel(Vector3i pos) const override;
|
|
|
|
float _get_voxel_f(Vector3i pos) const override;
|
2020-08-06 19:54:47 +01:00
|
|
|
void _set_voxel(Vector3i pos, uint64_t v) override;
|
2019-09-08 19:42:25 +01:00
|
|
|
void _set_voxel_f(Vector3i pos, float v) override;
|
2021-05-31 17:10:54 +01:00
|
|
|
void _post_edit(const Box3i &box) override;
|
2019-09-08 19:42:25 +01:00
|
|
|
|
|
|
|
private:
|
2020-07-28 20:32:33 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2019-09-08 19:42:25 +01:00
|
|
|
VoxelTerrain *_terrain = nullptr;
|
|
|
|
};
|
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
} // namespace zylann::voxel
|
|
|
|
|
2019-09-08 19:42:25 +01:00
|
|
|
#endif // VOXEL_TOOL_TERRAIN_H
|