From 4a8ed25544a12e924adcdd354af89ed5c858dbac Mon Sep 17 00:00:00 2001 From: Relintai Date: Tue, 14 Jan 2020 02:57:32 +0100 Subject: [PATCH] Moved the transvoxel mesher into a folder. --- SCsub | 7 +- .../transvoxel_cell_data.cpp | 0 .../transvoxel_cell_data.h | 0 .../transvoxel_tables.cpp | 0 .../transvoxel_tables.h | 0 .../voxel_mesher_transvoxel.cpp | 0 .../voxel_mesher_transvoxel.h | 2 +- meshers/voxel_mesh_data.cpp | 81 ------------------- meshers/voxel_mesh_data.h | 45 ----------- register_types.cpp | 4 +- 10 files changed, 7 insertions(+), 132 deletions(-) rename meshers/{ => transvoxel_uv_mesher}/transvoxel_cell_data.cpp (100%) rename meshers/{ => transvoxel_uv_mesher}/transvoxel_cell_data.h (100%) rename meshers/{ => transvoxel_uv_mesher}/transvoxel_tables.cpp (100%) rename meshers/{ => transvoxel_uv_mesher}/transvoxel_tables.h (100%) rename meshers/{ => transvoxel_uv_mesher}/voxel_mesher_transvoxel.cpp (100%) rename meshers/{ => transvoxel_uv_mesher}/voxel_mesher_transvoxel.h (98%) delete mode 100644 meshers/voxel_mesh_data.cpp delete mode 100644 meshers/voxel_mesh_data.h diff --git a/SCsub b/SCsub index a2cd8b5..2ba8196 100644 --- a/SCsub +++ b/SCsub @@ -26,9 +26,10 @@ sources = [ "data/voxel_light.cpp", "meshers/voxel_mesher.cpp", - "meshers/transvoxel_cell_data.cpp", - "meshers/voxel_mesher_transvoxel.cpp", - "meshers/transvoxel_tables.cpp", + + "meshers/transvoxel_uv_mesher/transvoxel_cell_data.cpp", + "meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.cpp", + "meshers/transvoxel_uv_mesher/transvoxel_tables.cpp", "world/voxel_world.cpp", "world/voxel_chunk.cpp", diff --git a/meshers/transvoxel_cell_data.cpp b/meshers/transvoxel_uv_mesher/transvoxel_cell_data.cpp similarity index 100% rename from meshers/transvoxel_cell_data.cpp rename to meshers/transvoxel_uv_mesher/transvoxel_cell_data.cpp diff --git a/meshers/transvoxel_cell_data.h b/meshers/transvoxel_uv_mesher/transvoxel_cell_data.h similarity index 100% rename from meshers/transvoxel_cell_data.h rename to meshers/transvoxel_uv_mesher/transvoxel_cell_data.h diff --git a/meshers/transvoxel_tables.cpp b/meshers/transvoxel_uv_mesher/transvoxel_tables.cpp similarity index 100% rename from meshers/transvoxel_tables.cpp rename to meshers/transvoxel_uv_mesher/transvoxel_tables.cpp diff --git a/meshers/transvoxel_tables.h b/meshers/transvoxel_uv_mesher/transvoxel_tables.h similarity index 100% rename from meshers/transvoxel_tables.h rename to meshers/transvoxel_uv_mesher/transvoxel_tables.h diff --git a/meshers/voxel_mesher_transvoxel.cpp b/meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.cpp similarity index 100% rename from meshers/voxel_mesher_transvoxel.cpp rename to meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.cpp diff --git a/meshers/voxel_mesher_transvoxel.h b/meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h similarity index 98% rename from meshers/voxel_mesher_transvoxel.h rename to meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h index 83fa06c..2d66083 100644 --- a/meshers/voxel_mesher_transvoxel.h +++ b/meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h @@ -1,8 +1,8 @@ #ifndef VOXEL_MESHER_TRANSVOXEL_H #define VOXEL_MESHER_TRANSVOXEL_H +#include "../voxel_mesher.h" #include "core/reference.h" -#include "voxel_mesher.h" #include "transvoxel_cell_data.h" diff --git a/meshers/voxel_mesh_data.cpp b/meshers/voxel_mesh_data.cpp deleted file mode 100644 index 0cef6bb..0000000 --- a/meshers/voxel_mesh_data.cpp +++ /dev/null @@ -1,81 +0,0 @@ -#include "voxel_mesh_data.h" - -Ref VoxelMeshData::get_material() { - return _material; -} - -void VoxelMeshData::set_material(Ref material) { - _material = material; -} - -Ref VoxelMeshData::create_mesh() { - _surface_tool->begin(Mesh::PRIMITIVE_TRIANGLES); - _surface_tool->set_material(_material); - - int len = _vertices->size(); - - for (int i = 0; i < len; ++i) { - _surface_tool->add_normal(_normals->get(i)); - //_surface_tool->add_color(_colors->get(i)); - //_surface_tool->add_uv(_uvs->get(i)); - - _surface_tool->add_vertex(_vertices->get(i)); - } - - for (int i = 0; i < _indices->size(); ++i) { - _surface_tool->add_index(_indices->get(i)); - } - - Ref m = _surface_tool->commit(); - - return m; -} - -void VoxelMeshData::add_vertices_from(Vector &vertices) { - _vertices->append_array(vertices); -} - -void VoxelMeshData::add_normals_from(Vector &normals) { - _normals->append_array(normals); -} - -void VoxelMeshData::add_indices_from(Vector &indices) { - _indices->append_array(indices); -} - -void VoxelMeshData::add_vertex(Vector3 vertex) { - _vertices->push_back(vertex); -} - -void VoxelMeshData::add_normal(Vector3 normal) { - _normals->push_back(normal); -} - -void VoxelMeshData::add_index(int iundex) { - _indices->push_back(iundex); -} - -void VoxelMeshData::clear() { - _vertices->clear(); - _normals->clear(); - _indices->clear(); -} - -VoxelMeshData::VoxelMeshData() { - _vertices = memnew(Vector()); - _normals = memnew(Vector()); - _indices = memnew(Vector()); - - _surface_tool.instance(); -} - -VoxelMeshData::~VoxelMeshData() { - memdelete(_vertices); - memdelete(_normals); - memdelete(_indices); - - _surface_tool.unref(); -} - -void VoxelMeshData::_bind_methods() { -} diff --git a/meshers/voxel_mesh_data.h b/meshers/voxel_mesh_data.h deleted file mode 100644 index b077473..0000000 --- a/meshers/voxel_mesh_data.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef VOXEL_MESH_DATA_H -#define VOXEL_MESH_DATA_H - -#include "core/reference.h" -#include "core/vector.h" -#include "scene/resources/material.h" -#include "scene/resources/mesh.h" -#include "scene/resources/surface_tool.h" - -class VoxelMeshData : public Reference { - GDCLASS(VoxelMeshData, Reference) - -public: - Ref get_material(); - void set_material(Ref material); - - Ref create_mesh(); - - void add_vertex(Vector3 vertex); - void add_normal(Vector3 normal); - void add_index(int iundex); - - void add_vertices_from(Vector &vertices); - void add_normals_from(Vector &normals); - void add_indices_from(Vector &indices); - - void clear(); - - VoxelMeshData(); - ~VoxelMeshData(); - -protected: - static void _bind_methods(); - -private: - Ref _material; - - Vector *_vertices; - Vector *_normals; - Vector *_indices; - - Ref _surface_tool; -}; - -#endif diff --git a/register_types.cpp b/register_types.cpp index 3487e06..43b14e5 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -12,9 +12,9 @@ #include "library/voxelman_library_simple.h" #include "data/voxel_light.h" -#include "meshers/transvoxel_cell_data.h" +#include "meshers/transvoxel_uv_mesher/transvoxel_cell_data.h" +#include "meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.h" #include "meshers/voxel_mesher.h" -#include "meshers/voxel_mesher_transvoxel.h" #include "world/environment_data.h" #include "world/voxel_chunk.h"