2017-08-20 06:48:55 -07:00
|
|
|
#ifndef VOXEL_BLOCK_H
|
|
|
|
#define VOXEL_BLOCK_H
|
|
|
|
|
|
|
|
#include "voxel_buffer.h"
|
|
|
|
|
|
|
|
#include <scene/3d/mesh_instance.h>
|
|
|
|
#include <scene/3d/physics_body.h>
|
|
|
|
|
|
|
|
// Internal structure holding a reference to mesh visuals, physics and a block of voxel data.
|
|
|
|
// TODO Voxel data should be separated from this
|
|
|
|
class VoxelBlock {
|
|
|
|
public:
|
|
|
|
Ref<VoxelBuffer> voxels; // SIZE*SIZE*SIZE voxels
|
|
|
|
Vector3i pos;
|
|
|
|
|
|
|
|
static VoxelBlock *create(Vector3i bpos, Ref<VoxelBuffer> buffer, unsigned int size);
|
|
|
|
|
2017-08-20 09:37:08 -07:00
|
|
|
void set_mesh(Ref<Mesh> mesh, Ref<World> world);
|
2017-08-20 06:48:55 -07:00
|
|
|
|
2017-08-27 17:32:23 -07:00
|
|
|
void enter_world(World *world);
|
|
|
|
void exit_world();
|
|
|
|
void set_visible(bool visible);
|
|
|
|
|
2017-08-20 06:48:55 -07:00
|
|
|
private:
|
|
|
|
VoxelBlock();
|
2017-08-20 09:37:08 -07:00
|
|
|
|
|
|
|
Vector3i _position_in_voxels;
|
|
|
|
|
|
|
|
Ref<Mesh> _mesh;
|
|
|
|
RID _mesh_instance;
|
2018-09-29 09:08:05 -07:00
|
|
|
int _mesh_update_count;
|
2017-08-20 06:48:55 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_BLOCK_H
|