mirror of
https://github.com/Relintai/godot_voxel.git
synced 2024-11-19 02:47:18 +01:00
Rename VoxelMesherSmooth => VoxelMesherTransvoxel
This commit is contained in:
parent
d53e43f115
commit
35ff5fd546
@ -8,13 +8,14 @@
|
||||
|
||||
namespace dmc {
|
||||
|
||||
// Faster than SurfaceTool, only does what is needed
|
||||
// Faster than SurfaceTool, only does what is needed to build a smooth mesh
|
||||
class MeshBuilder {
|
||||
public:
|
||||
inline void add_vertex(Vector3 position, Vector3 normal) {
|
||||
|
||||
int i = 0;
|
||||
|
||||
// TODO Debug this to see if it's effectively indexing
|
||||
if (_position_to_index.find(position) != _position_to_index.end()) {
|
||||
|
||||
i = _position_to_index[position];
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "marching_cubes_tables.h"
|
||||
#include "mesh_builder.h"
|
||||
|
||||
// Dual marching cubes
|
||||
// Algorithm taken from https://www.volume-gfx.com/volume-rendering/dual-marching-cubes/
|
||||
|
||||
namespace dmc {
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include "register_types.h"
|
||||
#include "dmc/voxel_mesher_dmc.h"
|
||||
#include "transvoxel/voxel_mesher_smooth.h"
|
||||
#include "transvoxel/voxel_mesher_transvoxel.h"
|
||||
#include "voxel_box_mover.h"
|
||||
#include "voxel_buffer.h"
|
||||
#include "voxel_library.h"
|
||||
@ -21,7 +21,7 @@ void register_voxel_types() {
|
||||
ClassDB::register_class<VoxelProvider>();
|
||||
ClassDB::register_class<VoxelProviderTest>();
|
||||
ClassDB::register_class<VoxelProviderImage>();
|
||||
ClassDB::register_class<VoxelMesherSmooth>();
|
||||
ClassDB::register_class<VoxelMesherTransvoxel>();
|
||||
ClassDB::register_class<VoxelBoxMover>();
|
||||
|
||||
ClassDB::register_class<VoxelMesherDMC>();
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
#include "voxel_mesher_smooth.h"
|
||||
#include "voxel_mesher_transvoxel.h"
|
||||
#include "transvoxel_tables.cpp"
|
||||
#include <core/os/os.h>
|
||||
|
||||
@ -58,17 +58,17 @@ void copy_to(PoolVector<T> &to, Vector<T> &from) {
|
||||
}
|
||||
}
|
||||
|
||||
VoxelMesherSmooth::ReuseCell::ReuseCell() {
|
||||
VoxelMesherTransvoxel::ReuseCell::ReuseCell() {
|
||||
case_index = 0;
|
||||
for (unsigned int i = 0; i < 4; ++i) {
|
||||
vertices[i] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
VoxelMesherSmooth::VoxelMesherSmooth() {
|
||||
VoxelMesherTransvoxel::VoxelMesherTransvoxel() {
|
||||
}
|
||||
|
||||
Ref<ArrayMesh> VoxelMesherSmooth::build_mesh(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh) {
|
||||
Ref<ArrayMesh> VoxelMesherTransvoxel::build_mesh(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh) {
|
||||
|
||||
ERR_FAIL_COND_V(voxels_ref.is_null(), Ref<ArrayMesh>());
|
||||
|
||||
@ -88,7 +88,7 @@ Ref<ArrayMesh> VoxelMesherSmooth::build_mesh(Ref<VoxelBuffer> voxels_ref, unsign
|
||||
return mesh;
|
||||
}
|
||||
|
||||
Array VoxelMesherSmooth::build(const VoxelBuffer &voxels, unsigned int channel) {
|
||||
Array VoxelMesherTransvoxel::build(const VoxelBuffer &voxels, unsigned int channel) {
|
||||
|
||||
ERR_FAIL_COND_V(channel >= VoxelBuffer::MAX_CHANNELS, Array());
|
||||
|
||||
@ -134,7 +134,7 @@ Array VoxelMesherSmooth::build(const VoxelBuffer &voxels, unsigned int channel)
|
||||
return surfaces;
|
||||
}
|
||||
|
||||
void VoxelMesherSmooth::build_internal(const VoxelBuffer &voxels, unsigned int channel) {
|
||||
void VoxelMesherTransvoxel::build_internal(const VoxelBuffer &voxels, unsigned int channel) {
|
||||
|
||||
// Each 2x2 voxel group is a "cell"
|
||||
|
||||
@ -381,18 +381,18 @@ void VoxelMesherSmooth::build_internal(const VoxelBuffer &voxels, unsigned int c
|
||||
//OS::get_singleton()->print("\n");
|
||||
}
|
||||
|
||||
VoxelMesherSmooth::ReuseCell &VoxelMesherSmooth::get_reuse_cell(Vector3i pos) {
|
||||
VoxelMesherTransvoxel::ReuseCell &VoxelMesherTransvoxel::get_reuse_cell(Vector3i pos) {
|
||||
int j = pos.z & 1;
|
||||
int i = pos.y * m_block_size.y + pos.x;
|
||||
return m_cache[j].write[i];
|
||||
}
|
||||
|
||||
void VoxelMesherSmooth::emit_vertex(Vector3 primary, Vector3 normal) {
|
||||
void VoxelMesherTransvoxel::emit_vertex(Vector3 primary, Vector3 normal) {
|
||||
m_output_vertices.push_back(primary - PAD.to_vec3());
|
||||
m_output_normals.push_back(normal);
|
||||
}
|
||||
|
||||
void VoxelMesherSmooth::_bind_methods() {
|
||||
void VoxelMesherTransvoxel::_bind_methods() {
|
||||
|
||||
ClassDB::bind_method(D_METHOD("build", "voxels", "channel", "existing_mesh"), &VoxelMesherSmooth::build_mesh, DEFVAL(Variant()));
|
||||
ClassDB::bind_method(D_METHOD("build", "voxels", "channel", "existing_mesh"), &VoxelMesherTransvoxel::build_mesh, DEFVAL(Variant()));
|
||||
}
|
@ -4,11 +4,11 @@
|
||||
#include "../voxel_buffer.h"
|
||||
#include <scene/resources/mesh.h>
|
||||
|
||||
class VoxelMesherSmooth : public Reference {
|
||||
GDCLASS(VoxelMesherSmooth, Reference)
|
||||
class VoxelMesherTransvoxel : public Reference {
|
||||
GDCLASS(VoxelMesherTransvoxel, Reference)
|
||||
|
||||
public:
|
||||
VoxelMesherSmooth();
|
||||
VoxelMesherTransvoxel();
|
||||
|
||||
Ref<ArrayMesh> build_mesh(Ref<VoxelBuffer> voxels_ref, unsigned int channel, Ref<ArrayMesh> mesh = Ref<ArrayMesh>());
|
||||
Array build(const VoxelBuffer &voxels, unsigned int channel);
|
@ -6,7 +6,7 @@
|
||||
#include <core/hash_map.h>
|
||||
#include <scene/main/node.h>
|
||||
|
||||
// Infinite voxel storage by means of octants like Gridmap
|
||||
// Infinite voxel storage by means of octants like Gridmap, within a constant LOD
|
||||
class VoxelMap : public Reference {
|
||||
GDCLASS(VoxelMap, Reference)
|
||||
public:
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "voxel_buffer.h"
|
||||
#include "voxel_mesher.h"
|
||||
#include "transvoxel/voxel_mesher_smooth.h"
|
||||
#include "transvoxel/voxel_mesher_transvoxel.h"
|
||||
|
||||
class VoxelMeshUpdater {
|
||||
public:
|
||||
@ -77,7 +77,7 @@ private:
|
||||
Mutex *_output_mutex;
|
||||
|
||||
Ref<VoxelMesher> _model_mesher;
|
||||
Ref<VoxelMesherSmooth> _smooth_mesher;
|
||||
Ref<VoxelMesherTransvoxel> _smooth_mesher;
|
||||
|
||||
Input _input;
|
||||
Output _output;
|
||||
|
Loading…
Reference in New Issue
Block a user