mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-12-22 01:26:50 +01:00
Fix compilation
This commit is contained in:
parent
f07ddb37e3
commit
dd64868c2e
@ -170,16 +170,16 @@ inline bool is_transparent(const VoxelLibrary & lib, int voxel_id) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Ref<Mesh> VoxelMesher::build_ref(Ref<VoxelBuffer> buffer_ref, unsigned int channel, Ref<Mesh> mesh) {
|
||||
ERR_FAIL_COND_V(buffer_ref.is_null(), Ref<Mesh>());
|
||||
Ref<ArrayMesh> VoxelMesher::build_ref(Ref<VoxelBuffer> buffer_ref, unsigned int channel, Ref<ArrayMesh> mesh) {
|
||||
ERR_FAIL_COND_V(buffer_ref.is_null(), Ref<ArrayMesh>());
|
||||
VoxelBuffer & buffer = **buffer_ref;
|
||||
mesh = build(buffer, channel, Vector3i(), buffer.get_size(), mesh);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Ref<Mesh> VoxelMesher::build(const VoxelBuffer & buffer, unsigned int channel, Vector3i min, Vector3i max, Ref<Mesh> mesh) {
|
||||
ERR_FAIL_COND_V(_library.is_null(), Ref<Mesh>());
|
||||
ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Ref<Mesh>());
|
||||
Ref<ArrayMesh> VoxelMesher::build(const VoxelBuffer & buffer, unsigned int channel, Vector3i min, Vector3i max, Ref<ArrayMesh> mesh) {
|
||||
ERR_FAIL_COND_V(_library.is_null(), Ref<ArrayMesh>());
|
||||
ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Ref<ArrayMesh>());
|
||||
|
||||
const VoxelLibrary & library = **_library;
|
||||
|
||||
@ -337,9 +337,9 @@ Ref<Mesh> VoxelMesher::build(const VoxelBuffer & buffer, unsigned int channel, V
|
||||
|
||||
// Commit mesh
|
||||
|
||||
Ref<Mesh> mesh_ref = mesh;
|
||||
Ref<ArrayMesh> mesh_ref = mesh;
|
||||
if(mesh.is_null())
|
||||
mesh_ref = Ref<Mesh>(memnew(Mesh));
|
||||
mesh_ref = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||
|
||||
for (unsigned int i = 0; i < MAX_MATERIALS; ++i) {
|
||||
if (_materials[i].is_valid()) {
|
||||
|
@ -31,8 +31,8 @@ public:
|
||||
void set_occlusion_enabled(bool enable);
|
||||
bool get_occlusion_enabled() const { return _bake_occlusion; }
|
||||
|
||||
Ref<Mesh> build(const VoxelBuffer & buffer_ref, unsigned int channel, Vector3i min, Vector3i max, Ref<Mesh> mesh=Ref<Mesh>());
|
||||
Ref<Mesh> build_ref(Ref<VoxelBuffer> buffer_ref, unsigned int channel, Ref<Mesh> mesh=Ref<Mesh>());
|
||||
Ref<ArrayMesh> build(const VoxelBuffer & buffer_ref, unsigned int channel, Vector3i min, Vector3i max, Ref<ArrayMesh> mesh=Ref<Mesh>());
|
||||
Ref<ArrayMesh> build_ref(Ref<VoxelBuffer> buffer_ref, unsigned int channel, Ref<ArrayMesh> mesh=Ref<ArrayMesh>());
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -70,18 +70,18 @@ VoxelMesherSmooth::ReuseCell::ReuseCell() {
|
||||
VoxelMesherSmooth::VoxelMesherSmooth() {
|
||||
}
|
||||
|
||||
Ref<Mesh> VoxelMesherSmooth::build_ref(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<Mesh> mesh) {
|
||||
Ref<ArrayMesh> VoxelMesherSmooth::build_ref(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh) {
|
||||
|
||||
ERR_FAIL_COND_V(voxels_ref.is_null(), Ref<Mesh>());
|
||||
ERR_FAIL_COND_V(voxels_ref.is_null(), Ref<ArrayMesh>());
|
||||
|
||||
VoxelBuffer & voxels = **voxels_ref;
|
||||
|
||||
return build(voxels, channel, mesh);
|
||||
}
|
||||
|
||||
Ref<Mesh> VoxelMesherSmooth::build(const VoxelBuffer & voxels, unsigned int channel, Ref<Mesh> mesh) {
|
||||
Ref<ArrayMesh> VoxelMesherSmooth::build(const VoxelBuffer & voxels, unsigned int channel, Ref<ArrayMesh> mesh) {
|
||||
|
||||
ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Ref<Mesh>());
|
||||
ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Ref<ArrayMesh>());
|
||||
|
||||
// Initialize dynamic memory:
|
||||
// These vectors are re-used.
|
||||
@ -100,7 +100,7 @@ Ref<Mesh> VoxelMesherSmooth::build(const VoxelBuffer & voxels, unsigned int chan
|
||||
|
||||
if(m_output_vertices.size() == 0) {
|
||||
// The mesh can be empty
|
||||
return Ref<Mesh>();
|
||||
return Ref<ArrayMesh>();
|
||||
}
|
||||
|
||||
PoolVector<Vector3> vertices;
|
||||
@ -120,7 +120,7 @@ Ref<Mesh> VoxelMesherSmooth::build(const VoxelBuffer & voxels, unsigned int chan
|
||||
arrays[Mesh::ARRAY_INDEX] = indices;
|
||||
|
||||
if(mesh.is_null())
|
||||
mesh = Ref<Mesh>(memnew(Mesh));
|
||||
mesh = Ref<ArrayMesh>(memnew(ArrayMesh));
|
||||
|
||||
mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, arrays);
|
||||
|
||||
|
@ -10,8 +10,8 @@ class VoxelMesherSmooth : public Reference {
|
||||
public:
|
||||
VoxelMesherSmooth();
|
||||
|
||||
Ref<Mesh> build_ref(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<Mesh> mesh=Ref<Mesh>());
|
||||
Ref<Mesh> build(const VoxelBuffer & voxels, unsigned int channel, Ref<Mesh> mesh=Ref<Mesh>());
|
||||
Ref<ArrayMesh> build_ref(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh=Ref<ArrayMesh>());
|
||||
Ref<ArrayMesh> build(const VoxelBuffer & voxels, unsigned int channel, Ref<ArrayMesh> mesh=Ref<ArrayMesh>());
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
@ -356,7 +356,7 @@ void VoxelTerrain::update_block_mesh(Vector3i block_pos) {
|
||||
// TODO Re-use existing meshes to optimize memory cost
|
||||
|
||||
// Build cubic parts of the mesh
|
||||
Ref<Mesh> mesh = _mesher->build(nbuffer, Voxel::CHANNEL_TYPE, Vector3i(0,0,0), nbuffer.get_size()-Vector3(1,1,1));
|
||||
Ref<ArrayMesh> mesh = _mesher->build(nbuffer, Voxel::CHANNEL_TYPE, Vector3i(0,0,0), nbuffer.get_size()-Vector3(1,1,1));
|
||||
// Build smooth parts of the mesh
|
||||
_mesher_smooth->build(nbuffer, Voxel::CHANNEL_ISOLEVEL, mesh);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user