Moved the transvoxel mesher into a folder.

This commit is contained in:
Relintai 2020-01-14 02:57:32 +01:00
parent 01bb492760
commit 4a8ed25544
10 changed files with 7 additions and 132 deletions

7
SCsub
View File

@ -26,9 +26,10 @@ sources = [
"data/voxel_light.cpp", "data/voxel_light.cpp",
"meshers/voxel_mesher.cpp", "meshers/voxel_mesher.cpp",
"meshers/transvoxel_cell_data.cpp",
"meshers/voxel_mesher_transvoxel.cpp", "meshers/transvoxel_uv_mesher/transvoxel_cell_data.cpp",
"meshers/transvoxel_tables.cpp", "meshers/transvoxel_uv_mesher/voxel_mesher_transvoxel.cpp",
"meshers/transvoxel_uv_mesher/transvoxel_tables.cpp",
"world/voxel_world.cpp", "world/voxel_world.cpp",
"world/voxel_chunk.cpp", "world/voxel_chunk.cpp",

View File

@ -1,8 +1,8 @@
#ifndef VOXEL_MESHER_TRANSVOXEL_H #ifndef VOXEL_MESHER_TRANSVOXEL_H
#define VOXEL_MESHER_TRANSVOXEL_H #define VOXEL_MESHER_TRANSVOXEL_H
#include "../voxel_mesher.h"
#include "core/reference.h" #include "core/reference.h"
#include "voxel_mesher.h"
#include "transvoxel_cell_data.h" #include "transvoxel_cell_data.h"

View File

@ -1,81 +0,0 @@
#include "voxel_mesh_data.h"
Ref<Material> VoxelMeshData::get_material() {
return _material;
}
void VoxelMeshData::set_material(Ref<Material> material) {
_material = material;
}
Ref<ArrayMesh> 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<ArrayMesh> m = _surface_tool->commit();
return m;
}
void VoxelMeshData::add_vertices_from(Vector<Vector3> &vertices) {
_vertices->append_array(vertices);
}
void VoxelMeshData::add_normals_from(Vector<Vector3> &normals) {
_normals->append_array(normals);
}
void VoxelMeshData::add_indices_from(Vector<int> &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<Vector3>());
_normals = memnew(Vector<Vector3>());
_indices = memnew(Vector<int>());
_surface_tool.instance();
}
VoxelMeshData::~VoxelMeshData() {
memdelete(_vertices);
memdelete(_normals);
memdelete(_indices);
_surface_tool.unref();
}
void VoxelMeshData::_bind_methods() {
}

View File

@ -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<Material> get_material();
void set_material(Ref<Material> material);
Ref<ArrayMesh> create_mesh();
void add_vertex(Vector3 vertex);
void add_normal(Vector3 normal);
void add_index(int iundex);
void add_vertices_from(Vector<Vector3> &vertices);
void add_normals_from(Vector<Vector3> &normals);
void add_indices_from(Vector<int> &indices);
void clear();
VoxelMeshData();
~VoxelMeshData();
protected:
static void _bind_methods();
private:
Ref<Material> _material;
Vector<Vector3> *_vertices;
Vector<Vector3> *_normals;
Vector<int> *_indices;
Ref<SurfaceTool> _surface_tool;
};
#endif

View File

@ -12,9 +12,9 @@
#include "library/voxelman_library_simple.h" #include "library/voxelman_library_simple.h"
#include "data/voxel_light.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.h"
#include "meshers/voxel_mesher_transvoxel.h"
#include "world/environment_data.h" #include "world/environment_data.h"
#include "world/voxel_chunk.h" #include "world/voxel_chunk.h"