2020-09-06 19:01:12 +01:00
|
|
|
#ifndef VOXEL_VIEWER_H
|
|
|
|
#define VOXEL_VIEWER_H
|
|
|
|
|
2021-12-13 21:38:10 +00:00
|
|
|
#include <scene/3d/node_3d.h>
|
2020-09-06 19:01:12 +01:00
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
namespace zylann::voxel {
|
|
|
|
|
2020-09-06 19:01:12 +01:00
|
|
|
// Triggers loading of voxel nodes around its position. Voxels will update in priority closer to viewers.
|
|
|
|
// Usually added as child of the player's camera.
|
2021-12-13 21:38:10 +00:00
|
|
|
class VoxelViewer : public Node3D {
|
|
|
|
GDCLASS(VoxelViewer, Node3D)
|
2020-09-06 19:01:12 +01:00
|
|
|
public:
|
|
|
|
VoxelViewer();
|
|
|
|
|
|
|
|
// Distance in world space units
|
|
|
|
void set_view_distance(unsigned int distance);
|
|
|
|
unsigned int get_view_distance() const;
|
2020-10-22 22:43:31 +01:00
|
|
|
// TODO Collision distance
|
2020-09-06 19:01:12 +01:00
|
|
|
|
|
|
|
void set_requires_visuals(bool enabled);
|
|
|
|
bool is_requiring_visuals() const;
|
|
|
|
|
|
|
|
void set_requires_collisions(bool enabled);
|
|
|
|
bool is_requiring_collisions() const;
|
|
|
|
|
2022-01-31 21:23:39 +00:00
|
|
|
void set_requires_data_block_notifications(bool enabled);
|
|
|
|
bool is_requiring_data_block_notifications() const;
|
|
|
|
|
|
|
|
void set_network_peer_id(int id);
|
|
|
|
int get_network_peer_id() const;
|
|
|
|
|
2020-09-06 19:01:12 +01:00
|
|
|
protected:
|
|
|
|
void _notification(int p_what);
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
|
|
|
void _process();
|
|
|
|
bool is_active() const;
|
|
|
|
|
|
|
|
uint32_t _viewer_id = 0;
|
|
|
|
unsigned int _view_distance = 128;
|
|
|
|
bool _requires_visuals = true;
|
2021-10-15 22:51:53 +01:00
|
|
|
bool _requires_collisions = true;
|
2022-01-31 21:23:39 +00:00
|
|
|
bool _requires_data_block_notifications = false;
|
|
|
|
int _network_peer_id = -1;
|
2020-09-06 19:01:12 +01:00
|
|
|
};
|
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
} // namespace zylann::voxel
|
|
|
|
|
2020-09-06 19:01:12 +01:00
|
|
|
#endif // VOXEL_VIEWER_H
|