diff --git a/README.md b/README.md index b6586a2..a8ffe43 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ experimental terrain and building engine for godot, based on voxelman. -# Voxelman's readme: (will update later) +# Terraman's readme: (will update later) A voxel engine module for godot, focusing more on editor integration, gameplay-related features, and extendability (even from gdscript), without sacrificing too much speed. @@ -15,8 +15,8 @@ check whether it works from time to time. ## Optional Dependencies -`https://github.com/Relintai/thread_pool`: Threaded chunk generation. Without this Voxelman is single threaded! \ -`https://github.com/Relintai/texture_packer`: You get access to [VoxelmanLibraryMerger](#voxelmanlibrarymerger). \ +`https://github.com/Relintai/thread_pool`: Threaded chunk generation. Without this Terraman is single threaded! \ +`https://github.com/Relintai/texture_packer`: You get access to [TerramanLibraryMerger](#voxelmanlibrarymerger). \ `https://github.com/Relintai/mesh_data_resource`: You get access to a bunch of properties, and methods that can manipulate meshes.\ `https://github.com/Relintai/props`: You get access to a bunch of properties, and methods that can manipulate, and use props.\ `https://github.com/Relintai/mesh_utils`: Lets you use lod levels higher than 4 by default. @@ -28,29 +28,29 @@ repo, should you want to. It contains all my modules. ## Usage -First create a scene, and add a VoxelWorldBlocky node into it. Create a VoxelmanLibrary, and assign it to the Library property. -Also, add a VoxelSurface into your library. +First create a scene, and add a TerraWorldBlocky node into it. Create a TerramanLibrary, and assign it to the Library property. +Also, add a TerraSurface into your library. -(VoxelWorldBlocky is the only one that works properly for now, this will soon be fixed!) +(TerraWorldBlocky is the only one that works properly for now, this will soon be fixed!) Tick the editable property, deselect, then select the world again, and click the insert button at the top toolbar, or press B to insert a voxel at the inspector's camera's location. Select the add button, and now you can just add voxels with the mouse, by clicking on the newly added voxel. -## VoxelmanLibrary +## TerramanLibrary -This class stores the materials, and the VoxelSurfaces. +This class stores the materials, and the TerraSurfaces. Note: If you want lods, assign equal (or more) materials than your maximum lod level. If you only want one material just assign it multiple times. If you don't then your meshes won't have materials (They will be white). -### VoxelmanLibrarySimple +### TerramanLibrarySimple The simplest library, just assign a material with a texture, and using the atlas_rows and atlas_culomns properties to tell the system how the UVs should be divided. -### VoxelmanLibraryMerger +### TerramanLibraryMerger You will only have this if your godot also contains https://github.com/Relintai/texture_packer @@ -60,41 +60,41 @@ You can assign any texture to your surfaces with this, and it will merge them to The 2 base classes: -VoxelWorld: Basic world, does not do anything until you implemnent the required virtual methods!\ -VoxelWorldDefault: This adds threading, and LoD storage support to VoxelWorld. Will not create meshes for you! +TerraWorld: Basic world, does not do anything until you implemnent the required virtual methods!\ +TerraWorldDefault: This adds threading, and LoD storage support to TerraWorld. Will not create meshes for you! -### VoxelWorldBlocky +### TerraWorldBlocky The most basic world. It is the Minecraft-style world. -### VoxelWorldMarchingCubes +### TerraWorldMarchingCubes -A marching cubes based Voxel World. Actually it uses a modified version of the Transvoxel tables. It is UV mapped. +A marching cubes based Terra World. Actually it uses a modified version of the Transvoxel tables. It is UV mapped. -### VoxelWorldCubic +### TerraWorldCubic This is my own meshing algorithm, it's basicly a Minecraft style mesher that can take isolevel into account. ### Level generation -Assign a VoxelManLevelGenerator to the `World`'s `Level Generator` property. +Assign a TerraManLevelGenerator to the `World`'s `Level Generator` property. -You can write your own algorithm by implementing the ``` void _generate_chunk(chunk: VoxelChunk) virtual ``` method. +You can write your own algorithm by implementing the ``` void _generate_chunk(chunk: TerraChunk) virtual ``` method. -`VoxelManLevelGeneratorFlat` is also available, it will generate a floor for you, if you use it. +`TerraManLevelGeneratorFlat` is also available, it will generate a floor for you, if you use it. -## VoxelJobs +## TerraJobs Producing just a terrarin mesh for a chunk is not that hard by itself. However when you start adding layers/features like lod generation, collision meshes (especially since manipulating the physics server is not threadsafe), vertex volumetric lights, props, snapping props, props with vertex lights, etc chunk mesh generation can quicly become a serious mess. -VoxelJobs are meant to solve the issue with this complexity. +TerraJobs are meant to solve the issue with this complexity. They also provide a way to easily modularize mesh generation. -### VoxelJob +### TerraJob Base class for jobs. @@ -105,43 +105,43 @@ A job has a reference to it's owner chunk. If you implement your own jobs, when your job finishes call `next_job()`. -### VoxelLightJob +### TerraLightJob -This is the job that will generate vertex light based ao, random ao, and will bake your `VoxelLight`s. +This is the job that will generate vertex light based ao, random ao, and will bake your `TerraLight`s. -### VoxelTerrarinJob +### TerraTerrarinJob This will generate your terrarin collider and mesh (with lods) for you, using the meshers that you add into it. -### VoxelPropJob +### TerraPropJob This will generate your prop meshes (with lods). ### Internal workings -#### VoxelWorld +#### TerraWorld -Whenever you want to spawn a chunk your World will create it using the ``` VoxelChunk _create_chunk(x: int, y: int, z: int, chunk: VoxelChunk) virtual ``` method. +Whenever you want to spawn a chunk your World will create it using the ``` TerraChunk _create_chunk(x: int, y: int, z: int, chunk: TerraChunk) virtual ``` method. Since properly initializing a chunk usually takes quite a few steps that you probably don't want to repeat everywhere the `chunk` parameter was added. This means you can just call the super `_create_chunk` methods, and you won't need to worry about your chunk getting overridden. Like: Note that `_create_chunk` is also responsible for initializing chunks if you have them stored inside a scene. -This is done by `setup_chunk(shunk)` in `VoxelWorld`. +This is done by `setup_chunk(shunk)` in `TerraWorld`. ``` - func _create_chunk(x : int, y : int, z : int, chunk : VoxelChunk) -> VoxelChunk: + func _create_chunk(x : int, y : int, z : int, chunk : TerraChunk) -> TerraChunk: if !chunk: chunk = MyChunk.new() # We need to check whether or not we need to initialize jobs if chunk.job_get_count() == 0: # Setup a blocky (minecratf like) mesher job - var tj : VoxelTerrarinJob = VoxelTerrarinJob.new() + var tj : TerraTerrarinJob = TerraTerrarinJob.new() - tj.add_mesher(VoxelMesherBlocky.new()) - tj.add_liquid_mesher(VoxelMesherLiquidBlocky.new()) + tj.add_mesher(TerraMesherBlocky.new()) + tj.add_liquid_mesher(TerraMesherLiquidBlocky.new()) chunk.job_add(tj); @@ -150,17 +150,17 @@ This is done by `setup_chunk(shunk)` in `VoxelWorld`. return ._create_chunk(x, y, z, chunk) ``` -#### VoxelChunk +#### TerraChunk -Stores terrarin data, prop data. And mesh data (VoxelChunkDefault), and the mesh generation jobs. +Stores terrarin data, prop data. And mesh data (TerraChunkDefault), and the mesh generation jobs. When it starts building meshes it will start submitting jobs to thread_pool (if present) one by one. -#### VoxelMesher +#### TerraMesher -If you want to implement your own meshing algorithm you can do so by overriding ``` void _add_chunk(chunk: VoxelChunk) virtual ```. +If you want to implement your own meshing algorithm you can do so by overriding ``` void _add_chunk(chunk: TerraChunk) virtual ```. -VoxelMesher works similarly to SurfaceTool, so first you need to set colors, uvs, etc and then call add_vertex. +TerraMesher works similarly to SurfaceTool, so first you need to set colors, uvs, etc and then call add_vertex. They won't get reset, so for exaple if you want all your vertices to have a certain color, you can get away with setting it only once. ## Compiling diff --git a/SCsub b/SCsub index 4e22350..6cad5fc 100644 --- a/SCsub +++ b/SCsub @@ -25,65 +25,65 @@ sources = [ "register_types.cpp", - #"library/voxelman_library.cpp", - #"library/voxelman_library_simple.cpp", + "library/voxelman_library.cpp", + "library/voxelman_library_simple.cpp", - #"nodes/voxelman_light.cpp", + "nodes/voxelman_light.cpp", - #"library/voxel_surface.cpp", - #"library/voxel_surface_simple.cpp", + "library/voxel_surface.cpp", + "library/voxel_surface_simple.cpp", - #"data/voxel_light.cpp", + "data/voxel_light.cpp", - #"meshers/voxel_mesher.cpp", + "meshers/voxel_mesher.cpp", - #"meshers/marching_cubes/marching_cubes_cell_data.cpp", - #"meshers/marching_cubes/voxel_mesher_marching_cubes.cpp", - #"meshers/marching_cubes/marching_cubes_tables.cpp", + "meshers/marching_cubes/marching_cubes_cell_data.cpp", + "meshers/marching_cubes/voxel_mesher_marching_cubes.cpp", + "meshers/marching_cubes/marching_cubes_tables.cpp", - #"meshers/blocky/voxel_mesher_blocky.cpp", - #"meshers/blocky/voxel_mesher_liquid_blocky.cpp", - #"meshers/default/voxel_mesher_default.cpp", + "meshers/blocky/voxel_mesher_blocky.cpp", + "meshers/blocky/voxel_mesher_liquid_blocky.cpp", + "meshers/default/voxel_mesher_default.cpp", - #"world/voxel_world.cpp", - #"world/voxel_chunk.cpp", - #"world/voxel_structure.cpp", - #"world/block_voxel_structure.cpp", - #"world/environment_data.cpp", + "world/voxel_world.cpp", + "world/voxel_chunk.cpp", + "world/voxel_structure.cpp", + "world/block_voxel_structure.cpp", + "world/environment_data.cpp", - #"world/blocky/voxel_chunk_blocky.cpp", - #"world/blocky/voxel_world_blocky.cpp", + "world/blocky/voxel_chunk_blocky.cpp", + "world/blocky/voxel_world_blocky.cpp", - #"world/default/voxel_world_default.cpp", - # "world/default/voxel_chunk_default.cpp", + "world/default/voxel_world_default.cpp", + "world/default/voxel_chunk_default.cpp", - # "world/marching_cubes/voxel_chunk_marching_cubes.cpp", - # "world/marching_cubes/voxel_world_marching_cubes.cpp", + "world/marching_cubes/voxel_chunk_marching_cubes.cpp", + "world/marching_cubes/voxel_world_marching_cubes.cpp", - #"meshers/cubic/voxel_mesher_cubic.cpp", - #"meshers/cubic/voxel_cube_points.cpp", + "meshers/cubic/voxel_mesher_cubic.cpp", + "meshers/cubic/voxel_cube_points.cpp", - #"level_generator/voxelman_level_generator.cpp", - #"level_generator/voxelman_level_generator_flat.cpp", + "level_generator/voxelman_level_generator.cpp", + "level_generator/voxelman_level_generator_flat.cpp", - #"world/cubic/voxel_chunk_cubic.cpp", - #"world/cubic/voxel_world_cubic.cpp", + "world/cubic/voxel_chunk_cubic.cpp", + "world/cubic/voxel_world_cubic.cpp", - #"areas/world_area.cpp", + "areas/world_area.cpp", - #"world/voxel_world_editor.cpp", + "world/voxel_world_editor.cpp", - #"thirdparty/lz4/lz4.c", + "thirdparty/lz4/lz4.c", - #"world/jobs/voxel_job.cpp", - #"world/jobs/voxel_terrarin_job.cpp", - #"world/jobs/voxel_light_job.cpp", - #"world/jobs/voxel_prop_job.cpp", + "world/jobs/voxel_job.cpp", + "world/jobs/voxel_terrarin_job.cpp", + "world/jobs/voxel_light_job.cpp", + "world/jobs/voxel_prop_job.cpp", ] -#if has_texture_packer: -# sources.append("library/voxelman_library_merger.cpp") -# sources.append("library/voxel_surface_merger.cpp") +if has_texture_packer: + sources.append("library/voxelman_library_merger.cpp") + sources.append("library/voxel_surface_merger.cpp") if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation diff --git a/areas/world_area.cpp b/areas/world_area.cpp index 8e88e95..f22141d 100644 --- a/areas/world_area.cpp +++ b/areas/world_area.cpp @@ -22,66 +22,66 @@ SOFTWARE. #include "world_area.h" -AABB WorldArea::get_aabb() const { +AABB TerraWorldArea::get_aabb() const { return _aabb; } -void WorldArea::set_aabb(const AABB value) { +void TerraWorldArea::set_aabb(const AABB value) { _aabb = value; } -Ref WorldArea::get_map_texture() const { +Ref TerraWorldArea::get_map_texture() const { return _map_texture; } -void WorldArea::set_map_texture(const Ref &value) { +void TerraWorldArea::set_map_texture(const Ref &value) { _map_texture = value; } -Ref WorldArea::get_fov_texture() const { +Ref TerraWorldArea::get_fov_texture() const { return _fov_texture; } -void WorldArea::set_fov_texture(const Ref &value) { +void TerraWorldArea::set_fov_texture(const Ref &value) { _fov_texture = value; } -String WorldArea::get_name() const { +String TerraWorldArea::get_name() const { return _name; } -void WorldArea::set_name(const String &value) { +void TerraWorldArea::set_name(const String &value) { _name = value; } -int WorldArea::get_level() const { +int TerraWorldArea::get_level() const { return _level; } -void WorldArea::set_level(const int level) { +void TerraWorldArea::set_level(const int level) { _level = level; } -WorldArea::WorldArea() { +TerraWorldArea::TerraWorldArea() { _level = 0; } -WorldArea::~WorldArea() { +TerraWorldArea::~TerraWorldArea() { } -void WorldArea::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_aabb"), &WorldArea::get_aabb); - ClassDB::bind_method(D_METHOD("set_aabb"), &WorldArea::set_aabb); +void TerraWorldArea::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_aabb"), &TerraWorldArea::get_aabb); + ClassDB::bind_method(D_METHOD("set_aabb"), &TerraWorldArea::set_aabb); ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); - ClassDB::bind_method(D_METHOD("get_map_texture"), &WorldArea::get_map_texture); - ClassDB::bind_method(D_METHOD("set_map_texture"), &WorldArea::set_map_texture); + ClassDB::bind_method(D_METHOD("get_map_texture"), &TerraWorldArea::get_map_texture); + ClassDB::bind_method(D_METHOD("set_map_texture"), &TerraWorldArea::set_map_texture); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "map_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_map_texture", "get_map_texture"); - ClassDB::bind_method(D_METHOD("get_fov_texture"), &WorldArea::get_fov_texture); - ClassDB::bind_method(D_METHOD("set_fov_texture"), &WorldArea::set_fov_texture); + ClassDB::bind_method(D_METHOD("get_fov_texture"), &TerraWorldArea::get_fov_texture); + ClassDB::bind_method(D_METHOD("set_fov_texture"), &TerraWorldArea::set_fov_texture); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "fov_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_fov_texture", "get_fov_texture"); - ClassDB::bind_method(D_METHOD("get_name"), &WorldArea::get_name); - ClassDB::bind_method(D_METHOD("set_name"), &WorldArea::set_name); + ClassDB::bind_method(D_METHOD("get_name"), &TerraWorldArea::get_name); + ClassDB::bind_method(D_METHOD("set_name"), &TerraWorldArea::set_name); ADD_PROPERTY(PropertyInfo(Variant::STRING, "name"), "set_name", "get_name"); - ClassDB::bind_method(D_METHOD("get_level"), &WorldArea::get_level); - ClassDB::bind_method(D_METHOD("set_level"), &WorldArea::set_level); + ClassDB::bind_method(D_METHOD("get_level"), &TerraWorldArea::get_level); + ClassDB::bind_method(D_METHOD("set_level"), &TerraWorldArea::set_level); ADD_PROPERTY(PropertyInfo(Variant::INT, "level"), "set_level", "get_level"); } diff --git a/areas/world_area.h b/areas/world_area.h index 829d90e..ba9fda8 100644 --- a/areas/world_area.h +++ b/areas/world_area.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef WORLD_AREA_H -#define WORLD_AREA_H +#ifndef TERRA_WORLD_AREA_H +#define TERRA_WORLD_AREA_H #include "core/version.h" @@ -37,8 +37,8 @@ SOFTWARE. #include "scene/resources/texture.h" -class WorldArea : public Reference { - GDCLASS(WorldArea, Reference); +class TerraWorldArea : public Reference { + GDCLASS(TerraWorldArea, Reference); public: AABB get_aabb() const; @@ -56,8 +56,8 @@ public: int get_level() const; void set_level(const int value); - WorldArea(); - ~WorldArea(); + TerraWorldArea(); + ~TerraWorldArea(); private: static void _bind_methods(); diff --git a/config.py b/config.py index cd3ddfc..493f761 100644 --- a/config.py +++ b/config.py @@ -10,56 +10,56 @@ def configure(env): def get_doc_classes(): return [ - #"WorldArea", + "TerraWorldArea", - #"VoxelLight", - #"VoxelmanLight", + "TerraLight", + "TerramanLight", - # "VoxelmanLevelGenerator", - # "VoxelmanLevelGeneratorFlat", + "TerramanLevelGenerator", + "TerramanLevelGeneratorFlat", - #"VoxelSurfaceMerger", - # "VoxelSurfaceSimple", - # "VoxelSurface", - # "VoxelmanLibraryMerger", - # "VoxelmanLibrarySimple", - # "VoxelmanLibrary", + "TerraSurfaceMerger", + "TerraSurfaceSimple", + "TerraSurface", + "TerramanLibraryMerger", + "TerramanLibrarySimple", + "TerramanLibrary", - # "VoxelCubePoints", - # "VoxelMesherCubic", - # "VoxelMeshData", + "TerraCubePoints", + "TerraMesherCubic", + "TerraMeshData", - # "MarchingCubesCellData", - # "VoxelMesherMarchingCubes", + "MarchingCubesCellData", + "TerraMesherMarchingCubes", - # "VoxelMesher", + "TerraMesher", - # "EnvironmentData", - # "VoxelChunk", - # "VoxelChunkDefault", - # "VoxelStructure", - # "BlockVoxelStructure", - # "VoxelWorld", + "EnvironmentData", + "TerraChunk", + "TerraChunkDefault", + "TerraStructure", + "BlockTerraStructure", + "TerraWorld", - # "VoxelMesherBlocky", - # "VoxelWorldBlocky", - #"VoxelChunkBlocky", - #"VoxelMesherLiquidBlocky", + "TerraMesherBlocky", + "TerraWorldBlocky", + "TerraChunkBlocky", + "TerraMesherLiquidBlocky", - # "VoxelWorldMarchingCubes", - # "VoxelChunkMarchingCubes", + "TerraWorldMarchingCubes", + "TerraChunkMarchingCubes", + + "TerraMesherCubic", + "TerraWorldCubic", + "TerraChunkCubic", - # "VoxelMesherCubic", - # "VoxelWorldCubic", - # "VoxelChunkCubic", + "TerraMesherDefault", + "TerraWorldDefault", - # "VoxelMesherDefault", - # "VoxelWorldDefault", - - # "VoxelJob", - # "VoxelTerrarinJob", - # "VoxelLightJob", - #"VoxelPropJob", + "TerraJob", + "TerraTerrarinJob", + "TerraLightJob", + "TerraPropJob", ] diff --git a/data/voxel_light.cpp b/data/voxel_light.cpp index 39cd5b0..5979515 100644 --- a/data/voxel_light.cpp +++ b/data/voxel_light.cpp @@ -22,56 +22,56 @@ SOFTWARE. #include "voxel_light.h" -_FORCE_INLINE_ int VoxelLight::get_world_position_x() const { +_FORCE_INLINE_ int TerraLight::get_world_position_x() const { return _world_position_x; } -_FORCE_INLINE_ int VoxelLight::get_world_position_y() const { +_FORCE_INLINE_ int TerraLight::get_world_position_y() const { return _world_position_y; } -_FORCE_INLINE_ int VoxelLight::get_world_position_z() const { +_FORCE_INLINE_ int TerraLight::get_world_position_z() const { return _world_position_z; } -Vector3 VoxelLight::get_world_position() { +Vector3 TerraLight::get_world_position() { return Vector3(_world_position_x, _world_position_y, _world_position_z); } -void VoxelLight::set_world_position(const int x, const int y, const int z) { +void TerraLight::set_world_position(const int x, const int y, const int z) { _world_position_x = x; _world_position_y = y; _world_position_z = z; } -_FORCE_INLINE_ Color VoxelLight::get_color() const { +_FORCE_INLINE_ Color TerraLight::get_color() const { return _color; } -void VoxelLight::set_color(const Color &color) { +void TerraLight::set_color(const Color &color) { _color = color; } -_FORCE_INLINE_ float VoxelLight::get_size() const { +_FORCE_INLINE_ float TerraLight::get_size() const { return _size; } -void VoxelLight::set_size(const float size) { +void TerraLight::set_size(const float size) { _size = size; } -VoxelLight::VoxelLight() { +TerraLight::TerraLight() { _size = 0; } -VoxelLight::~VoxelLight() { +TerraLight::~TerraLight() { } -void VoxelLight::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_world_position_x"), &VoxelLight::get_world_position_x); - ClassDB::bind_method(D_METHOD("get_world_position_y"), &VoxelLight::get_world_position_y); - ClassDB::bind_method(D_METHOD("get_world_position_z"), &VoxelLight::get_world_position_z); - ClassDB::bind_method(D_METHOD("set_world_position", "x", "y", "z"), &VoxelLight::set_world_position); +void TerraLight::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_world_position_x"), &TerraLight::get_world_position_x); + ClassDB::bind_method(D_METHOD("get_world_position_y"), &TerraLight::get_world_position_y); + ClassDB::bind_method(D_METHOD("get_world_position_z"), &TerraLight::get_world_position_z); + ClassDB::bind_method(D_METHOD("set_world_position", "x", "y", "z"), &TerraLight::set_world_position); - ClassDB::bind_method(D_METHOD("get_color"), &VoxelLight::get_color); - ClassDB::bind_method(D_METHOD("set_color"), &VoxelLight::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &TerraLight::get_color); + ClassDB::bind_method(D_METHOD("set_color"), &TerraLight::set_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); - ClassDB::bind_method(D_METHOD("get_size"), &VoxelLight::get_size); - ClassDB::bind_method(D_METHOD("set_size"), &VoxelLight::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &TerraLight::get_size); + ClassDB::bind_method(D_METHOD("set_size"), &TerraLight::set_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); } diff --git a/data/voxel_light.h b/data/voxel_light.h index fba4323..07ffeb7 100644 --- a/data/voxel_light.h +++ b/data/voxel_light.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_LIGHT_H -#define VOXEL_LIGHT_H +#ifndef TERRA_LIGHT_H +#define TERRA_LIGHT_H #include "core/version.h" @@ -35,8 +35,8 @@ SOFTWARE. #include "core/color.h" #endif -class VoxelLight : public Reference { - GDCLASS(VoxelLight, Reference); +class TerraLight : public Reference { + GDCLASS(TerraLight, Reference); public: int get_world_position_x() const; @@ -51,8 +51,8 @@ public: float get_size() const; void set_size(const float strength); - VoxelLight(); - ~VoxelLight(); + TerraLight(); + ~TerraLight(); private: static void _bind_methods(); diff --git a/level_generator/voxelman_level_generator.cpp b/level_generator/voxelman_level_generator.cpp index 4386076..a8bb759 100644 --- a/level_generator/voxelman_level_generator.cpp +++ b/level_generator/voxelman_level_generator.cpp @@ -24,20 +24,20 @@ SOFTWARE. #include "../world/voxel_chunk.h" -void VoxelmanLevelGenerator::generate_chunk(Ref chunk) { +void TerramanLevelGenerator::generate_chunk(Ref chunk) { if (has_method("_generate_chunk")) { call("_generate_chunk", chunk); } } -VoxelmanLevelGenerator::VoxelmanLevelGenerator() { +TerramanLevelGenerator::TerramanLevelGenerator() { } -VoxelmanLevelGenerator::~VoxelmanLevelGenerator() { +TerramanLevelGenerator::~TerramanLevelGenerator() { } -void VoxelmanLevelGenerator::_bind_methods() { - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); +void TerramanLevelGenerator::_bind_methods() { + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &VoxelmanLevelGenerator::generate_chunk); + ClassDB::bind_method(D_METHOD("generate_chunk", "chunk"), &TerramanLevelGenerator::generate_chunk); } diff --git a/level_generator/voxelman_level_generator.h b/level_generator/voxelman_level_generator.h index 59f1013..cc5215e 100644 --- a/level_generator/voxelman_level_generator.h +++ b/level_generator/voxelman_level_generator.h @@ -31,16 +31,16 @@ SOFTWARE. #include "core/resource.h" #endif -class VoxelChunk; +class TerraChunk; -class VoxelmanLevelGenerator : public Resource { - GDCLASS(VoxelmanLevelGenerator, Resource); +class TerramanLevelGenerator : public Resource { + GDCLASS(TerramanLevelGenerator, Resource); public: - void generate_chunk(Ref chunk); + void generate_chunk(Ref chunk); - VoxelmanLevelGenerator(); - ~VoxelmanLevelGenerator(); + TerramanLevelGenerator(); + ~TerramanLevelGenerator(); protected: static void _bind_methods(); diff --git a/level_generator/voxelman_level_generator_flat.cpp b/level_generator/voxelman_level_generator_flat.cpp index f98dc35..7ec519c 100644 --- a/level_generator/voxelman_level_generator_flat.cpp +++ b/level_generator/voxelman_level_generator_flat.cpp @@ -24,21 +24,21 @@ SOFTWARE. #include "../world/voxel_chunk.h" -int VoxelmanLevelGeneratorFlat::get_floor_position() const { +int TerramanLevelGeneratorFlat::get_floor_position() const { return _floor_position; } -void VoxelmanLevelGeneratorFlat::set_floor_position(const int floor_height) { +void TerramanLevelGeneratorFlat::set_floor_position(const int floor_height) { _floor_position = floor_height; } -Dictionary VoxelmanLevelGeneratorFlat::get_channel_map() { +Dictionary TerramanLevelGeneratorFlat::get_channel_map() { return _channel_map; } -void VoxelmanLevelGeneratorFlat::set_channel_map(const Dictionary &map) { +void TerramanLevelGeneratorFlat::set_channel_map(const Dictionary &map) { _channel_map = map; } -void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref chunk) { +void TerramanLevelGeneratorFlat::_generate_chunk(Ref chunk) { int dymin = chunk->get_position_y() * chunk->get_size_y(); int dymax = dymin + chunk->get_size_y() + chunk->get_margin_end(); @@ -82,22 +82,22 @@ void VoxelmanLevelGeneratorFlat::_generate_chunk(Ref chunk) { } } -VoxelmanLevelGeneratorFlat::VoxelmanLevelGeneratorFlat() { +TerramanLevelGeneratorFlat::TerramanLevelGeneratorFlat() { _floor_position = 0; } -VoxelmanLevelGeneratorFlat::~VoxelmanLevelGeneratorFlat() { +TerramanLevelGeneratorFlat::~TerramanLevelGeneratorFlat() { _channel_map.clear(); } -void VoxelmanLevelGeneratorFlat::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_floor_position"), &VoxelmanLevelGeneratorFlat::get_floor_position); - ClassDB::bind_method(D_METHOD("set_floor_position", "value"), &VoxelmanLevelGeneratorFlat::set_floor_position); +void TerramanLevelGeneratorFlat::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_floor_position"), &TerramanLevelGeneratorFlat::get_floor_position); + ClassDB::bind_method(D_METHOD("set_floor_position", "value"), &TerramanLevelGeneratorFlat::set_floor_position); ADD_PROPERTY(PropertyInfo(Variant::INT, "floor_position"), "set_floor_position", "get_floor_position"); - ClassDB::bind_method(D_METHOD("get_channel_map"), &VoxelmanLevelGeneratorFlat::get_channel_map); - ClassDB::bind_method(D_METHOD("set_channel_map", "value"), &VoxelmanLevelGeneratorFlat::set_channel_map); + ClassDB::bind_method(D_METHOD("get_channel_map"), &TerramanLevelGeneratorFlat::get_channel_map); + ClassDB::bind_method(D_METHOD("set_channel_map", "value"), &TerramanLevelGeneratorFlat::set_channel_map); ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "channel_map"), "set_channel_map", "get_channel_map"); - ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &VoxelmanLevelGeneratorFlat::_generate_chunk); + ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &TerramanLevelGeneratorFlat::_generate_chunk); } diff --git a/level_generator/voxelman_level_generator_flat.h b/level_generator/voxelman_level_generator_flat.h index b257665..74b0509 100644 --- a/level_generator/voxelman_level_generator_flat.h +++ b/level_generator/voxelman_level_generator_flat.h @@ -25,10 +25,10 @@ SOFTWARE. #include "voxelman_level_generator.h" -class VoxelChunk; +class TerraChunk; -class VoxelmanLevelGeneratorFlat : public VoxelmanLevelGenerator { - GDCLASS(VoxelmanLevelGeneratorFlat, VoxelmanLevelGenerator); +class TerramanLevelGeneratorFlat : public TerramanLevelGenerator { + GDCLASS(TerramanLevelGeneratorFlat, TerramanLevelGenerator); public: int get_floor_position() const; @@ -37,10 +37,10 @@ public: Dictionary get_channel_map(); void set_channel_map(const Dictionary &map); - virtual void _generate_chunk(Ref chunk); + virtual void _generate_chunk(Ref chunk); - VoxelmanLevelGeneratorFlat(); - ~VoxelmanLevelGeneratorFlat(); + TerramanLevelGeneratorFlat(); + ~TerramanLevelGeneratorFlat(); protected: static void _bind_methods(); diff --git a/library/voxel_surface.cpp b/library/voxel_surface.cpp index 172af1c..55cd8ef 100644 --- a/library/voxel_surface.cpp +++ b/library/voxel_surface.cpp @@ -22,50 +22,50 @@ SOFTWARE. #include "voxel_surface.h" -int VoxelSurface::get_id() const { +int TerraSurface::get_id() const { return _id; } -void VoxelSurface::set_id(const int value) { +void TerraSurface::set_id(const int value) { _id = value; } -int VoxelSurface::get_mesher_index() const { +int TerraSurface::get_mesher_index() const { return _mesher_index; } -void VoxelSurface::set_mesher_index(const int value) { +void TerraSurface::set_mesher_index(const int value) { _mesher_index = value; } -bool VoxelSurface::get_transparent() const { +bool TerraSurface::get_transparent() const { return _transparent; } -void VoxelSurface::set_transparent(const bool transparent) { +void TerraSurface::set_transparent(const bool transparent) { _transparent = transparent; } -bool VoxelSurface::get_liquid() const { +bool TerraSurface::get_liquid() const { return _liquid; } -void VoxelSurface::set_liquid(const bool value) { +void TerraSurface::set_liquid(const bool value) { _liquid = value; } -Rect2 VoxelSurface::get_rect(const VoxelSurfaceSides side) const { +Rect2 TerraSurface::get_rect(const TerraSurfaceSides side) const { return _rects[side]; } -void VoxelSurface::set_rect(const VoxelSurfaceSides side, const Rect2 &rect) { +void TerraSurface::set_rect(const TerraSurfaceSides side, const Rect2 &rect) { _rects[side] = rect; } -Ref VoxelSurface::get_library() const { - return Ref(_library); +Ref TerraSurface::get_library() const { + return Ref(_library); } -void VoxelSurface::set_library(Ref library) { +void TerraSurface::set_library(Ref library) { _library = (*library); } -_FORCE_INLINE_ Vector2 VoxelSurface::transform_uv(const VoxelSurfaceSides p_side, const Vector2 &p_uv) const { +_FORCE_INLINE_ Vector2 TerraSurface::transform_uv(const TerraSurfaceSides p_side, const Vector2 &p_uv) const { Vector2 uv = p_uv; Rect2 r = _rects[p_side]; @@ -78,7 +78,7 @@ _FORCE_INLINE_ Vector2 VoxelSurface::transform_uv(const VoxelSurfaceSides p_side return uv; } -_FORCE_INLINE_ Vector2 VoxelSurface::transform_uv_scaled(const VoxelSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const { +_FORCE_INLINE_ Vector2 TerraSurface::transform_uv_scaled(const TerraSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const { Vector2 uv = p_uv; Rect2 r = _rects[p_side]; @@ -95,10 +95,10 @@ _FORCE_INLINE_ Vector2 VoxelSurface::transform_uv_scaled(const VoxelSurfaceSides return uv; } -void VoxelSurface::refresh_rects() { +void TerraSurface::refresh_rects() { } -VoxelSurface::VoxelSurface() { +TerraSurface::TerraSurface() { _id = 0; _mesher_index = 0; _transparent = false; @@ -106,40 +106,40 @@ VoxelSurface::VoxelSurface() { _library = NULL; } -VoxelSurface::~VoxelSurface() { +TerraSurface::~TerraSurface() { _library = NULL; } -void VoxelSurface::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_id"), &VoxelSurface::get_id); - ClassDB::bind_method(D_METHOD("set_id", "value"), &VoxelSurface::set_id); +void TerraSurface::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_id"), &TerraSurface::get_id); + ClassDB::bind_method(D_METHOD("set_id", "value"), &TerraSurface::set_id); ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id"); - ClassDB::bind_method(D_METHOD("get_mesher_index"), &VoxelSurface::get_mesher_index); - ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &VoxelSurface::set_mesher_index); + ClassDB::bind_method(D_METHOD("get_mesher_index"), &TerraSurface::get_mesher_index); + ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &TerraSurface::set_mesher_index); ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "voxel_name"), "set_name", "get_name"); - ClassDB::bind_method(D_METHOD("get_transparent"), &VoxelSurface::get_transparent); - ClassDB::bind_method(D_METHOD("set_transparent", "transparent"), &VoxelSurface::set_transparent); + ClassDB::bind_method(D_METHOD("get_transparent"), &TerraSurface::get_transparent); + ClassDB::bind_method(D_METHOD("set_transparent", "transparent"), &TerraSurface::set_transparent); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent"), "set_transparent", "get_transparent"); - ClassDB::bind_method(D_METHOD("get_liquid"), &VoxelSurface::get_liquid); - ClassDB::bind_method(D_METHOD("set_liquid", "transparent"), &VoxelSurface::set_liquid); + ClassDB::bind_method(D_METHOD("get_liquid"), &TerraSurface::get_liquid); + ClassDB::bind_method(D_METHOD("set_liquid", "transparent"), &TerraSurface::set_liquid); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "liquid"), "set_liquid", "get_liquid"); - ClassDB::bind_method(D_METHOD("get_rect", "side"), &VoxelSurface::get_rect); - ClassDB::bind_method(D_METHOD("set_rect", "side", "rect"), &VoxelSurface::set_rect); + ClassDB::bind_method(D_METHOD("get_rect", "side"), &TerraSurface::get_rect); + ClassDB::bind_method(D_METHOD("set_rect", "side", "rect"), &TerraSurface::set_rect); - ClassDB::bind_method(D_METHOD("transform_uv", "side", "uv"), &VoxelSurface::transform_uv); - ClassDB::bind_method(D_METHOD("transform_uv_scaled", "side", "uv", "p_current_x", "p_current_y", "max"), &VoxelSurface::transform_uv_scaled); + ClassDB::bind_method(D_METHOD("transform_uv", "side", "uv"), &TerraSurface::transform_uv); + ClassDB::bind_method(D_METHOD("transform_uv_scaled", "side", "uv", "p_current_x", "p_current_y", "max"), &TerraSurface::transform_uv_scaled); - ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelSurface::refresh_rects); + ClassDB::bind_method(D_METHOD("refresh_rects"), &TerraSurface::refresh_rects); - BIND_ENUM_CONSTANT(VOXEL_SIDE_TOP); - BIND_ENUM_CONSTANT(VOXEL_SIDE_BOTTOM); - BIND_ENUM_CONSTANT(VOXEL_SIDE_SIDE); + BIND_ENUM_CONSTANT(TERRA_SIDE_TOP); + BIND_ENUM_CONSTANT(TERRA_SIDE_BOTTOM); + BIND_ENUM_CONSTANT(TERRA_SIDE_SIDE); - BIND_CONSTANT(VOXEL_SIDES_COUNT); + BIND_CONSTANT(TERRA_SIDES_COUNT); } diff --git a/library/voxel_surface.h b/library/voxel_surface.h index fb43933..4db57d9 100644 --- a/library/voxel_surface.h +++ b/library/voxel_surface.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_SURFACE_H -#define VOXEL_SURFACE_H +#ifndef TERRA_SURFACE_H +#define TERRA_SURFACE_H #include "core/version.h" @@ -41,10 +41,10 @@ SOFTWARE. #include "voxelman_library.h" -class VoxelmanLibrary; +class TerramanLibrary; -class VoxelSurface : public Resource { - GDCLASS(VoxelSurface, Resource) +class TerraSurface : public Resource { + GDCLASS(TerraSurface, Resource) public: /* @@ -62,15 +62,15 @@ public: / z+ I ---I/ */ - enum VoxelSurfaceSides { - VOXEL_SIDE_TOP = 0, - VOXEL_SIDE_BOTTOM = 1, - VOXEL_SIDE_SIDE = 2, + enum TerraSurfaceSides { + TERRA_SIDE_TOP = 0, + TERRA_SIDE_BOTTOM = 1, + TERRA_SIDE_SIDE = 2, }; enum { - VOXEL_SIDES_COUNT = 3, - VOXEL_SIDES_ARRAY_SIZE = VOXEL_SIDES_COUNT * 2, + TERRA_SIDES_COUNT = 3, + TERRA_SIDES_ARRAY_SIZE = TERRA_SIDES_COUNT * 2, }; int get_id() const; @@ -85,32 +85,32 @@ public: bool get_liquid() const; void set_liquid(const bool value); - Rect2 get_rect(const VoxelSurfaceSides side) const; - void set_rect(const VoxelSurfaceSides side, const Rect2 &rect); + Rect2 get_rect(const TerraSurfaceSides side) const; + void set_rect(const TerraSurfaceSides side, const Rect2 &rect); - Ref get_library() const; - void set_library(Ref library); + Ref get_library() const; + void set_library(Ref library); - Vector2 transform_uv(const VoxelSurfaceSides p_side, const Vector2 &p_uv) const; - Vector2 transform_uv_scaled(const VoxelSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const; + Vector2 transform_uv(const TerraSurfaceSides p_side, const Vector2 &p_uv) const; + Vector2 transform_uv_scaled(const TerraSurfaceSides p_side, const Vector2 &p_uv, const int p_current_x, const int p_current_y, const int p_max) const; virtual void refresh_rects(); - VoxelSurface(); - ~VoxelSurface(); + TerraSurface(); + ~TerraSurface(); protected: static void _bind_methods(); - VoxelmanLibrary *_library; + TerramanLibrary *_library; int _id; int _mesher_index; bool _transparent; bool _liquid; - Rect2 _rects[VOXEL_SIDES_COUNT]; + Rect2 _rects[TERRA_SIDES_COUNT]; }; -VARIANT_ENUM_CAST(VoxelSurface::VoxelSurfaceSides); +VARIANT_ENUM_CAST(TerraSurface::TerraSurfaceSides); #endif diff --git a/library/voxel_surface_merger.cpp b/library/voxel_surface_merger.cpp index e604e6a..e96b258 100644 --- a/library/voxel_surface_merger.cpp +++ b/library/voxel_surface_merger.cpp @@ -30,26 +30,26 @@ SOFTWARE. #define Texture Texture2D #endif -Ref VoxelSurfaceMerger::get_region(const VoxelSurfaceSides side) { +Ref TerraSurfaceMerger::get_region(const TerraSurfaceSides side) { return _regions[side]; } -void VoxelSurfaceMerger::set_region(const VoxelSurfaceSides side, const Ref &texture) { +void TerraSurfaceMerger::set_region(const TerraSurfaceSides side, const Ref &texture) { _regions[side] = texture; } -Ref VoxelSurfaceMerger::get_texture(const VoxelSurfaceSides side) { +Ref TerraSurfaceMerger::get_texture(const TerraSurfaceSides side) { return _textures[side]; } -void VoxelSurfaceMerger::set_texture(const VoxelSurfaceSides side, const Ref &texture) { +void TerraSurfaceMerger::set_texture(const TerraSurfaceSides side, const Ref &texture) { _textures[side] = texture; } -void VoxelSurfaceMerger::refresh_rects() { - VoxelmanLibraryMerger *lib = Object::cast_to(_library); +void TerraSurfaceMerger::refresh_rects() { + TerramanLibraryMerger *lib = Object::cast_to(_library); ERR_FAIL_COND(lib == NULL); - for (int i = 0; i < VOXEL_SIDES_COUNT; ++i) { + for (int i = 0; i < TERRA_SIDES_COUNT; ++i) { if (!_regions[i].is_valid()) { _rects[i] = Rect2(); continue; @@ -78,26 +78,26 @@ void VoxelSurfaceMerger::refresh_rects() { } } -VoxelSurfaceMerger::VoxelSurfaceMerger() { - for (int i = 0; i < VOXEL_SIDES_COUNT; ++i) { +TerraSurfaceMerger::TerraSurfaceMerger() { + for (int i = 0; i < TERRA_SIDES_COUNT; ++i) { _regions[i].unref(); _textures[i].unref(); } } -VoxelSurfaceMerger::~VoxelSurfaceMerger() { +TerraSurfaceMerger::~TerraSurfaceMerger() { } -void VoxelSurfaceMerger::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_region", "side"), &VoxelSurfaceMerger::get_region); - ClassDB::bind_method(D_METHOD("set_region", "side", "texture"), &VoxelSurfaceMerger::set_region); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_top", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", VOXEL_SIDE_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_bottom", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", VOXEL_SIDE_BOTTOM); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_side", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", VOXEL_SIDE_SIDE); +void TerraSurfaceMerger::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_region", "side"), &TerraSurfaceMerger::get_region); + ClassDB::bind_method(D_METHOD("set_region", "side", "texture"), &TerraSurfaceMerger::set_region); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_top", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRA_SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_bottom", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRA_SIDE_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "region_side", PROPERTY_HINT_RESOURCE_TYPE, "AtlasTexture", 0), "set_region", "get_region", TERRA_SIDE_SIDE); - ClassDB::bind_method(D_METHOD("get_texture", "side"), &VoxelSurfaceMerger::get_texture); - ClassDB::bind_method(D_METHOD("set_texture", "side", "texture"), &VoxelSurfaceMerger::set_texture); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_top", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_bottom", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_BOTTOM); - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_side", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", VOXEL_SIDE_SIDE); + ClassDB::bind_method(D_METHOD("get_texture", "side"), &TerraSurfaceMerger::get_texture); + ClassDB::bind_method(D_METHOD("set_texture", "side", "texture"), &TerraSurfaceMerger::set_texture); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_top", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRA_SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_bottom", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRA_SIDE_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "texture_side", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TERRA_SIDE_SIDE); } diff --git a/library/voxel_surface_merger.h b/library/voxel_surface_merger.h index d786dc4..30f8d49 100644 --- a/library/voxel_surface_merger.h +++ b/library/voxel_surface_merger.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_SURFACE_MERGER_H -#define VOXEL_SURFACE_MERGER_H +#ifndef TERRA_SURFACE_MERGER_H +#define TERRA_SURFACE_MERGER_H #include "voxel_surface.h" @@ -35,27 +35,27 @@ SOFTWARE. #define Texture Texture2D #endif -class VoxelSurfaceMerger : public VoxelSurface { - GDCLASS(VoxelSurfaceMerger, VoxelSurface) +class TerraSurfaceMerger : public TerraSurface { + GDCLASS(TerraSurfaceMerger, TerraSurface) public: - Ref get_region(const VoxelSurfaceSides side); - void set_region(const VoxelSurfaceSides side, const Ref &texture); + Ref get_region(const TerraSurfaceSides side); + void set_region(const TerraSurfaceSides side, const Ref &texture); - Ref get_texture(const VoxelSurfaceSides side); - void set_texture(const VoxelSurfaceSides side, const Ref &texture); + Ref get_texture(const TerraSurfaceSides side); + void set_texture(const TerraSurfaceSides side, const Ref &texture); void refresh_rects(); - VoxelSurfaceMerger(); - ~VoxelSurfaceMerger(); + TerraSurfaceMerger(); + ~TerraSurfaceMerger(); protected: static void _bind_methods(); private: - Ref _regions[VOXEL_SIDES_COUNT]; - Ref _textures[VOXEL_SIDES_COUNT]; + Ref _regions[TERRA_SIDES_COUNT]; + Ref _textures[TERRA_SIDES_COUNT]; }; #endif diff --git a/library/voxel_surface_simple.cpp b/library/voxel_surface_simple.cpp index 7537050..3026fb2 100644 --- a/library/voxel_surface_simple.cpp +++ b/library/voxel_surface_simple.cpp @@ -24,34 +24,34 @@ SOFTWARE. #include "voxelman_library_simple.h" -int VoxelSurfaceSimple::get_atlas_x(const VoxelSurfaceSides side) const { +int TerraSurfaceSimple::get_atlas_x(const TerraSurfaceSides side) const { int indx = (side * 2); return _atlas_positions[indx]; } -void VoxelSurfaceSimple::set_atlas_x(const VoxelSurfaceSides side, int value) { +void TerraSurfaceSimple::set_atlas_x(const TerraSurfaceSides side, int value) { int indx = (side * 2); _atlas_positions[indx] = value; } -int VoxelSurfaceSimple::get_atlas_y(const VoxelSurfaceSides side) const { +int TerraSurfaceSimple::get_atlas_y(const TerraSurfaceSides side) const { int indx = (side * 2) + 1; return _atlas_positions[indx]; } -void VoxelSurfaceSimple::set_atlas_y(const VoxelSurfaceSides side, int value) { +void TerraSurfaceSimple::set_atlas_y(const TerraSurfaceSides side, int value) { int indx = (side * 2) + 1; _atlas_positions[indx] = value; } -void VoxelSurfaceSimple::refresh_rects() { - VoxelmanLibrarySimple *lib = Object::cast_to(_library); +void TerraSurfaceSimple::refresh_rects() { + TerramanLibrarySimple *lib = Object::cast_to(_library); ERR_FAIL_COND(lib == NULL); - for (int i = 0; i < VOXEL_SIDES_COUNT; ++i) { + for (int i = 0; i < TERRA_SIDES_COUNT; ++i) { float culomn = 1.0 / static_cast(lib->get_atlas_columns()); float row = 1.0 / static_cast(lib->get_atlas_rows()); @@ -67,28 +67,28 @@ void VoxelSurfaceSimple::refresh_rects() { } } -VoxelSurfaceSimple::VoxelSurfaceSimple() { - for (int i = 0; i < VOXEL_SIDES_ARRAY_SIZE; ++i) { +TerraSurfaceSimple::TerraSurfaceSimple() { + for (int i = 0; i < TERRA_SIDES_ARRAY_SIZE; ++i) { _atlas_positions[i] = 0; } } -VoxelSurfaceSimple::~VoxelSurfaceSimple() { +TerraSurfaceSimple::~TerraSurfaceSimple() { } -void VoxelSurfaceSimple::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_atlas_x", "side"), &VoxelSurfaceSimple::get_atlas_x); - ClassDB::bind_method(D_METHOD("set_atlas_x", "side", "value"), &VoxelSurfaceSimple::set_atlas_x); +void TerraSurfaceSimple::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_atlas_x", "side"), &TerraSurfaceSimple::get_atlas_x); + ClassDB::bind_method(D_METHOD("set_atlas_x", "side", "value"), &TerraSurfaceSimple::set_atlas_x); - ClassDB::bind_method(D_METHOD("get_atlas_y", "side"), &VoxelSurfaceSimple::get_atlas_y); - ClassDB::bind_method(D_METHOD("set_atlas_y", "side", "value"), &VoxelSurfaceSimple::set_atlas_y); + ClassDB::bind_method(D_METHOD("get_atlas_y", "side"), &TerraSurfaceSimple::get_atlas_y); + ClassDB::bind_method(D_METHOD("set_atlas_y", "side", "value"), &TerraSurfaceSimple::set_atlas_y); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_x"), "set_atlas_x", "get_atlas_x", VOXEL_SIDE_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_y"), "set_atlas_y", "get_atlas_y", VOXEL_SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_x"), "set_atlas_x", "get_atlas_x", TERRA_SIDE_TOP); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "top_atlas_y"), "set_atlas_y", "get_atlas_y", TERRA_SIDE_TOP); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_x"), "set_atlas_x", "get_atlas_x", VOXEL_SIDE_BOTTOM); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_y"), "set_atlas_y", "get_atlas_y", VOXEL_SIDE_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_x"), "set_atlas_x", "get_atlas_x", TERRA_SIDE_BOTTOM); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "bottom_atlas_y"), "set_atlas_y", "get_atlas_y", TERRA_SIDE_BOTTOM); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_x"), "set_atlas_x", "get_atlas_x", VOXEL_SIDE_SIDE); - ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_y"), "set_atlas_y", "get_atlas_y", VOXEL_SIDE_SIDE); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_x"), "set_atlas_x", "get_atlas_x", TERRA_SIDE_SIDE); + ADD_PROPERTYI(PropertyInfo(Variant::INT, "side_atlas_y"), "set_atlas_y", "get_atlas_y", TERRA_SIDE_SIDE); } diff --git a/library/voxel_surface_simple.h b/library/voxel_surface_simple.h index 0659923..1ed3ce8 100644 --- a/library/voxel_surface_simple.h +++ b/library/voxel_surface_simple.h @@ -20,31 +20,31 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_SURFACE_SIMPLE_H -#define VOXEL_SURFACE_SIMPLE_H +#ifndef TERRA_SURFACE_SIMPLE_H +#define TERRA_SURFACE_SIMPLE_H #include "voxel_surface.h" -class VoxelSurfaceSimple : public VoxelSurface { - GDCLASS(VoxelSurfaceSimple, VoxelSurface) +class TerraSurfaceSimple : public TerraSurface { + GDCLASS(TerraSurfaceSimple, TerraSurface) public: - int get_atlas_x(const VoxelSurfaceSides side) const; - void set_atlas_x(const VoxelSurfaceSides side, int value); + int get_atlas_x(const TerraSurfaceSides side) const; + void set_atlas_x(const TerraSurfaceSides side, int value); - int get_atlas_y(const VoxelSurfaceSides side) const; - void set_atlas_y(const VoxelSurfaceSides side, int value); + int get_atlas_y(const TerraSurfaceSides side) const; + void set_atlas_y(const TerraSurfaceSides side, int value); void refresh_rects(); - VoxelSurfaceSimple(); - ~VoxelSurfaceSimple(); + TerraSurfaceSimple(); + ~TerraSurfaceSimple(); protected: static void _bind_methods(); private: - int _atlas_positions[VOXEL_SIDES_ARRAY_SIZE]; + int _atlas_positions[TERRA_SIDES_ARRAY_SIZE]; }; #endif diff --git a/library/voxelman_library.cpp b/library/voxelman_library.cpp index f2a560b..96602d2 100644 --- a/library/voxelman_library.cpp +++ b/library/voxelman_library.cpp @@ -30,49 +30,49 @@ SOFTWARE. #include "../defines.h" -bool VoxelmanLibrary::get_initialized() const { +bool TerramanLibrary::get_initialized() const { return _initialized; } -void VoxelmanLibrary::set_initialized(const bool value) { +void TerramanLibrary::set_initialized(const bool value) { _initialized = value; } //Materials -Ref VoxelmanLibrary::material_get(const int index) { - ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); +Ref TerramanLibrary::material_get(const int index) { + ERR_FAIL_INDEX_V(index, _materials.size(), Ref(NULL)); return _materials[index]; } -void VoxelmanLibrary::material_add(const Ref &value) { +void TerramanLibrary::material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _materials.push_back(value); } -void VoxelmanLibrary::material_set(const int index, const Ref &value) { +void TerramanLibrary::material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _materials.size()); _materials.set(index, value); } -void VoxelmanLibrary::material_remove(const int index) { +void TerramanLibrary::material_remove(const int index) { _materials.remove(index); } -int VoxelmanLibrary::material_get_num() const { +int TerramanLibrary::material_get_num() const { return _materials.size(); } -void VoxelmanLibrary::materials_clear() { +void TerramanLibrary::materials_clear() { _materials.clear(); } -Vector VoxelmanLibrary::materials_get() { +Vector TerramanLibrary::materials_get() { VARIANT_ARRAY_GET(_materials); } -void VoxelmanLibrary::materials_set(const Vector &materials) { +void TerramanLibrary::materials_set(const Vector &materials) { _materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -83,41 +83,41 @@ void VoxelmanLibrary::materials_set(const Vector &materials) { } //Liquid Materials -Ref VoxelmanLibrary::liquid_material_get(const int index) { - ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref(NULL)); +Ref TerramanLibrary::liquid_material_get(const int index) { + ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref(NULL)); return _liquid_materials[index]; } -void VoxelmanLibrary::liquid_material_add(const Ref &value) { +void TerramanLibrary::liquid_material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _liquid_materials.push_back(value); } -void VoxelmanLibrary::liquid_material_set(const int index, const Ref &value) { +void TerramanLibrary::liquid_material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _liquid_materials.size()); _liquid_materials.set(index, value); } -void VoxelmanLibrary::liquid_material_remove(const int index) { +void TerramanLibrary::liquid_material_remove(const int index) { _liquid_materials.remove(index); } -int VoxelmanLibrary::liquid_material_get_num() const { +int TerramanLibrary::liquid_material_get_num() const { return _liquid_materials.size(); } -void VoxelmanLibrary::liquid_materials_clear() { +void TerramanLibrary::liquid_materials_clear() { _liquid_materials.clear(); } -Vector VoxelmanLibrary::liquid_materials_get() { +Vector TerramanLibrary::liquid_materials_get() { VARIANT_ARRAY_GET(_liquid_materials); } -void VoxelmanLibrary::liquid_materials_set(const Vector &materials) { +void TerramanLibrary::liquid_materials_set(const Vector &materials) { _liquid_materials.clear(); for (int i = 0; i < materials.size(); i++) { @@ -128,188 +128,188 @@ void VoxelmanLibrary::liquid_materials_set(const Vector &materials) { } //Prop Materials -Ref VoxelmanLibrary::prop_material_get(const int index) { - ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref(NULL)); +Ref TerramanLibrary::prop_material_get(const int index) { + ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref(NULL)); return _prop_materials[index]; } -void VoxelmanLibrary::prop_material_add(const Ref &value) { +void TerramanLibrary::prop_material_add(const Ref &value) { ERR_FAIL_COND(!value.is_valid()); _prop_materials.push_back(value); } -void VoxelmanLibrary::prop_material_set(const int index, const Ref &value) { +void TerramanLibrary::prop_material_set(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _prop_materials.size()); _prop_materials.set(index, value); } -void VoxelmanLibrary::prop_material_remove(const int index) { +void TerramanLibrary::prop_material_remove(const int index) { _prop_materials.remove(index); } -int VoxelmanLibrary::prop_material_get_num() const { +int TerramanLibrary::prop_material_get_num() const { return _prop_materials.size(); } -void VoxelmanLibrary::prop_materials_clear() { +void TerramanLibrary::prop_materials_clear() { _prop_materials.clear(); } -Vector VoxelmanLibrary::prop_materials_get() { +Vector TerramanLibrary::prop_materials_get() { VARIANT_ARRAY_GET(_prop_materials); } -void VoxelmanLibrary::prop_materials_set(const Vector &materials) { +void TerramanLibrary::prop_materials_set(const Vector &materials) { VARIANT_ARRAY_SET(materials, _prop_materials, Material); } //Surfaces -Ref VoxelmanLibrary::voxel_surface_get(const int index) { - return Ref(); +Ref TerramanLibrary::voxel_surface_get(const int index) { + return Ref(); } -void VoxelmanLibrary::voxel_surface_add(Ref value) { +void TerramanLibrary::voxel_surface_add(Ref value) { } -void VoxelmanLibrary::voxel_surface_set(int index, Ref value) { +void TerramanLibrary::voxel_surface_set(int index, Ref value) { } -void VoxelmanLibrary::voxel_surface_remove(const int index) { +void TerramanLibrary::voxel_surface_remove(const int index) { } -int VoxelmanLibrary::voxel_surface_get_num() const { +int TerramanLibrary::voxel_surface_get_num() const { return 0; } -void VoxelmanLibrary::voxel_surfaces_clear() { +void TerramanLibrary::voxel_surfaces_clear() { } -Ref VoxelmanLibrary::scene_get(const int id) { +Ref TerramanLibrary::scene_get(const int id) { return Ref(); } -void VoxelmanLibrary::scene_add(Ref value) { +void TerramanLibrary::scene_add(Ref value) { } -void VoxelmanLibrary::scene_set(int id, Ref value) { +void TerramanLibrary::scene_set(int id, Ref value) { } -void VoxelmanLibrary::scene_remove(const int id) { +void TerramanLibrary::scene_remove(const int id) { } -int VoxelmanLibrary::scene_get_num() const { +int TerramanLibrary::scene_get_num() const { return 0; } -void VoxelmanLibrary::scenes_clear() { +void TerramanLibrary::scenes_clear() { } #ifdef PROPS_PRESENT -Ref VoxelmanLibrary::prop_get(const int id) { +Ref TerramanLibrary::prop_get(const int id) { return Ref(); } -void VoxelmanLibrary::prop_add(Ref value) { +void TerramanLibrary::prop_add(Ref value) { } -bool VoxelmanLibrary::prop_has(const Ref &value) const { +bool TerramanLibrary::prop_has(const Ref &value) const { return false; } -void VoxelmanLibrary::prop_set(int id, Ref value) { +void TerramanLibrary::prop_set(int id, Ref value) { } -void VoxelmanLibrary::prop_remove(const int id) { +void TerramanLibrary::prop_remove(const int id) { } -int VoxelmanLibrary::prop_get_num() const { +int TerramanLibrary::prop_get_num() const { return 0; } -void VoxelmanLibrary::props_clear() { +void TerramanLibrary::props_clear() { } -Rect2 VoxelmanLibrary::get_prop_uv_rect(const Ref &texture) { +Rect2 TerramanLibrary::get_prop_uv_rect(const Ref &texture) { return Rect2(0, 0, 1, 1); } #endif //Rects -void VoxelmanLibrary::refresh_rects() { +void TerramanLibrary::refresh_rects() { _initialized = true; } -void VoxelmanLibrary::setup_material_albedo(int material_index, Ref texture) { +void TerramanLibrary::setup_material_albedo(int material_index, Ref texture) { if (has_method("_setup_material_albedo")) call("_setup_material_albedo", material_index, texture); } -VoxelmanLibrary::VoxelmanLibrary() { +TerramanLibrary::TerramanLibrary() { _initialized = false; } -VoxelmanLibrary::~VoxelmanLibrary() { +TerramanLibrary::~TerramanLibrary() { _materials.clear(); _liquid_materials.clear(); _prop_materials.clear(); } -void VoxelmanLibrary::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_initialized"), &VoxelmanLibrary::get_initialized); - ClassDB::bind_method(D_METHOD("set_initialized", "value"), &VoxelmanLibrary::set_initialized); +void TerramanLibrary::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_initialized"), &TerramanLibrary::get_initialized); + ClassDB::bind_method(D_METHOD("set_initialized", "value"), &TerramanLibrary::set_initialized); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "initialized", PROPERTY_HINT_NONE, "", 0), "set_initialized", "get_initialized"); BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::INT, "material_index"), PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); - ClassDB::bind_method(D_METHOD("material_get", "index"), &VoxelmanLibrary::material_get); - ClassDB::bind_method(D_METHOD("material_add", "value"), &VoxelmanLibrary::material_add); - ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &VoxelmanLibrary::material_set); - ClassDB::bind_method(D_METHOD("material_remove", "index"), &VoxelmanLibrary::material_remove); - ClassDB::bind_method(D_METHOD("material_get_num"), &VoxelmanLibrary::material_get_num); - ClassDB::bind_method(D_METHOD("materials_clear"), &VoxelmanLibrary::materials_clear); + ClassDB::bind_method(D_METHOD("material_get", "index"), &TerramanLibrary::material_get); + ClassDB::bind_method(D_METHOD("material_add", "value"), &TerramanLibrary::material_add); + ClassDB::bind_method(D_METHOD("material_set", "index", "value"), &TerramanLibrary::material_set); + ClassDB::bind_method(D_METHOD("material_remove", "index"), &TerramanLibrary::material_remove); + ClassDB::bind_method(D_METHOD("material_get_num"), &TerramanLibrary::material_get_num); + ClassDB::bind_method(D_METHOD("materials_clear"), &TerramanLibrary::materials_clear); - ClassDB::bind_method(D_METHOD("materials_get"), &VoxelmanLibrary::materials_get); - ClassDB::bind_method(D_METHOD("materials_set"), &VoxelmanLibrary::materials_set); + ClassDB::bind_method(D_METHOD("materials_get"), &TerramanLibrary::materials_get); + ClassDB::bind_method(D_METHOD("materials_set"), &TerramanLibrary::materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "materials_set", "materials_get"); - ClassDB::bind_method(D_METHOD("liquid_material_get", "index"), &VoxelmanLibrary::liquid_material_get); - ClassDB::bind_method(D_METHOD("liquid_material_add", "value"), &VoxelmanLibrary::liquid_material_add); - ClassDB::bind_method(D_METHOD("liquid_material_set", "index", "value"), &VoxelmanLibrary::liquid_material_set); - ClassDB::bind_method(D_METHOD("liquid_material_remove", "index"), &VoxelmanLibrary::liquid_material_remove); - ClassDB::bind_method(D_METHOD("liquid_material_get_num"), &VoxelmanLibrary::liquid_material_get_num); - ClassDB::bind_method(D_METHOD("liquid_materials_clear"), &VoxelmanLibrary::liquid_materials_clear); + ClassDB::bind_method(D_METHOD("liquid_material_get", "index"), &TerramanLibrary::liquid_material_get); + ClassDB::bind_method(D_METHOD("liquid_material_add", "value"), &TerramanLibrary::liquid_material_add); + ClassDB::bind_method(D_METHOD("liquid_material_set", "index", "value"), &TerramanLibrary::liquid_material_set); + ClassDB::bind_method(D_METHOD("liquid_material_remove", "index"), &TerramanLibrary::liquid_material_remove); + ClassDB::bind_method(D_METHOD("liquid_material_get_num"), &TerramanLibrary::liquid_material_get_num); + ClassDB::bind_method(D_METHOD("liquid_materials_clear"), &TerramanLibrary::liquid_materials_clear); - ClassDB::bind_method(D_METHOD("liquid_materials_get"), &VoxelmanLibrary::liquid_materials_get); - ClassDB::bind_method(D_METHOD("liquid_materials_set"), &VoxelmanLibrary::liquid_materials_set); + ClassDB::bind_method(D_METHOD("liquid_materials_get"), &TerramanLibrary::liquid_materials_get); + ClassDB::bind_method(D_METHOD("liquid_materials_set"), &TerramanLibrary::liquid_materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "liquid_materials_set", "liquid_materials_get"); - ClassDB::bind_method(D_METHOD("prop_material_get", "index"), &VoxelmanLibrary::prop_material_get); - ClassDB::bind_method(D_METHOD("prop_material_add", "value"), &VoxelmanLibrary::prop_material_add); - ClassDB::bind_method(D_METHOD("prop_material_set", "index", "value"), &VoxelmanLibrary::prop_material_set); - ClassDB::bind_method(D_METHOD("prop_material_remove", "index"), &VoxelmanLibrary::prop_material_remove); - ClassDB::bind_method(D_METHOD("prop_material_get_num"), &VoxelmanLibrary::prop_material_get_num); - ClassDB::bind_method(D_METHOD("prop_materials_clear"), &VoxelmanLibrary::prop_materials_clear); + ClassDB::bind_method(D_METHOD("prop_material_get", "index"), &TerramanLibrary::prop_material_get); + ClassDB::bind_method(D_METHOD("prop_material_add", "value"), &TerramanLibrary::prop_material_add); + ClassDB::bind_method(D_METHOD("prop_material_set", "index", "value"), &TerramanLibrary::prop_material_set); + ClassDB::bind_method(D_METHOD("prop_material_remove", "index"), &TerramanLibrary::prop_material_remove); + ClassDB::bind_method(D_METHOD("prop_material_get_num"), &TerramanLibrary::prop_material_get_num); + ClassDB::bind_method(D_METHOD("prop_materials_clear"), &TerramanLibrary::prop_materials_clear); - ClassDB::bind_method(D_METHOD("prop_materials_get"), &VoxelmanLibrary::prop_materials_get); - ClassDB::bind_method(D_METHOD("prop_materials_set"), &VoxelmanLibrary::prop_materials_set); + ClassDB::bind_method(D_METHOD("prop_materials_get"), &TerramanLibrary::prop_materials_get); + ClassDB::bind_method(D_METHOD("prop_materials_set"), &TerramanLibrary::prop_materials_set); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "prop_materials_set", "prop_materials_get"); - ClassDB::bind_method(D_METHOD("voxel_surface_get", "index"), &VoxelmanLibrary::voxel_surface_get); - ClassDB::bind_method(D_METHOD("voxel_surface_add", "value"), &VoxelmanLibrary::voxel_surface_add); - ClassDB::bind_method(D_METHOD("voxel_surface_set", "index", "surface"), &VoxelmanLibrary::voxel_surface_set); - ClassDB::bind_method(D_METHOD("voxel_surface_remove", "index"), &VoxelmanLibrary::voxel_surface_remove); - ClassDB::bind_method(D_METHOD("voxel_surface_get_num"), &VoxelmanLibrary::voxel_surface_get_num); - ClassDB::bind_method(D_METHOD("voxel_surfaces_clear"), &VoxelmanLibrary::voxel_surfaces_clear); + ClassDB::bind_method(D_METHOD("voxel_surface_get", "index"), &TerramanLibrary::voxel_surface_get); + ClassDB::bind_method(D_METHOD("voxel_surface_add", "value"), &TerramanLibrary::voxel_surface_add); + ClassDB::bind_method(D_METHOD("voxel_surface_set", "index", "surface"), &TerramanLibrary::voxel_surface_set); + ClassDB::bind_method(D_METHOD("voxel_surface_remove", "index"), &TerramanLibrary::voxel_surface_remove); + ClassDB::bind_method(D_METHOD("voxel_surface_get_num"), &TerramanLibrary::voxel_surface_get_num); + ClassDB::bind_method(D_METHOD("voxel_surfaces_clear"), &TerramanLibrary::voxel_surfaces_clear); - ClassDB::bind_method(D_METHOD("scene_get", "index"), &VoxelmanLibrary::scene_get); - ClassDB::bind_method(D_METHOD("scene_add", "value"), &VoxelmanLibrary::scene_add); - ClassDB::bind_method(D_METHOD("scene_set", "index", "value"), &VoxelmanLibrary::scene_set); - ClassDB::bind_method(D_METHOD("scene_remove", "index"), &VoxelmanLibrary::scene_remove); - ClassDB::bind_method(D_METHOD("scene_get_num"), &VoxelmanLibrary::scene_get_num); - ClassDB::bind_method(D_METHOD("scenes_clear"), &VoxelmanLibrary::scenes_clear); + ClassDB::bind_method(D_METHOD("scene_get", "index"), &TerramanLibrary::scene_get); + ClassDB::bind_method(D_METHOD("scene_add", "value"), &TerramanLibrary::scene_add); + ClassDB::bind_method(D_METHOD("scene_set", "index", "value"), &TerramanLibrary::scene_set); + ClassDB::bind_method(D_METHOD("scene_remove", "index"), &TerramanLibrary::scene_remove); + ClassDB::bind_method(D_METHOD("scene_get_num"), &TerramanLibrary::scene_get_num); + ClassDB::bind_method(D_METHOD("scenes_clear"), &TerramanLibrary::scenes_clear); #ifdef PROPS_PRESENT - ClassDB::bind_method(D_METHOD("prop_get", "id"), &VoxelmanLibrary::prop_get); - ClassDB::bind_method(D_METHOD("prop_add", "value"), &VoxelmanLibrary::prop_add); - ClassDB::bind_method(D_METHOD("prop_has", "prop"), &VoxelmanLibrary::prop_has); - ClassDB::bind_method(D_METHOD("prop_set", "id", "surface"), &VoxelmanLibrary::prop_set); - ClassDB::bind_method(D_METHOD("prop_remove", "id"), &VoxelmanLibrary::prop_remove); - ClassDB::bind_method(D_METHOD("prop_get_num"), &VoxelmanLibrary::prop_get_num); - ClassDB::bind_method(D_METHOD("props_clear"), &VoxelmanLibrary::props_clear); + ClassDB::bind_method(D_METHOD("prop_get", "id"), &TerramanLibrary::prop_get); + ClassDB::bind_method(D_METHOD("prop_add", "value"), &TerramanLibrary::prop_add); + ClassDB::bind_method(D_METHOD("prop_has", "prop"), &TerramanLibrary::prop_has); + ClassDB::bind_method(D_METHOD("prop_set", "id", "surface"), &TerramanLibrary::prop_set); + ClassDB::bind_method(D_METHOD("prop_remove", "id"), &TerramanLibrary::prop_remove); + ClassDB::bind_method(D_METHOD("prop_get_num"), &TerramanLibrary::prop_get_num); + ClassDB::bind_method(D_METHOD("props_clear"), &TerramanLibrary::props_clear); #endif - ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelmanLibrary::refresh_rects); + ClassDB::bind_method(D_METHOD("refresh_rects"), &TerramanLibrary::refresh_rects); - ClassDB::bind_method(D_METHOD("setup_material_albedo", "material_index", "texture"), &VoxelmanLibrary::setup_material_albedo); + ClassDB::bind_method(D_METHOD("setup_material_albedo", "material_index", "texture"), &TerramanLibrary::setup_material_albedo); - BIND_CONSTANT(MATERIAL_INDEX_VOXELS); + BIND_CONSTANT(MATERIAL_INDEX_TERRAS); BIND_CONSTANT(MATERIAL_INDEX_LIQUID); BIND_CONSTANT(MATERIAL_INDEX_PROP); } diff --git a/library/voxelman_library.h b/library/voxelman_library.h index 2a9fe18..c44e00f 100644 --- a/library/voxelman_library.h +++ b/library/voxelman_library.h @@ -43,19 +43,19 @@ SOFTWARE. #define Texture Texture2D #endif -class VoxelSurface; -class VoxelMesher; +class TerraSurface; +class TerraMesher; class PackedScene; #ifdef PROPS_PRESENT class PropData; #endif -class VoxelmanLibrary : public Resource { - GDCLASS(VoxelmanLibrary, Resource) +class TerramanLibrary : public Resource { + GDCLASS(TerramanLibrary, Resource) public: enum { - MATERIAL_INDEX_VOXELS = 0, + MATERIAL_INDEX_TERRAS = 0, MATERIAL_INDEX_LIQUID = 1, MATERIAL_INDEX_PROP = 2, }; @@ -94,9 +94,9 @@ public: Vector prop_materials_get(); void prop_materials_set(const Vector &materials); - virtual Ref voxel_surface_get(const int index); - virtual void voxel_surface_add(Ref value); - virtual void voxel_surface_set(const int index, Ref value); + virtual Ref voxel_surface_get(const int index); + virtual void voxel_surface_add(Ref value); + virtual void voxel_surface_set(const int index, Ref value); virtual void voxel_surface_remove(const int index); virtual int voxel_surface_get_num() const; virtual void voxel_surfaces_clear(); @@ -124,8 +124,8 @@ public: void setup_material_albedo(int material_index, Ref texture); - VoxelmanLibrary(); - ~VoxelmanLibrary(); + TerramanLibrary(); + ~TerramanLibrary(); protected: static void _bind_methods(); @@ -137,4 +137,4 @@ private: Vector > _prop_materials; }; -#endif // VOXEL_LIBRARY_H +#endif // TERRA_LIBRARY_H diff --git a/library/voxelman_library_merger.cpp b/library/voxelman_library_merger.cpp index a9bf296..2c57e41 100644 --- a/library/voxelman_library_merger.cpp +++ b/library/voxelman_library_merger.cpp @@ -37,63 +37,63 @@ SOFTWARE. #include "../defines.h" -int VoxelmanLibraryMerger::get_texture_flags() const { +int TerramanLibraryMerger::get_texture_flags() const { return _packer->get_texture_flags(); } -void VoxelmanLibraryMerger::set_texture_flags(const int flags) { +void TerramanLibraryMerger::set_texture_flags(const int flags) { _packer->set_texture_flags(flags); _prop_packer->set_texture_flags(flags); } -int VoxelmanLibraryMerger::get_max_atlas_size() const { +int TerramanLibraryMerger::get_max_atlas_size() const { return _packer->get_max_atlas_size(); } -void VoxelmanLibraryMerger::set_max_atlas_size(const int size) { +void TerramanLibraryMerger::set_max_atlas_size(const int size) { _packer->set_max_atlas_size(size); _prop_packer->set_max_atlas_size(size); } -bool VoxelmanLibraryMerger::get_keep_original_atlases() const { +bool TerramanLibraryMerger::get_keep_original_atlases() const { return _packer->get_keep_original_atlases(); } -void VoxelmanLibraryMerger::set_keep_original_atlases(const bool value) { +void TerramanLibraryMerger::set_keep_original_atlases(const bool value) { _packer->set_keep_original_atlases(value); _prop_packer->set_keep_original_atlases(value); } -Color VoxelmanLibraryMerger::get_background_color() const { +Color TerramanLibraryMerger::get_background_color() const { return _packer->get_background_color(); } -void VoxelmanLibraryMerger::set_background_color(const Color &color) { +void TerramanLibraryMerger::set_background_color(const Color &color) { _packer->set_background_color(color); _prop_packer->set_background_color(color); } -int VoxelmanLibraryMerger::get_margin() const { +int TerramanLibraryMerger::get_margin() const { return _packer->get_margin(); } -void VoxelmanLibraryMerger::set_margin(const int margin) { +void TerramanLibraryMerger::set_margin(const int margin) { _packer->set_margin(margin); _prop_packer->set_margin(margin); } //Surfaces -Ref VoxelmanLibraryMerger::voxel_surface_get(const int index) { - ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); +Ref TerramanLibraryMerger::voxel_surface_get(const int index) { + ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); return _voxel_surfaces[index]; } -void VoxelmanLibraryMerger::voxel_surface_add(Ref value) { +void TerramanLibraryMerger::voxel_surface_add(Ref value) { ERR_FAIL_COND(!value.is_valid()); - value->set_library(Ref(this)); + value->set_library(Ref(this)); value->set_id(_voxel_surfaces.size()); _voxel_surfaces.push_back(value); } -void VoxelmanLibraryMerger::voxel_surface_set(const int index, Ref value) { +void TerramanLibraryMerger::voxel_surface_set(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_voxel_surfaces.size() < index) { @@ -101,29 +101,29 @@ void VoxelmanLibraryMerger::voxel_surface_set(const int index, Ref } if (_voxel_surfaces[index].is_valid()) { - _voxel_surfaces.get(index)->set_library(Ref(NULL)); + _voxel_surfaces.get(index)->set_library(Ref(NULL)); } if (value.is_valid()) { - value->set_library(Ref(this)); + value->set_library(Ref(this)); _voxel_surfaces.set(index, value); } } -void VoxelmanLibraryMerger::voxel_surface_remove(const int index) { +void TerramanLibraryMerger::voxel_surface_remove(const int index) { _voxel_surfaces.remove(index); } -int VoxelmanLibraryMerger::voxel_surface_get_num() const { +int TerramanLibraryMerger::voxel_surface_get_num() const { return _voxel_surfaces.size(); } -void VoxelmanLibraryMerger::voxel_surfaces_clear() { +void TerramanLibraryMerger::voxel_surfaces_clear() { _packer->clear(); for (int i = 0; i < _voxel_surfaces.size(); i++) { - Ref surface = _voxel_surfaces[i]; + Ref surface = _voxel_surfaces[i]; if (surface.is_valid()) { surface->set_library(NULL); @@ -133,15 +133,15 @@ void VoxelmanLibraryMerger::voxel_surfaces_clear() { _voxel_surfaces.clear(); } -Vector VoxelmanLibraryMerger::get_voxel_surfaces() { +Vector TerramanLibraryMerger::get_voxel_surfaces() { VARIANT_ARRAY_GET(_voxel_surfaces); } -void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector &surfaces) { +void TerramanLibraryMerger::set_voxel_surfaces(const Vector &surfaces) { _voxel_surfaces.clear(); for (int i = 0; i < surfaces.size(); i++) { - Ref surface = Ref(surfaces[i]); + Ref surface = Ref(surfaces[i]); if (surface.is_valid()) { surface->set_library(this); @@ -152,43 +152,43 @@ void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector &surfaces) } #ifdef PROPS_PRESENT -Ref VoxelmanLibraryMerger::get_prop(const int index) { +Ref TerramanLibraryMerger::get_prop(const int index) { ERR_FAIL_INDEX_V(index, _props.size(), Ref()); return _props[index]; } -void VoxelmanLibraryMerger::add_prop(Ref value) { +void TerramanLibraryMerger::add_prop(Ref value) { _props.push_back(value); } -bool VoxelmanLibraryMerger::has_prop(const Ref &value) const { +bool TerramanLibraryMerger::has_prop(const Ref &value) const { return _props.find(value) != -1; } -void VoxelmanLibraryMerger::set_prop(const int index, const Ref &value) { +void TerramanLibraryMerger::set_prop(const int index, const Ref &value) { ERR_FAIL_INDEX(index, _props.size()); _props.write[index] = value; } -void VoxelmanLibraryMerger::remove_prop(const int index) { +void TerramanLibraryMerger::remove_prop(const int index) { ERR_FAIL_INDEX(index, _props.size()); _props.remove(index); } -int VoxelmanLibraryMerger::get_num_props() const { +int TerramanLibraryMerger::get_num_props() const { return _props.size(); } -void VoxelmanLibraryMerger::clear_props() { +void TerramanLibraryMerger::clear_props() { _props.clear(); } -Vector VoxelmanLibraryMerger::get_props() { +Vector TerramanLibraryMerger::get_props() { VARIANT_ARRAY_GET(_props); } -void VoxelmanLibraryMerger::set_props(const Vector &props) { +void TerramanLibraryMerger::set_props(const Vector &props) { VARIANT_ARRAY_SET(props, _props, PropData); } -Rect2 VoxelmanLibraryMerger::get_prop_uv_rect(const Ref &texture) { +Rect2 TerramanLibraryMerger::get_prop_uv_rect(const Ref &texture) { if (!texture.is_valid()) { return Rect2(0, 0, 1, 1); } @@ -222,28 +222,28 @@ Rect2 VoxelmanLibraryMerger::get_prop_uv_rect(const Ref &texture) { return region; } -Ref VoxelmanLibraryMerger::get_prop_packer() { +Ref TerramanLibraryMerger::get_prop_packer() { return _prop_packer; } #endif -void VoxelmanLibraryMerger::refresh_rects() { +void TerramanLibraryMerger::refresh_rects() { bool texture_added = false; for (int i = 0; i < _voxel_surfaces.size(); i++) { - Ref surface = Ref(_voxel_surfaces[i]); + Ref surface = Ref(_voxel_surfaces[i]); if (surface.is_valid()) { - for (int j = 0; j < VoxelSurface::VOXEL_SIDES_COUNT; ++j) { - Ref tex = surface->get_texture(static_cast(j)); + for (int j = 0; j < TerraSurface::TERRA_SIDES_COUNT; ++j) { + Ref tex = surface->get_texture(static_cast(j)); if (!tex.is_valid()) continue; if (!_packer->contains_texture(tex)) { texture_added = true; - surface->set_region(static_cast(j), _packer->add_texture(tex)); + surface->set_region(static_cast(j), _packer->add_texture(tex)); } else { - surface->set_region(static_cast(j), _packer->get_texture(tex)); + surface->set_region(static_cast(j), _packer->get_texture(tex)); } } } @@ -256,7 +256,7 @@ void VoxelmanLibraryMerger::refresh_rects() { Ref tex = _packer->get_generated_texture(0); - setup_material_albedo(MATERIAL_INDEX_VOXELS, tex); + setup_material_albedo(MATERIAL_INDEX_TERRAS, tex); setup_material_albedo(MATERIAL_INDEX_LIQUID, tex); } @@ -285,7 +285,7 @@ void VoxelmanLibraryMerger::refresh_rects() { #endif for (int i = 0; i < _voxel_surfaces.size(); i++) { - Ref surface = _voxel_surfaces[i]; + Ref surface = _voxel_surfaces[i]; if (surface.is_valid()) { surface->refresh_rects(); @@ -295,13 +295,13 @@ void VoxelmanLibraryMerger::refresh_rects() { set_initialized(true); } -void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, const Ref &texture) { +void TerramanLibraryMerger::_setup_material_albedo(const int material_index, const Ref &texture) { Ref mat; int count = 0; switch (material_index) { - case MATERIAL_INDEX_VOXELS: + case MATERIAL_INDEX_TERRAS: count = material_get_num(); break; case MATERIAL_INDEX_LIQUID: @@ -315,7 +315,7 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con for (int i = 0; i < count; ++i) { switch (material_index) { - case MATERIAL_INDEX_VOXELS: + case MATERIAL_INDEX_TERRAS: mat = material_get(i); break; case MATERIAL_INDEX_LIQUID: @@ -336,7 +336,7 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con Ref shmat; switch (material_index) { - case MATERIAL_INDEX_VOXELS: + case MATERIAL_INDEX_TERRAS: shmat = material_get(i); break; case MATERIAL_INDEX_LIQUID: @@ -353,7 +353,7 @@ void VoxelmanLibraryMerger::_setup_material_albedo(const int material_index, con } } -VoxelmanLibraryMerger::VoxelmanLibraryMerger() { +TerramanLibraryMerger::TerramanLibraryMerger() { _packer.instance(); #if GODOT4 @@ -379,12 +379,12 @@ VoxelmanLibraryMerger::VoxelmanLibraryMerger() { _prop_packer->set_margin(0); } -VoxelmanLibraryMerger::~VoxelmanLibraryMerger() { +TerramanLibraryMerger::~TerramanLibraryMerger() { for (int i = 0; i < _voxel_surfaces.size(); ++i) { - Ref surface = _voxel_surfaces[i]; + Ref surface = _voxel_surfaces[i]; if (surface.is_valid()) { - surface->set_library(Ref()); + surface->set_library(Ref()); } } @@ -398,7 +398,7 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() { } #ifdef PROPS_PRESENT -bool VoxelmanLibraryMerger::process_prop_textures(Ref prop) { +bool TerramanLibraryMerger::process_prop_textures(Ref prop) { if (!prop.is_valid()) { return false; } @@ -432,40 +432,40 @@ bool VoxelmanLibraryMerger::process_prop_textures(Ref prop) { } #endif -void VoxelmanLibraryMerger::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_texture_flags"), &VoxelmanLibraryMerger::get_texture_flags); - ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &VoxelmanLibraryMerger::set_texture_flags); +void TerramanLibraryMerger::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_texture_flags"), &TerramanLibraryMerger::get_texture_flags); + ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &TerramanLibraryMerger::set_texture_flags); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_texture_flags", "get_texture_flags"); - ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &VoxelmanLibraryMerger::get_max_atlas_size); - ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &VoxelmanLibraryMerger::set_max_atlas_size); + ClassDB::bind_method(D_METHOD("get_max_atlas_size"), &TerramanLibraryMerger::get_max_atlas_size); + ClassDB::bind_method(D_METHOD("set_max_atlas_size", "size"), &TerramanLibraryMerger::set_max_atlas_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_atlas_size"), "set_max_atlas_size", "get_max_atlas_size"); - ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &VoxelmanLibraryMerger::get_keep_original_atlases); - ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &VoxelmanLibraryMerger::set_keep_original_atlases); + ClassDB::bind_method(D_METHOD("get_keep_original_atlases"), &TerramanLibraryMerger::get_keep_original_atlases); + ClassDB::bind_method(D_METHOD("set_keep_original_atlases", "value"), &TerramanLibraryMerger::set_keep_original_atlases); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "keep_original_atlases"), "set_keep_original_atlases", "get_keep_original_atlases"); - ClassDB::bind_method(D_METHOD("get_background_color"), &VoxelmanLibraryMerger::get_background_color); - ClassDB::bind_method(D_METHOD("set_background_color", "color"), &VoxelmanLibraryMerger::set_background_color); + ClassDB::bind_method(D_METHOD("get_background_color"), &TerramanLibraryMerger::get_background_color); + ClassDB::bind_method(D_METHOD("set_background_color", "color"), &TerramanLibraryMerger::set_background_color); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "background_color"), "set_background_color", "get_background_color"); - ClassDB::bind_method(D_METHOD("get_margin"), &VoxelmanLibraryMerger::get_margin); - ClassDB::bind_method(D_METHOD("set_margin", "size"), &VoxelmanLibraryMerger::set_margin); + ClassDB::bind_method(D_METHOD("get_margin"), &TerramanLibraryMerger::get_margin); + ClassDB::bind_method(D_METHOD("set_margin", "size"), &TerramanLibraryMerger::set_margin); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin"), "set_margin", "get_margin"); - ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibraryMerger::get_voxel_surfaces); - ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibraryMerger::set_voxel_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceMerger", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceMerger"), "set_voxel_surfaces", "get_voxel_surfaces"); + ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &TerramanLibraryMerger::get_voxel_surfaces); + ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &TerramanLibraryMerger::set_voxel_surfaces); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:TerraSurfaceMerger", PROPERTY_USAGE_DEFAULT, "TerraSurfaceMerger"), "set_voxel_surfaces", "get_voxel_surfaces"); #ifdef PROPS_PRESENT - ClassDB::bind_method(D_METHOD("get_props"), &VoxelmanLibraryMerger::get_props); - ClassDB::bind_method(D_METHOD("set_props"), &VoxelmanLibraryMerger::set_props); + ClassDB::bind_method(D_METHOD("get_props"), &TerramanLibraryMerger::get_props); + ClassDB::bind_method(D_METHOD("set_props"), &TerramanLibraryMerger::set_props); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PropData", PROPERTY_USAGE_DEFAULT, "PropData"), "set_props", "get_props"); - ClassDB::bind_method(D_METHOD("get_prop_uv_rect", "texture"), &VoxelmanLibraryMerger::get_prop_uv_rect); + ClassDB::bind_method(D_METHOD("get_prop_uv_rect", "texture"), &TerramanLibraryMerger::get_prop_uv_rect); - ClassDB::bind_method(D_METHOD("get_prop_packer"), &VoxelmanLibraryMerger::get_prop_packer); + ClassDB::bind_method(D_METHOD("get_prop_packer"), &TerramanLibraryMerger::get_prop_packer); #endif - ClassDB::bind_method(D_METHOD("_setup_material_albedo", "material_index", "texture"), &VoxelmanLibraryMerger::_setup_material_albedo); + ClassDB::bind_method(D_METHOD("_setup_material_albedo", "material_index", "texture"), &TerramanLibraryMerger::_setup_material_albedo); } diff --git a/library/voxelman_library_merger.h b/library/voxelman_library_merger.h index 24e8f77..ab8185f 100644 --- a/library/voxelman_library_merger.h +++ b/library/voxelman_library_merger.h @@ -40,12 +40,12 @@ SOFTWARE. #include "../data/voxel_light.h" #include "voxel_surface_merger.h" -class VoxelSurfaceSimple; -class VoxelMesher; +class TerraSurfaceSimple; +class TerraMesher; class PackedScene; -class VoxelmanLibraryMerger : public VoxelmanLibrary { - GDCLASS(VoxelmanLibraryMerger, VoxelmanLibrary) +class TerramanLibraryMerger : public TerramanLibrary { + GDCLASS(TerramanLibraryMerger, TerramanLibrary) public: int get_texture_flags() const; @@ -63,9 +63,9 @@ public: int get_margin() const; void set_margin(const int margin); - Ref voxel_surface_get(const int index); - void voxel_surface_add(Ref value); - void voxel_surface_set(const int index, Ref value); + Ref voxel_surface_get(const int index); + void voxel_surface_add(Ref value); + void voxel_surface_set(const int index, Ref value); void voxel_surface_remove(const int index); int voxel_surface_get_num() const; void voxel_surfaces_clear(); @@ -94,8 +94,8 @@ public: void _setup_material_albedo(const int material_index, const Ref &texture); - VoxelmanLibraryMerger(); - ~VoxelmanLibraryMerger(); + TerramanLibraryMerger(); + ~TerramanLibraryMerger(); protected: #ifdef PROPS_PRESENT @@ -105,7 +105,7 @@ protected: static void _bind_methods(); private: - Vector > _voxel_surfaces; + Vector > _voxel_surfaces; #ifdef PROPS_PRESENT Vector > _props; #endif diff --git a/library/voxelman_library_simple.cpp b/library/voxelman_library_simple.cpp index 69d0247..3bbd9ec 100644 --- a/library/voxelman_library_simple.cpp +++ b/library/voxelman_library_simple.cpp @@ -24,41 +24,41 @@ SOFTWARE. #include "../defines.h" -int VoxelmanLibrarySimple::get_atlas_columns() const { +int TerramanLibrarySimple::get_atlas_columns() const { return _atlas_columns; } -void VoxelmanLibrarySimple::set_atlas_columns(int s) { +void TerramanLibrarySimple::set_atlas_columns(int s) { ERR_FAIL_COND(s < 0); _atlas_columns = s; } -int VoxelmanLibrarySimple::get_atlas_rows() const { +int TerramanLibrarySimple::get_atlas_rows() const { return _atlas_rows; } -void VoxelmanLibrarySimple::set_atlas_rows(int s) { +void TerramanLibrarySimple::set_atlas_rows(int s) { ERR_FAIL_COND(s < 0); _atlas_rows = s; } //Surfaces -Ref VoxelmanLibrarySimple::voxel_surface_get(const int index) { - ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); +Ref TerramanLibrarySimple::voxel_surface_get(const int index) { + ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); return _voxel_surfaces[index]; } -void VoxelmanLibrarySimple::voxel_surface_add(Ref value) { +void TerramanLibrarySimple::voxel_surface_add(Ref value) { ERR_FAIL_COND(!value.is_valid()); - value->set_library(Ref(this)); + value->set_library(Ref(this)); value->set_id(_voxel_surfaces.size()); _voxel_surfaces.push_back(value); } -void VoxelmanLibrarySimple::voxel_surface_set(const int index, Ref value) { +void TerramanLibrarySimple::voxel_surface_set(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_voxel_surfaces.size() < index) { @@ -66,37 +66,37 @@ void VoxelmanLibrarySimple::voxel_surface_set(const int index, Ref } if (_voxel_surfaces[index].is_valid()) { - _voxel_surfaces.get(index)->set_library(Ref(NULL)); + _voxel_surfaces.get(index)->set_library(Ref(NULL)); } if (value.is_valid()) { - value->set_library(Ref(this)); + value->set_library(Ref(this)); _voxel_surfaces.set(index, value); } } -void VoxelmanLibrarySimple::voxel_surface_remove(const int index) { +void TerramanLibrarySimple::voxel_surface_remove(const int index) { _voxel_surfaces.remove(index); } -int VoxelmanLibrarySimple::voxel_surface_get_num() const { +int TerramanLibrarySimple::voxel_surface_get_num() const { return _voxel_surfaces.size(); } -void VoxelmanLibrarySimple::voxel_surfaces_clear() { +void TerramanLibrarySimple::voxel_surfaces_clear() { _voxel_surfaces.clear(); } -Vector VoxelmanLibrarySimple::get_voxel_surfaces() { +Vector TerramanLibrarySimple::get_voxel_surfaces() { VARIANT_ARRAY_GET(_voxel_surfaces); } -void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector &surfaces) { +void TerramanLibrarySimple::set_voxel_surfaces(const Vector &surfaces) { _voxel_surfaces.clear(); for (int i = 0; i < surfaces.size(); i++) { - Ref surface = Ref(surfaces[i]); + Ref surface = Ref(surfaces[i]); if (surface.is_valid()) { surface->set_library(this); @@ -109,9 +109,9 @@ void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector &surfaces) set_initialized(true); } -void VoxelmanLibrarySimple::refresh_rects() { +void TerramanLibrarySimple::refresh_rects() { for (int i = 0; i < _voxel_surfaces.size(); i++) { - Ref surface = Ref(_voxel_surfaces[i]); + Ref surface = Ref(_voxel_surfaces[i]); if (surface.is_valid()) { surface->refresh_rects(); @@ -119,33 +119,33 @@ void VoxelmanLibrarySimple::refresh_rects() { } } -VoxelmanLibrarySimple::VoxelmanLibrarySimple() { +TerramanLibrarySimple::TerramanLibrarySimple() { _atlas_rows = 8; _atlas_columns = 8; } -VoxelmanLibrarySimple::~VoxelmanLibrarySimple() { +TerramanLibrarySimple::~TerramanLibrarySimple() { for (int i = 0; i < _voxel_surfaces.size(); ++i) { - Ref surface = _voxel_surfaces[i]; + Ref surface = _voxel_surfaces[i]; if (surface.is_valid()) { - surface->set_library(Ref()); + surface->set_library(Ref()); } } _voxel_surfaces.clear(); } -void VoxelmanLibrarySimple::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_atlas_columns"), &VoxelmanLibrarySimple::get_atlas_columns); - ClassDB::bind_method(D_METHOD("set_atlas_columns", "value"), &VoxelmanLibrarySimple::set_atlas_columns); +void TerramanLibrarySimple::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_atlas_columns"), &TerramanLibrarySimple::get_atlas_columns); + ClassDB::bind_method(D_METHOD("set_atlas_columns", "value"), &TerramanLibrarySimple::set_atlas_columns); ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_columns"), "set_atlas_columns", "get_atlas_columns"); - ClassDB::bind_method(D_METHOD("get_atlas_rows"), &VoxelmanLibrarySimple::get_atlas_rows); - ClassDB::bind_method(D_METHOD("set_atlas_rows", "value"), &VoxelmanLibrarySimple::set_atlas_rows); + ClassDB::bind_method(D_METHOD("get_atlas_rows"), &TerramanLibrarySimple::get_atlas_rows); + ClassDB::bind_method(D_METHOD("set_atlas_rows", "value"), &TerramanLibrarySimple::set_atlas_rows); ADD_PROPERTY(PropertyInfo(Variant::INT, "atlas_rows"), "set_atlas_rows", "get_atlas_rows"); - ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &VoxelmanLibrarySimple::get_voxel_surfaces); - ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &VoxelmanLibrarySimple::set_voxel_surfaces); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceSimple", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceSimple"), "set_voxel_surfaces", "get_voxel_surfaces"); + ClassDB::bind_method(D_METHOD("get_voxel_surfaces"), &TerramanLibrarySimple::get_voxel_surfaces); + ClassDB::bind_method(D_METHOD("set_voxel_surfaces"), &TerramanLibrarySimple::set_voxel_surfaces); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_surfaces", PROPERTY_HINT_NONE, "17/17:TerraSurfaceSimple", PROPERTY_USAGE_DEFAULT, "TerraSurfaceSimple"), "set_voxel_surfaces", "get_voxel_surfaces"); } diff --git a/library/voxelman_library_simple.h b/library/voxelman_library_simple.h index 0847d4c..945b782 100644 --- a/library/voxelman_library_simple.h +++ b/library/voxelman_library_simple.h @@ -38,11 +38,11 @@ SOFTWARE. #include "../data/voxel_light.h" #include "voxel_surface_simple.h" -class VoxelSurfaceSimple; -class VoxelMesher; +class TerraSurfaceSimple; +class TerraMesher; -class VoxelmanLibrarySimple : public VoxelmanLibrary { - GDCLASS(VoxelmanLibrarySimple, VoxelmanLibrary) +class TerramanLibrarySimple : public TerramanLibrary { + GDCLASS(TerramanLibrarySimple, TerramanLibrary) public: int get_atlas_columns() const; @@ -51,9 +51,9 @@ public: int get_atlas_rows() const; void set_atlas_rows(int s); - Ref voxel_surface_get(const int index); - void voxel_surface_add(Ref value); - void voxel_surface_set(const int index, Ref value); + Ref voxel_surface_get(const int index); + void voxel_surface_add(Ref value); + void voxel_surface_set(const int index, Ref value); void voxel_surface_remove(const int index); int voxel_surface_get_num() const; void voxel_surfaces_clear(); @@ -63,18 +63,18 @@ public: void refresh_rects(); - VoxelmanLibrarySimple(); - ~VoxelmanLibrarySimple(); + TerramanLibrarySimple(); + ~TerramanLibrarySimple(); protected: static void _bind_methods(); private: - Vector > _voxel_surfaces; + Vector > _voxel_surfaces; //atlas int _atlas_columns; int _atlas_rows; }; -#endif // VOXEL_LIBRARY_H +#endif // TERRA_LIBRARY_H diff --git a/meshers/blocky/voxel_mesher_blocky.cpp b/meshers/blocky/voxel_mesher_blocky.cpp index 3f1c8e3..e181c60 100644 --- a/meshers/blocky/voxel_mesher_blocky.cpp +++ b/meshers/blocky/voxel_mesher_blocky.cpp @@ -24,20 +24,20 @@ SOFTWARE. #include "../../world/default/voxel_chunk_default.h" -bool VoxelMesherBlocky::get_always_add_colors() const { +bool TerraMesherBlocky::get_always_add_colors() const { return _always_add_colors; } -void VoxelMesherBlocky::set_always_add_colors(const bool value) { +void TerraMesherBlocky::set_always_add_colors(const bool value) { _always_add_colors = value; } -void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { - Ref chunk = p_chunk; +void TerraMesherBlocky::_add_chunk(Ref p_chunk) { + Ref chunk = p_chunk; ERR_FAIL_COND(!chunk.is_valid()); - //if ((get_build_flags() & VoxelChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) - // if (!chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_AO)) + //if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) + // if (!chunk->get_channel(TerraChunkDefault::DEFAULT_CHANNEL_AO)) // chunk->generate_ao(); int x_size = chunk->get_size_x(); @@ -59,25 +59,25 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { Color base_light(_base_light_value, _base_light_value, _base_light_value); Color light(1, 1, 1); - bool use_lighting = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0; - bool use_ao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_AO) != 0; - bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0; + bool use_lighting = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0; + bool use_ao = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_AO) != 0; + bool use_rao = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_RAO) != 0; if (use_lighting) { - channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + channel_color_r = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + channel_color_g = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + channel_color_b = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); if (use_ao) - channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO); + channel_ao = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_AO); if (use_rao) - channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); + channel_rao = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); } Vector liquids; for (int i = 0; i < _library->voxel_surface_get_num(); ++i) { - Ref surface = _library->voxel_surface_get(i); + Ref surface = _library->voxel_surface_get(i); if (!surface.is_valid()) continue; @@ -106,7 +106,7 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { if (liquids.find(type) != -1) continue; - Ref surface = _library->voxel_surface_get(type - 1); + Ref surface = _library->voxel_surface_get(type - 1); if (!surface.is_valid()) continue; @@ -162,10 +162,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -223,10 +223,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -283,10 +283,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -344,10 +344,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -404,10 +404,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -465,10 +465,10 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), - surface->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()), + surface->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1), x % get_texture_scale(), z % get_texture_scale(), get_texture_scale()) }; Vector3 verts[] = { @@ -493,17 +493,17 @@ void VoxelMesherBlocky::_add_chunk(Ref p_chunk) { } } -VoxelMesherBlocky::VoxelMesherBlocky() { +TerraMesherBlocky::TerraMesherBlocky() { _always_add_colors = false; } -VoxelMesherBlocky::~VoxelMesherBlocky() { +TerraMesherBlocky::~TerraMesherBlocky() { } -void VoxelMesherBlocky::_bind_methods() { - ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &VoxelMesherBlocky::_add_chunk); +void TerraMesherBlocky::_bind_methods() { + ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &TerraMesherBlocky::_add_chunk); - ClassDB::bind_method(D_METHOD("get_always_add_colors"), &VoxelMesherBlocky::get_always_add_colors); - ClassDB::bind_method(D_METHOD("set_always_add_colors", "value"), &VoxelMesherBlocky::set_always_add_colors); + ClassDB::bind_method(D_METHOD("get_always_add_colors"), &TerraMesherBlocky::get_always_add_colors); + ClassDB::bind_method(D_METHOD("set_always_add_colors", "value"), &TerraMesherBlocky::set_always_add_colors); ADD_PROPERTY(PropertyInfo(Variant::INT, "always_add_colors"), "set_always_add_colors", "get_always_add_colors"); } diff --git a/meshers/blocky/voxel_mesher_blocky.h b/meshers/blocky/voxel_mesher_blocky.h index 47cf25b..4b394a6 100644 --- a/meshers/blocky/voxel_mesher_blocky.h +++ b/meshers/blocky/voxel_mesher_blocky.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_MESHER_BLOCKY_H -#define VOXEL_MESHER_BLOCKY_H +#ifndef TERRA_MESHER_BLOCKY_H +#define TERRA_MESHER_BLOCKY_H #include "core/version.h" @@ -36,17 +36,17 @@ SOFTWARE. #include "../default/voxel_mesher_default.h" -class VoxelMesherBlocky : public VoxelMesherDefault { - GDCLASS(VoxelMesherBlocky, VoxelMesherDefault); +class TerraMesherBlocky : public TerraMesherDefault { + GDCLASS(TerraMesherBlocky, TerraMesherDefault); public: bool get_always_add_colors() const; void set_always_add_colors(const bool value); - void _add_chunk(Ref p_chunk); + void _add_chunk(Ref p_chunk); - VoxelMesherBlocky(); - ~VoxelMesherBlocky(); + TerraMesherBlocky(); + ~TerraMesherBlocky(); protected: static void _bind_methods(); diff --git a/meshers/blocky/voxel_mesher_liquid_blocky.cpp b/meshers/blocky/voxel_mesher_liquid_blocky.cpp index eb4c203..36c6ee2 100644 --- a/meshers/blocky/voxel_mesher_liquid_blocky.cpp +++ b/meshers/blocky/voxel_mesher_liquid_blocky.cpp @@ -24,12 +24,12 @@ SOFTWARE. #include "../../world/default/voxel_chunk_default.h" -void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { - Ref chunk = p_chunk; +void TerraMesherLiquidBlocky::_add_chunk(Ref p_chunk) { + Ref chunk = p_chunk; ERR_FAIL_COND(!chunk.is_valid()); - //if ((get_build_flags() & VoxelChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) + //if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) // chunk->generate_ao(); int x_size = chunk->get_size_x(); @@ -38,7 +38,7 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { float voxel_scale = get_voxel_scale(); - uint8_t *channel_type = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); + uint8_t *channel_type = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_TYPE); if (!channel_type) return; @@ -51,25 +51,25 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { Color base_light(_base_light_value, _base_light_value, _base_light_value); Color light; - bool use_lighting = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0; - bool use_ao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_AO) != 0; - bool use_rao = (get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_RAO) != 0; + bool use_lighting = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0; + bool use_ao = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_AO) != 0; + bool use_rao = (get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_RAO) != 0; if (use_lighting) { - channel_color_r = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - channel_color_g = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - channel_color_b = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + channel_color_r = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + channel_color_g = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + channel_color_b = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); if (use_ao) - channel_ao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO); + channel_ao = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_AO); if (use_rao) - channel_rao = chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); + channel_rao = chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); } Vector liquids; for (int i = 0; i < _library->voxel_surface_get_num(); ++i) { - Ref surface = _library->voxel_surface_get(i); + Ref surface = _library->voxel_surface_get(i); if (!surface.is_valid()) continue; @@ -98,7 +98,7 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { if (liquids.find(type) == -1) continue; - Ref surface = _library->voxel_surface_get(type - 1); + Ref surface = _library->voxel_surface_get(type - 1); if (!surface.is_valid()) continue; @@ -148,10 +148,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1)) }; Vector3 verts[] = { @@ -209,10 +209,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1)) }; Vector3 verts[] = { @@ -269,10 +269,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_TOP, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_TOP, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_TOP, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_TOP, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_TOP, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_TOP, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_TOP, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_TOP, Vector2(1, 1)) }; Vector3 verts[] = { @@ -330,10 +330,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_BOTTOM, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_BOTTOM, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_BOTTOM, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_BOTTOM, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_BOTTOM, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_BOTTOM, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_BOTTOM, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_BOTTOM, Vector2(1, 1)) }; Vector3 verts[] = { @@ -390,10 +390,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 0); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1)) }; Vector3 verts[] = { @@ -451,10 +451,10 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { add_indices(vc + 3); Vector2 uvs[] = { - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 1)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(0, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 0)), - surface->transform_uv(VoxelSurface::VOXEL_SIDE_SIDE, Vector2(1, 1)) + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 1)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(0, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 0)), + surface->transform_uv(TerraSurface::TERRA_SIDE_SIDE, Vector2(1, 1)) }; Vector3 verts[] = { @@ -479,12 +479,12 @@ void VoxelMesherLiquidBlocky::_add_chunk(Ref p_chunk) { } } -VoxelMesherLiquidBlocky::VoxelMesherLiquidBlocky() { +TerraMesherLiquidBlocky::TerraMesherLiquidBlocky() { } -VoxelMesherLiquidBlocky::~VoxelMesherLiquidBlocky() { +TerraMesherLiquidBlocky::~TerraMesherLiquidBlocky() { } -void VoxelMesherLiquidBlocky::_bind_methods() { - ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &VoxelMesherLiquidBlocky::_add_chunk); +void TerraMesherLiquidBlocky::_bind_methods() { + ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &TerraMesherLiquidBlocky::_add_chunk); } diff --git a/meshers/blocky/voxel_mesher_liquid_blocky.h b/meshers/blocky/voxel_mesher_liquid_blocky.h index f533889..a06b0d9 100644 --- a/meshers/blocky/voxel_mesher_liquid_blocky.h +++ b/meshers/blocky/voxel_mesher_liquid_blocky.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_MESHER_LIQUID_BLOCKY_H -#define VOXEL_MESHER_LIQUID_BLOCKY_H +#ifndef TERRA_MESHER_LIQUID_BLOCKY_H +#define TERRA_MESHER_LIQUID_BLOCKY_H #include "core/version.h" @@ -36,14 +36,14 @@ SOFTWARE. #include "../default/voxel_mesher_default.h" -class VoxelMesherLiquidBlocky : public VoxelMesherDefault { - GDCLASS(VoxelMesherLiquidBlocky, VoxelMesherDefault); +class TerraMesherLiquidBlocky : public TerraMesherDefault { + GDCLASS(TerraMesherLiquidBlocky, TerraMesherDefault); public: - void _add_chunk(Ref p_chunk); + void _add_chunk(Ref p_chunk); - VoxelMesherLiquidBlocky(); - ~VoxelMesherLiquidBlocky(); + TerraMesherLiquidBlocky(); + ~TerraMesherLiquidBlocky(); protected: static void _bind_methods(); diff --git a/meshers/cubic/voxel_cube_points.cpp b/meshers/cubic/voxel_cube_points.cpp index 7352979..35b30cc 100644 --- a/meshers/cubic/voxel_cube_points.cpp +++ b/meshers/cubic/voxel_cube_points.cpp @@ -24,34 +24,34 @@ SOFTWARE. #include "../../world/default/voxel_chunk_default.h" #include "../../world/voxel_chunk.h" -const unsigned int VoxelCubePoints::index_table[6][4] = { - { P000, P010, P110, P100 }, //VOXEL_FACE_FRONT 0 - { P100, P110, P111, P101 }, //VOXEL_FACE_RIGHT 1 - { P101, P111, P011, P001 }, //VOXEL_FACE_BACK 2 - { P001, P011, P010, P000 }, //VOXEL_FACE_LEFT 3 - { P111, P110, P010, P011 }, //VOXEL_FACE_TOP 4 - { P001, P000, P100, P101 }, //VOXEL_FACE_BOTTOM 5 +const unsigned int TerraCubePoints::index_table[6][4] = { + { P000, P010, P110, P100 }, //TERRA_FACE_FRONT 0 + { P100, P110, P111, P101 }, //TERRA_FACE_RIGHT 1 + { P101, P111, P011, P001 }, //TERRA_FACE_BACK 2 + { P001, P011, P010, P000 }, //TERRA_FACE_LEFT 3 + { P111, P110, P010, P011 }, //TERRA_FACE_TOP 4 + { P001, P000, P100, P101 }, //TERRA_FACE_BOTTOM 5 }; -const unsigned int VoxelCubePoints::visibility_check_table[6] = { - VOXEL_NEIGHBOUR_FRONT, //VOXEL_FACE_FRONT 0 - VOXEL_NEIGHBOUR_RIGHT, //VOXEL_FACE_RIGHT 1 - VOXEL_NEIGHBOUR_BACK, //VOXEL_FACE_BACK 2 - VOXEL_NEIGHBOUR_LEFT, //VOXEL_FACE_LEFT 3 - VOXEL_NEIGHBOUR_TOP, //VOXEL_FACE_TOP 4 - VOXEL_NEIGHBOUR_BOTTOM //VOXEL_FACE_BOTTOM 5 +const unsigned int TerraCubePoints::visibility_check_table[6] = { + TERRA_NEIGHBOUR_FRONT, //TERRA_FACE_FRONT 0 + TERRA_NEIGHBOUR_RIGHT, //TERRA_FACE_RIGHT 1 + TERRA_NEIGHBOUR_BACK, //TERRA_FACE_BACK 2 + TERRA_NEIGHBOUR_LEFT, //TERRA_FACE_LEFT 3 + TERRA_NEIGHBOUR_TOP, //TERRA_FACE_TOP 4 + TERRA_NEIGHBOUR_BOTTOM //TERRA_FACE_BOTTOM 5 }; -const int VoxelCubePoints::face_light_direction_table[6][3] = { - { 0, 0, -1 }, //VOXEL_FACE_FRONT 0 - { -1, 0, 0 }, //VOXEL_FACE_RIGHT 1 - { 0, 0, 1 }, //VOXEL_FACE_BACK 2 - { 1, 0, 0 }, //VOXEL_FACE_LEFT 3 - { 0, -1, 0 }, //VOXEL_FACE_TOP 4 - { 0, 1, 0 } //VOXEL_FACE_BOTTOM 5 +const int TerraCubePoints::face_light_direction_table[6][3] = { + { 0, 0, -1 }, //TERRA_FACE_FRONT 0 + { -1, 0, 0 }, //TERRA_FACE_RIGHT 1 + { 0, 0, 1 }, //TERRA_FACE_BACK 2 + { 1, 0, 0 }, //TERRA_FACE_LEFT 3 + { 0, -1, 0 }, //TERRA_FACE_TOP 4 + { 0, 1, 0 } //TERRA_FACE_BOTTOM 5 }; -const float VoxelCubePoints::point_direction_table[8][3] = { +const float TerraCubePoints::point_direction_table[8][3] = { { -0.5, -0.5, -0.5 }, //P000 { 0.5, -0.5, -0.5 }, //P100 { -0.5, 0.5, -0.5 }, //P010 @@ -63,70 +63,70 @@ const float VoxelCubePoints::point_direction_table[8][3] = { { 0.5, 0.5, 0.5 }, //P111 }; -const unsigned int VoxelCubePoints::point_direction_neighbour_table[8][3] = { - { VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_FRONT }, //P000 - { VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_FRONT }, //P100 - { VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_FRONT }, //P010 - { VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BACK }, //P001 +const unsigned int TerraCubePoints::point_direction_neighbour_table[8][3] = { + { TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_FRONT }, //P000 + { TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_FRONT }, //P100 + { TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_FRONT }, //P010 + { TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BACK }, //P001 - { VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_FRONT }, //P110 - { VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_BACK }, //P011 - { VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BACK }, //P101 - { VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_BACK }, //P111 + { TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_FRONT }, //P110 + { TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_BACK }, //P011 + { TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BACK }, //P101 + { TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_BACK }, //P111 }; -const float VoxelCubePoints::uv_direction_table[8][4][2] = { - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_FRONT 0, P000, P010, P110, P100 - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_RIGHT 1, P100, P110, P111, P101 - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_BACK 2, P101, P111, P011, P001 - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_LEFT 3, P001, P011, P010, P000 - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_TOP 4, P111, P110, P010, P011 - { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //VOXEL_FACE_BOTTOM 5, P001, P000, P100, P101 +const float TerraCubePoints::uv_direction_table[8][4][2] = { + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_FRONT 0, P000, P010, P110, P100 + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_RIGHT 1, P100, P110, P111, P101 + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_BACK 2, P101, P111, P011, P001 + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_LEFT 3, P001, P011, P010, P000 + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_TOP 4, P111, P110, P010, P011 + { { -0.5, -0.5 }, { 0.5, -0.5 }, { 0.5, 0.5 }, { 0.5, -0.5 } }, //TERRA_FACE_BOTTOM 5, P001, P000, P100, P101 }; -int VoxelCubePoints::get_x() { +int TerraCubePoints::get_x() { return _x; } -void VoxelCubePoints::set_x(int value) { +void TerraCubePoints::set_x(int value) { _x = value; } -int VoxelCubePoints::get_y() { +int TerraCubePoints::get_y() { return _y; } -void VoxelCubePoints::set_y(int value) { +void TerraCubePoints::set_y(int value) { _y = value; } -int VoxelCubePoints::get_z() { +int TerraCubePoints::get_z() { return _z; } -void VoxelCubePoints::set_z(int value) { +void TerraCubePoints::set_z(int value) { _z = value; } -int VoxelCubePoints::get_size() { +int TerraCubePoints::get_size() { return _size; } -void VoxelCubePoints::set_size(int value) { +void TerraCubePoints::set_size(int value) { _size = value; } -int VoxelCubePoints::get_channel_index_type() const { +int TerraCubePoints::get_channel_index_type() const { return _channel_index_type; } -void VoxelCubePoints::set_channel_index_type(const int value) { +void TerraCubePoints::set_channel_index_type(const int value) { _channel_index_type = value; } -int VoxelCubePoints::get_channel_index_isolevel() const { +int TerraCubePoints::get_channel_index_isolevel() const { return _channel_index_isolevel; } -void VoxelCubePoints::set_channel_index_isolevel(const int value) { +void TerraCubePoints::set_channel_index_isolevel(const int value) { _channel_index_isolevel = value; } -void VoxelCubePoints::refresh_points() { +void TerraCubePoints::refresh_points() { for (int i = 0; i < POINT_COUNT; ++i) { recalculate_point(i); } @@ -135,55 +135,55 @@ void VoxelCubePoints::refresh_points() { //Front //Bottom Left refresh_point(P000, 0, 0, 0, - VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BOTTOM_LEFT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_FRONT, - VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BOTTOM_LEFT, VOXEL_NEIGHBOUR_BOTTOM_FRONT, VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT, - VOXEL_NEIGHBOUR_FRONT, VOXEL_NEIGHBOUR_BOTTOM_FRONT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_FRONT); + TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BOTTOM_LEFT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_FRONT, + TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BOTTOM_LEFT, TERRA_NEIGHBOUR_BOTTOM_FRONT, TERRA_NEIGHBOUR_BOTTOM_LEFT_FRONT, + TERRA_NEIGHBOUR_FRONT, TERRA_NEIGHBOUR_BOTTOM_FRONT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_FRONT); //Bottom Right refresh_point(P100, 255, 0, 0, - VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BOTTOM_RIGHT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_FRONT, - VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BOTTOM_RIGHT, VOXEL_NEIGHBOUR_BOTTOM_FRONT, VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT, - VOXEL_NEIGHBOUR_FRONT, VOXEL_NEIGHBOUR_BOTTOM_FRONT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_FRONT); + TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BOTTOM_RIGHT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_FRONT, + TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BOTTOM_RIGHT, TERRA_NEIGHBOUR_BOTTOM_FRONT, TERRA_NEIGHBOUR_BOTTOM_RIGHT_FRONT, + TERRA_NEIGHBOUR_FRONT, TERRA_NEIGHBOUR_BOTTOM_FRONT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_FRONT); //Top Left refresh_point(P010, 0, 255, 0, - VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_TOP_LEFT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_FRONT, - VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_TOP_LEFT, VOXEL_NEIGHBOUR_TOP_FRONT, VOXEL_NEIGHBOUR_TOP_LEFT_FRONT, - VOXEL_NEIGHBOUR_FRONT, VOXEL_NEIGHBOUR_TOP_FRONT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_FRONT); + TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_TOP_LEFT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_FRONT, + TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_TOP_LEFT, TERRA_NEIGHBOUR_TOP_FRONT, TERRA_NEIGHBOUR_TOP_LEFT_FRONT, + TERRA_NEIGHBOUR_FRONT, TERRA_NEIGHBOUR_TOP_FRONT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_FRONT); //Top Right refresh_point(P110, 255, 255, 0, - VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_TOP_RIGHT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_FRONT, - VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_TOP_RIGHT, VOXEL_NEIGHBOUR_TOP_FRONT, VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT, - VOXEL_NEIGHBOUR_FRONT, VOXEL_NEIGHBOUR_TOP_FRONT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_FRONT); + TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_TOP_RIGHT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_FRONT, + TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_TOP_RIGHT, TERRA_NEIGHBOUR_TOP_FRONT, TERRA_NEIGHBOUR_TOP_RIGHT_FRONT, + TERRA_NEIGHBOUR_FRONT, TERRA_NEIGHBOUR_TOP_FRONT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_FRONT); //Back //Bottom Left refresh_point(P001, 0, 0, 255, - VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BOTTOM_LEFT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BACK, - VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BOTTOM_LEFT, VOXEL_NEIGHBOUR_BOTTOM_BACK, VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK, - VOXEL_NEIGHBOUR_BACK, VOXEL_NEIGHBOUR_BOTTOM_BACK, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BACK); + TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BOTTOM_LEFT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BACK, + TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BOTTOM_LEFT, TERRA_NEIGHBOUR_BOTTOM_BACK, TERRA_NEIGHBOUR_BOTTOM_LEFT_BACK, + TERRA_NEIGHBOUR_BACK, TERRA_NEIGHBOUR_BOTTOM_BACK, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BACK); //Bottom Right refresh_point(P101, 255, 0, 255, - VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BOTTOM_RIGHT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BACK, - VOXEL_NEIGHBOUR_BOTTOM, VOXEL_NEIGHBOUR_BOTTOM_RIGHT, VOXEL_NEIGHBOUR_BOTTOM_BACK, VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK, - VOXEL_NEIGHBOUR_BACK, VOXEL_NEIGHBOUR_BOTTOM_BACK, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BACK); + TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BOTTOM_RIGHT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BACK, + TERRA_NEIGHBOUR_BOTTOM, TERRA_NEIGHBOUR_BOTTOM_RIGHT, TERRA_NEIGHBOUR_BOTTOM_BACK, TERRA_NEIGHBOUR_BOTTOM_RIGHT_BACK, + TERRA_NEIGHBOUR_BACK, TERRA_NEIGHBOUR_BOTTOM_BACK, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BACK); //Top Left refresh_point(P011, 0, 255, 255, - VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_TOP_LEFT, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BACK, - VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_TOP_LEFT, VOXEL_NEIGHBOUR_TOP_BACK, VOXEL_NEIGHBOUR_TOP_LEFT_BACK, - VOXEL_NEIGHBOUR_BACK, VOXEL_NEIGHBOUR_TOP_BACK, VOXEL_NEIGHBOUR_LEFT, VOXEL_NEIGHBOUR_BACK); + TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_TOP_LEFT, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BACK, + TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_TOP_LEFT, TERRA_NEIGHBOUR_TOP_BACK, TERRA_NEIGHBOUR_TOP_LEFT_BACK, + TERRA_NEIGHBOUR_BACK, TERRA_NEIGHBOUR_TOP_BACK, TERRA_NEIGHBOUR_LEFT, TERRA_NEIGHBOUR_BACK); //Top Right refresh_point(P111, 255, 255, 255, - VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_TOP_RIGHT, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BACK, - VOXEL_NEIGHBOUR_TOP, VOXEL_NEIGHBOUR_TOP_RIGHT, VOXEL_NEIGHBOUR_TOP_BACK, VOXEL_NEIGHBOUR_TOP_RIGHT_BACK, - VOXEL_NEIGHBOUR_BACK, VOXEL_NEIGHBOUR_TOP_BACK, VOXEL_NEIGHBOUR_RIGHT, VOXEL_NEIGHBOUR_BACK);*/ + TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_TOP_RIGHT, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BACK, + TERRA_NEIGHBOUR_TOP, TERRA_NEIGHBOUR_TOP_RIGHT, TERRA_NEIGHBOUR_TOP_BACK, TERRA_NEIGHBOUR_TOP_RIGHT_BACK, + TERRA_NEIGHBOUR_BACK, TERRA_NEIGHBOUR_TOP_BACK, TERRA_NEIGHBOUR_RIGHT, TERRA_NEIGHBOUR_BACK);*/ } -void VoxelCubePoints::recalculate_point(int point) { +void TerraCubePoints::recalculate_point(int point) { ERR_FAIL_INDEX(point, POINT_COUNT); Vector3 static_offset; @@ -206,7 +206,7 @@ void VoxelCubePoints::recalculate_point(int point) { _points[point] = dynamic_offset; } -void VoxelCubePoints::refresh_neighbours(Ref chunk) { +void TerraCubePoints::refresh_neighbours(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); int neighbours = 0; @@ -217,25 +217,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //000 if (chunk->get_voxel(x - 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT; if (chunk->get_voxel(x, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM; if (chunk->get_voxel(x, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_FRONT; /* if (chunk->get_voxel(x - 1, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT_FRONT; if (chunk->get_voxel(x - 1, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_LEFT; if (chunk->get_voxel(x, y - 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_FRONT; if (chunk->get_voxel(x - 1, y - 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_LEFT_FRONT;*/ _point_neighbours[P000] = neighbours; @@ -246,25 +246,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //100 if (chunk->get_voxel(x + 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT; if (chunk->get_voxel(x, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM; if (chunk->get_voxel(x, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_FRONT; /* if (chunk->get_voxel(x + 1, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT_FRONT; if (chunk->get_voxel(x + 1, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_RIGHT; if (chunk->get_voxel(x, y - 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_FRONT; if (chunk->get_voxel(x + 1, y - 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_RIGHT_FRONT;*/ _point_neighbours[P100] = neighbours; @@ -275,25 +275,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //010 if (chunk->get_voxel(x - 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT; if (chunk->get_voxel(x, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP; if (chunk->get_voxel(x, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_FRONT; /* if (chunk->get_voxel(x - 1, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT_FRONT; if (chunk->get_voxel(x - 1, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_LEFT; if (chunk->get_voxel(x, y + 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_FRONT; if (chunk->get_voxel(x - 1, y + 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_FRONT;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_LEFT_FRONT;*/ _point_neighbours[P010] = neighbours; @@ -304,25 +304,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //110 if (chunk->get_voxel(x + 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT; if (chunk->get_voxel(x, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP; if (chunk->get_voxel(x, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_FRONT; /* if (chunk->get_voxel(x + 1, y, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT_FRONT; if (chunk->get_voxel(x + 1, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_RIGHT; if (chunk->get_voxel(x, y + 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_FRONT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_FRONT; if (chunk->get_voxel(x + 1, y + 1, z - 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_RIGHT_FRONT;*/ _point_neighbours[P110] = neighbours; @@ -333,25 +333,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //001 if (chunk->get_voxel(x - 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT; if (chunk->get_voxel(x, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM; if (chunk->get_voxel(x, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BACK; /* if (chunk->get_voxel(x - 1, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT_BACK; if (chunk->get_voxel(x - 1, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_LEFT; if (chunk->get_voxel(x, y - 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_BACK; if (chunk->get_voxel(x - 1, y - 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_LEFT_BACK;*/ _point_neighbours[P001] = neighbours; @@ -362,25 +362,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //101 if (chunk->get_voxel(x + 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT; if (chunk->get_voxel(x, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM; if (chunk->get_voxel(x, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BACK; /* if (chunk->get_voxel(x + 1, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT_BACK; if (chunk->get_voxel(x + 1, y - 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_RIGHT; if (chunk->get_voxel(x, y - 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_BACK; if (chunk->get_voxel(x + 1, y - 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_BOTTOM_RIGHT_BACK;*/ _point_neighbours[P101] = neighbours; @@ -391,25 +391,25 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //011 if (chunk->get_voxel(x - 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT; if (chunk->get_voxel(x, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP; if (chunk->get_voxel(x, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BACK; /* if (chunk->get_voxel(x - 1, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_LEFT_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_LEFT_BACK; if (chunk->get_voxel(x - 1, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_LEFT; if (chunk->get_voxel(x, y + 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_BACK; if (chunk->get_voxel(x - 1, y + 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_LEFT_BACK;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_LEFT_BACK;*/ _point_neighbours[P011] = neighbours; @@ -420,30 +420,30 @@ void VoxelCubePoints::refresh_neighbours(Ref chunk) { //111 if (chunk->get_voxel(x + 1, y, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT; if (chunk->get_voxel(x, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP; if (chunk->get_voxel(x, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_BACK; /* if (chunk->get_voxel(x + 1, y, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_RIGHT_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_RIGHT_BACK; if (chunk->get_voxel(x + 1, y + 1, z, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_RIGHT; if (chunk->get_voxel(x, y + 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_BACK; + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_BACK; if (chunk->get_voxel(x + 1, y + 1, z + 1, _channel_index_type) != 0) - neighbours = neighbours | VOXEL_NEIGHBOUR_TOP_RIGHT_BACK;*/ + neighbours = neighbours | TERRA_NEIGHBOUR_TOP_RIGHT_BACK;*/ _point_neighbours[P111] = neighbours; } -void VoxelCubePoints::setup(Ref chunk, int x, int y, int z, int size) { +void TerraCubePoints::setup(Ref chunk, int x, int y, int z, int size) { ERR_FAIL_COND(!chunk.is_valid()); ERR_FAIL_COND(size <= 0); ERR_FAIL_COND(!chunk->validate_data_position(x + size, y + size, z + size) || !chunk->validate_data_position(x, y, z)); @@ -488,30 +488,30 @@ void VoxelCubePoints::setup(Ref chunk, int x, int y, int z, int size // } //} - _point_aos[P000] = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P100] = chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P010] = chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P001] = chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P110] = chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P011] = chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P101] = chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO); - _point_aos[P111] = chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P000] = chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P100] = chunk->get_voxel(x + size, y, z, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P010] = chunk->get_voxel(x, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P001] = chunk->get_voxel(x, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P110] = chunk->get_voxel(x + size, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P011] = chunk->get_voxel(x, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P101] = chunk->get_voxel(x + size, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_AO); + _point_aos[P111] = chunk->get_voxel(x + size, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_AO); - _point_colors[P000] = Color(chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P100] = Color(chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P010] = Color(chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P001] = Color(chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P110] = Color(chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P011] = Color(chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P101] = Color(chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - _point_colors[P111] = Color(chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z + size, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P000] = Color(chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P100] = Color(chunk->get_voxel(x + size, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P010] = Color(chunk->get_voxel(x, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P001] = Color(chunk->get_voxel(x, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P110] = Color(chunk->get_voxel(x + size, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P011] = Color(chunk->get_voxel(x, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P101] = Color(chunk->get_voxel(x + size, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + _point_colors[P111] = Color(chunk->get_voxel(x + size, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, chunk->get_voxel(x + size, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, chunk->get_voxel(x + size, y + size, z + size, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); refresh_neighbours(chunk); refresh_points(); } -void VoxelCubePoints::reset() { +void TerraCubePoints::reset() { for (int i = 0; i < POINT_COUNT; ++i) { _point_types[i] = 0; _point_fills[i] = 0; @@ -524,26 +524,26 @@ void VoxelCubePoints::reset() { _size = 1; } -int VoxelCubePoints::get_point_index(int face, int index) { - ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, 0); +int TerraCubePoints::get_point_index(int face, int index) { + ERR_FAIL_INDEX_V(face, TERRA_FACE_COUNT, 0); ERR_FAIL_INDEX_V(index, 4, 0); return index_table[face][index]; } -Vector2 VoxelCubePoints::get_point_uv_direction(int face, int index) { - ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, Vector2()); +Vector2 TerraCubePoints::get_point_uv_direction(int face, int index) { + ERR_FAIL_INDEX_V(face, TERRA_FACE_COUNT, Vector2()); ERR_FAIL_INDEX_V(index, 4, Vector2()); return Vector2(uv_direction_table[face][index][0], uv_direction_table[face][index][1]); } -Vector3 VoxelCubePoints::get_points_for_face(int face, int index) { +Vector3 TerraCubePoints::get_points_for_face(int face, int index) { return _points[get_point_index(face, index)]; } -bool VoxelCubePoints::is_face_visible(int face) { - ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, false); +bool TerraCubePoints::is_face_visible(int face) { + ERR_FAIL_INDEX_V(face, TERRA_FACE_COUNT, false); int target_neighbour = visibility_check_table[face]; @@ -558,7 +558,7 @@ bool VoxelCubePoints::is_face_visible(int face) { return false; } -bool VoxelCubePoints::is_sub_voxel_point(int x, int y, int z) { +bool TerraCubePoints::is_sub_voxel_point(int x, int y, int z) { for (int i = 0; i < POINT_COUNT; i += 1) { if (get_point(i) == Vector3(x, y, z)) { return true; @@ -567,11 +567,11 @@ bool VoxelCubePoints::is_sub_voxel_point(int x, int y, int z) { return false; } -void VoxelCubePoints::set_point(int point, int x, int y, int z) { +void TerraCubePoints::set_point(int point, int x, int y, int z) { _points[point] = Vector3(x, y, z); } -int VoxelCubePoints::get_point_id(int x, int y, int z) { +int TerraCubePoints::get_point_id(int x, int y, int z) { //for (int i = 0; i < POINT_COUNT; ++i) { // if (get_point(i) == Vector3i(x, y, z)) { // return i; @@ -580,13 +580,13 @@ int VoxelCubePoints::get_point_id(int x, int y, int z) { return 0; } -Vector3 VoxelCubePoints::get_point_for_face(int face, int index) { +Vector3 TerraCubePoints::get_point_for_face(int face, int index) { int indx = get_point_index(face, index); return _points[indx]; } -Vector3 VoxelCubePoints::get_vertex_vector3_for_point(int face, int index) { +Vector3 TerraCubePoints::get_vertex_vector3_for_point(int face, int index) { int point_index = get_point_index(face, index); Vector3 a = get_point(point_index); @@ -603,37 +603,37 @@ Vector3 VoxelCubePoints::get_vertex_vector3_for_point(int face, int index) { return vector; } -int VoxelCubePoints::get_point_type(int index) { +int TerraCubePoints::get_point_type(int index) { ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); return _point_types[index]; } -int VoxelCubePoints::get_point_fill(int index) { +int TerraCubePoints::get_point_fill(int index) { ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); return _point_fills[index]; } -int VoxelCubePoints::get_point_neighbours(int index) { +int TerraCubePoints::get_point_neighbours(int index) { ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); return _point_neighbours[index]; } -int VoxelCubePoints::get_point_ao(int index) { +int TerraCubePoints::get_point_ao(int index) { ERR_FAIL_INDEX_V(index, POINT_COUNT, 0); return _point_aos[index]; } -int VoxelCubePoints::get_face_point_ao(int face, int index) { +int TerraCubePoints::get_face_point_ao(int face, int index) { int indx = get_point_index(face, index); return _point_aos[indx]; } -Color VoxelCubePoints::get_face_point_ao_color(int face, int index) { +Color TerraCubePoints::get_face_point_ao_color(int face, int index) { int indx = get_point_index(face, index); float ao_value = (_point_aos[indx] / 255.0) * 0.75; @@ -641,12 +641,12 @@ Color VoxelCubePoints::get_face_point_ao_color(int face, int index) { return Color(ao_value, ao_value, ao_value); } -Color VoxelCubePoints::get_face_point_light_color(int face, int index) { +Color TerraCubePoints::get_face_point_light_color(int face, int index) { int indx = get_point_index(face, index); return _point_colors[indx]; } -Color VoxelCubePoints::get_face_point_color_mixed(int face, int index) { +Color TerraCubePoints::get_face_point_color_mixed(int face, int index) { int indx = get_point_index(face, index); float ao_value = (_point_aos[indx] / 255.0) * 0.75; @@ -654,129 +654,129 @@ Color VoxelCubePoints::get_face_point_color_mixed(int face, int index) { return _point_colors[indx] - Color(ao_value, ao_value, ao_value); } -Vector3 VoxelCubePoints::get_face_light_direction(int face) { - ERR_FAIL_INDEX_V(face, VOXEL_FACE_COUNT, Vector3()); +Vector3 TerraCubePoints::get_face_light_direction(int face) { + ERR_FAIL_INDEX_V(face, TERRA_FACE_COUNT, Vector3()); return Vector3(face_light_direction_table[face][0], face_light_direction_table[face][1], face_light_direction_table[face][2]); } -Vector3 VoxelCubePoints::get_point(int index) { +Vector3 TerraCubePoints::get_point(int index) { ERR_FAIL_INDEX_V(index, POINT_COUNT, Vector3()); return _points[index]; } -Vector3 VoxelCubePoints::get_top_left_point(int face) { - if (face == VOXEL_FACE_BACK) { +Vector3 TerraCubePoints::get_top_left_point(int face) { + if (face == TERRA_FACE_BACK) { return _points[P011]; } - if (face == VOXEL_FACE_FRONT) { + if (face == TERRA_FACE_FRONT) { return _points[P010]; } - if (face == VOXEL_FACE_RIGHT) { + if (face == TERRA_FACE_RIGHT) { return _points[P111]; } - if (face == VOXEL_FACE_LEFT) { + if (face == TERRA_FACE_LEFT) { return _points[P010]; } - if (face == VOXEL_FACE_TOP) { + if (face == TERRA_FACE_TOP) { return _points[P010]; } - if (face == VOXEL_FACE_BOTTOM) { + if (face == TERRA_FACE_BOTTOM) { return _points[P000]; } return _points[0]; } -Vector3 VoxelCubePoints::get_top_right_point(int face) { - if (face == VOXEL_FACE_BACK) { +Vector3 TerraCubePoints::get_top_right_point(int face) { + if (face == TERRA_FACE_BACK) { return _points[P111]; } - if (face == VOXEL_FACE_FRONT) { + if (face == TERRA_FACE_FRONT) { return _points[P110]; } - if (face == VOXEL_FACE_RIGHT) { + if (face == TERRA_FACE_RIGHT) { return _points[P110]; } - if (face == VOXEL_FACE_LEFT) { + if (face == TERRA_FACE_LEFT) { return _points[P011]; } - if (face == VOXEL_FACE_TOP) { + if (face == TERRA_FACE_TOP) { return _points[P110]; } - if (face == VOXEL_FACE_BOTTOM) { + if (face == TERRA_FACE_BOTTOM) { return _points[P100]; } return _points[0]; } -Vector3 VoxelCubePoints::get_bottom_left_point(int face) { - if (face == VOXEL_FACE_BACK) { +Vector3 TerraCubePoints::get_bottom_left_point(int face) { + if (face == TERRA_FACE_BACK) { return _points[P001]; } - if (face == VOXEL_FACE_FRONT) { + if (face == TERRA_FACE_FRONT) { return _points[P000]; } - if (face == VOXEL_FACE_RIGHT) { + if (face == TERRA_FACE_RIGHT) { return _points[P101]; } - if (face == VOXEL_FACE_LEFT) { + if (face == TERRA_FACE_LEFT) { return _points[P001]; } - if (face == VOXEL_FACE_TOP) { + if (face == TERRA_FACE_TOP) { return _points[P011]; } - if (face == VOXEL_FACE_BOTTOM) { + if (face == TERRA_FACE_BOTTOM) { return _points[P001]; } return _points[0]; } -Vector3 VoxelCubePoints::get_bottom_right_point(int face) { - if (face == VOXEL_FACE_BACK) { +Vector3 TerraCubePoints::get_bottom_right_point(int face) { + if (face == TERRA_FACE_BACK) { return _points[P101]; } - if (face == VOXEL_FACE_FRONT) { + if (face == TERRA_FACE_FRONT) { return _points[P100]; } - if (face == VOXEL_FACE_RIGHT) { + if (face == TERRA_FACE_RIGHT) { return _points[P100]; } - if (face == VOXEL_FACE_LEFT) { + if (face == TERRA_FACE_LEFT) { return _points[P001]; } - if (face == VOXEL_FACE_TOP) { + if (face == TERRA_FACE_TOP) { return _points[P111]; } - if (face == VOXEL_FACE_BOTTOM) { + if (face == TERRA_FACE_BOTTOM) { return _points[P101]; } return _points[P000]; } -uint8_t VoxelCubePoints::get_face_type(int face) { - if (face == VOXEL_FACE_BACK) { +uint8_t TerraCubePoints::get_face_type(int face) { + if (face == TERRA_FACE_BACK) { return _point_types[P111]; } - if (face == VOXEL_FACE_FRONT) { + if (face == TERRA_FACE_FRONT) { return _point_types[P110]; } - if (face == VOXEL_FACE_RIGHT) { + if (face == TERRA_FACE_RIGHT) { return _point_types[P110]; } - if (face == VOXEL_FACE_LEFT) { + if (face == TERRA_FACE_LEFT) { return _point_types[P011]; } - if (face == VOXEL_FACE_TOP) { + if (face == TERRA_FACE_TOP) { return _point_types[P110]; } - if (face == VOXEL_FACE_BOTTOM) { + if (face == TERRA_FACE_BOTTOM) { return _point_types[P100]; } return _point_types[0]; } -bool VoxelCubePoints::has_points() { +bool TerraCubePoints::has_points() { return (_point_types[P000] != 0 && _point_types[P100] != 0 && _point_types[P010] != 0 && _point_types[P001] != 0 && _point_types[P110] != 0 && _point_types[P011] != 0 && _point_types[P101] != 0 && _point_types[P111] != 0); @@ -784,102 +784,102 @@ bool VoxelCubePoints::has_points() { // _point_types[P110] == 0 && _point_types[P011] == 0 && _point_types[P101] == 0 && _point_types[P111] == 0); } -int VoxelCubePoints::get_opposite_face(int face) { - if (face == VOXEL_FACE_FRONT) { - return VOXEL_FACE_BACK; +int TerraCubePoints::get_opposite_face(int face) { + if (face == TERRA_FACE_FRONT) { + return TERRA_FACE_BACK; } - if (face == VOXEL_FACE_BACK) { - return VOXEL_FACE_FRONT; + if (face == TERRA_FACE_BACK) { + return TERRA_FACE_FRONT; } - if (face == VOXEL_FACE_LEFT) { - return VOXEL_FACE_RIGHT; + if (face == TERRA_FACE_LEFT) { + return TERRA_FACE_RIGHT; } - if (face == VOXEL_FACE_RIGHT) { - return VOXEL_FACE_LEFT; + if (face == TERRA_FACE_RIGHT) { + return TERRA_FACE_LEFT; } - if (face == VOXEL_FACE_TOP) { - return VOXEL_FACE_BOTTOM; + if (face == TERRA_FACE_TOP) { + return TERRA_FACE_BOTTOM; } - return VOXEL_FACE_BOTTOM; + return TERRA_FACE_BOTTOM; } -VoxelCubePoints::VoxelCubePoints() { +TerraCubePoints::TerraCubePoints() { _channel_index_type = 0; _channel_index_isolevel = 0; reset(); } -VoxelCubePoints::~VoxelCubePoints() { +TerraCubePoints::~TerraCubePoints() { } -void VoxelCubePoints::_bind_methods() { +void TerraCubePoints::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_x"), &VoxelCubePoints::get_x); - ClassDB::bind_method(D_METHOD("set_x", "value"), &VoxelCubePoints::set_x); + ClassDB::bind_method(D_METHOD("get_x"), &TerraCubePoints::get_x); + ClassDB::bind_method(D_METHOD("set_x", "value"), &TerraCubePoints::set_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x"); - ClassDB::bind_method(D_METHOD("get_y"), &VoxelCubePoints::get_y); - ClassDB::bind_method(D_METHOD("set_y", "value"), &VoxelCubePoints::set_y); + ClassDB::bind_method(D_METHOD("get_y"), &TerraCubePoints::get_y); + ClassDB::bind_method(D_METHOD("set_y", "value"), &TerraCubePoints::set_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y"); - ClassDB::bind_method(D_METHOD("get_z"), &VoxelCubePoints::get_z); - ClassDB::bind_method(D_METHOD("set_z", "value"), &VoxelCubePoints::set_z); + ClassDB::bind_method(D_METHOD("get_z"), &TerraCubePoints::get_z); + ClassDB::bind_method(D_METHOD("set_z", "value"), &TerraCubePoints::set_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "z"), "set_z", "get_z"); - ClassDB::bind_method(D_METHOD("get_size"), &VoxelCubePoints::get_size); - ClassDB::bind_method(D_METHOD("set_size", "value"), &VoxelCubePoints::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &TerraCubePoints::get_size); + ClassDB::bind_method(D_METHOD("set_size", "value"), &TerraCubePoints::set_size); ADD_PROPERTY(PropertyInfo(Variant::INT, "size"), "set_size", "get_size"); - ClassDB::bind_method(D_METHOD("get_channel_index_type"), &VoxelCubePoints::get_channel_index_type); - ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &VoxelCubePoints::set_channel_index_type); + ClassDB::bind_method(D_METHOD("get_channel_index_type"), &TerraCubePoints::get_channel_index_type); + ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &TerraCubePoints::set_channel_index_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_type"), "set_channel_index_type", "get_channel_index_type"); - ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &VoxelCubePoints::get_channel_index_isolevel); - ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &VoxelCubePoints::set_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &TerraCubePoints::get_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &TerraCubePoints::set_channel_index_isolevel); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel"); - ClassDB::bind_method(D_METHOD("refresh_points"), &VoxelCubePoints::refresh_points); - ClassDB::bind_method(D_METHOD("setup", "chunk", "x", "y", "z", "size"), &VoxelCubePoints::setup, DEFVAL(1)); + ClassDB::bind_method(D_METHOD("refresh_points"), &TerraCubePoints::refresh_points); + ClassDB::bind_method(D_METHOD("setup", "chunk", "x", "y", "z", "size"), &TerraCubePoints::setup, DEFVAL(1)); - ClassDB::bind_method(D_METHOD("get_point_index", "face", "index"), &VoxelCubePoints::get_point_index); - ClassDB::bind_method(D_METHOD("get_point_uv_direction", "face", "index"), &VoxelCubePoints::get_point_uv_direction); + ClassDB::bind_method(D_METHOD("get_point_index", "face", "index"), &TerraCubePoints::get_point_index); + ClassDB::bind_method(D_METHOD("get_point_uv_direction", "face", "index"), &TerraCubePoints::get_point_uv_direction); - ClassDB::bind_method(D_METHOD("get_points_for_face", "face", "index"), &VoxelCubePoints::get_points_for_face); + ClassDB::bind_method(D_METHOD("get_points_for_face", "face", "index"), &TerraCubePoints::get_points_for_face); - ClassDB::bind_method(D_METHOD("is_face_visible", "face"), &VoxelCubePoints::is_face_visible); + ClassDB::bind_method(D_METHOD("is_face_visible", "face"), &TerraCubePoints::is_face_visible); - ClassDB::bind_method(D_METHOD("is_sub_voxel_point", "x", "y", "z"), &VoxelCubePoints::is_sub_voxel_point); - ClassDB::bind_method(D_METHOD("set_point", "point", "x", "y", "z"), &VoxelCubePoints::set_point); - ClassDB::bind_method(D_METHOD("get_point_id", "x", "y", "z"), &VoxelCubePoints::get_point_id); + ClassDB::bind_method(D_METHOD("is_sub_voxel_point", "x", "y", "z"), &TerraCubePoints::is_sub_voxel_point); + ClassDB::bind_method(D_METHOD("set_point", "point", "x", "y", "z"), &TerraCubePoints::set_point); + ClassDB::bind_method(D_METHOD("get_point_id", "x", "y", "z"), &TerraCubePoints::get_point_id); - ClassDB::bind_method(D_METHOD("get_point_for_face", "face", "index"), &VoxelCubePoints::get_point_for_face); - ClassDB::bind_method(D_METHOD("get_vertex_vector3_for_point", "face", "index"), &VoxelCubePoints::get_vertex_vector3_for_point); + ClassDB::bind_method(D_METHOD("get_point_for_face", "face", "index"), &TerraCubePoints::get_point_for_face); + ClassDB::bind_method(D_METHOD("get_vertex_vector3_for_point", "face", "index"), &TerraCubePoints::get_vertex_vector3_for_point); - ClassDB::bind_method(D_METHOD("get_point_type", "index"), &VoxelCubePoints::get_point_type); - ClassDB::bind_method(D_METHOD("get_point_fill", "index"), &VoxelCubePoints::get_point_fill); - ClassDB::bind_method(D_METHOD("get_point_neighbours", "index"), &VoxelCubePoints::get_point_neighbours); + ClassDB::bind_method(D_METHOD("get_point_type", "index"), &TerraCubePoints::get_point_type); + ClassDB::bind_method(D_METHOD("get_point_fill", "index"), &TerraCubePoints::get_point_fill); + ClassDB::bind_method(D_METHOD("get_point_neighbours", "index"), &TerraCubePoints::get_point_neighbours); - ClassDB::bind_method(D_METHOD("get_point_ao", "index"), &VoxelCubePoints::get_point_ao); - ClassDB::bind_method(D_METHOD("get_face_point_ao", "face", "index"), &VoxelCubePoints::get_face_point_ao); - ClassDB::bind_method(D_METHOD("get_face_point_ao_color", "face", "index"), &VoxelCubePoints::get_face_point_ao_color); - ClassDB::bind_method(D_METHOD("get_face_point_light_color", "face", "index"), &VoxelCubePoints::get_face_point_light_color); - ClassDB::bind_method(D_METHOD("get_face_point_color_mixed", "face", "index"), &VoxelCubePoints::get_face_point_color_mixed); + ClassDB::bind_method(D_METHOD("get_point_ao", "index"), &TerraCubePoints::get_point_ao); + ClassDB::bind_method(D_METHOD("get_face_point_ao", "face", "index"), &TerraCubePoints::get_face_point_ao); + ClassDB::bind_method(D_METHOD("get_face_point_ao_color", "face", "index"), &TerraCubePoints::get_face_point_ao_color); + ClassDB::bind_method(D_METHOD("get_face_point_light_color", "face", "index"), &TerraCubePoints::get_face_point_light_color); + ClassDB::bind_method(D_METHOD("get_face_point_color_mixed", "face", "index"), &TerraCubePoints::get_face_point_color_mixed); - ClassDB::bind_method(D_METHOD("get_face_light_direction", "face"), &VoxelCubePoints::get_face_light_direction); + ClassDB::bind_method(D_METHOD("get_face_light_direction", "face"), &TerraCubePoints::get_face_light_direction); - ClassDB::bind_method(D_METHOD("get_point", "index"), &VoxelCubePoints::get_point); + ClassDB::bind_method(D_METHOD("get_point", "index"), &TerraCubePoints::get_point); - ClassDB::bind_method(D_METHOD("get_top_left_point", "face"), &VoxelCubePoints::get_top_left_point); - ClassDB::bind_method(D_METHOD("get_top_right_point", "face"), &VoxelCubePoints::get_top_right_point); - ClassDB::bind_method(D_METHOD("get_bottom_left_point", "face"), &VoxelCubePoints::get_bottom_left_point); - ClassDB::bind_method(D_METHOD("get_bottom_right_point", "face"), &VoxelCubePoints::get_bottom_right_point); + ClassDB::bind_method(D_METHOD("get_top_left_point", "face"), &TerraCubePoints::get_top_left_point); + ClassDB::bind_method(D_METHOD("get_top_right_point", "face"), &TerraCubePoints::get_top_right_point); + ClassDB::bind_method(D_METHOD("get_bottom_left_point", "face"), &TerraCubePoints::get_bottom_left_point); + ClassDB::bind_method(D_METHOD("get_bottom_right_point", "face"), &TerraCubePoints::get_bottom_right_point); - ClassDB::bind_method(D_METHOD("get_face_type", "face"), &VoxelCubePoints::get_face_type); + ClassDB::bind_method(D_METHOD("get_face_type", "face"), &TerraCubePoints::get_face_type); - ClassDB::bind_method(D_METHOD("has_points"), &VoxelCubePoints::has_points); - ClassDB::bind_method(D_METHOD("get_opposite_face", "face"), &VoxelCubePoints::get_opposite_face); + ClassDB::bind_method(D_METHOD("has_points"), &TerraCubePoints::has_points); + ClassDB::bind_method(D_METHOD("get_opposite_face", "face"), &TerraCubePoints::get_opposite_face); BIND_ENUM_CONSTANT(P000); BIND_ENUM_CONSTANT(P100); @@ -891,50 +891,50 @@ void VoxelCubePoints::_bind_methods() { BIND_ENUM_CONSTANT(P111); BIND_ENUM_CONSTANT(POINT_COUNT); - BIND_ENUM_CONSTANT(VOXEL_FACE_FRONT); - BIND_ENUM_CONSTANT(VOXEL_FACE_RIGHT); - BIND_ENUM_CONSTANT(VOXEL_FACE_BACK); - BIND_ENUM_CONSTANT(VOXEL_FACE_LEFT); - BIND_ENUM_CONSTANT(VOXEL_FACE_TOP); - BIND_ENUM_CONSTANT(VOXEL_FACE_BOTTOM); - BIND_ENUM_CONSTANT(VOXEL_FACE_COUNT); + BIND_ENUM_CONSTANT(TERRA_FACE_FRONT); + BIND_ENUM_CONSTANT(TERRA_FACE_RIGHT); + BIND_ENUM_CONSTANT(TERRA_FACE_BACK); + BIND_ENUM_CONSTANT(TERRA_FACE_LEFT); + BIND_ENUM_CONSTANT(TERRA_FACE_TOP); + BIND_ENUM_CONSTANT(TERRA_FACE_BOTTOM); + BIND_ENUM_CONSTANT(TERRA_FACE_COUNT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_NONE); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_NONE); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_LEFT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_RIGHT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_LEFT_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_RIGHT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_LEFT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_LEFT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_RIGHT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_RIGHT_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_LEFT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_RIGHT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_LEFT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_RIGHT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_LEFT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_LEFT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_RIGHT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_BOTTOM_RIGHT_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_LEFT_BACK); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT); - BIND_ENUM_CONSTANT(VOXEL_NEIGHBOUR_TOP_RIGHT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_LEFT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_LEFT_BACK); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_RIGHT_FRONT); + BIND_ENUM_CONSTANT(TERRA_NEIGHBOUR_TOP_RIGHT_BACK); - BIND_ENUM_CONSTANT(VOXEL_FULL_NEIGHBOURS_CROSS); - BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS); - BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS_TOP); - BIND_ENUM_CONSTANT(VOXEL_FULL_SIDE_NEIGHBOURS_DOWN); + BIND_ENUM_CONSTANT(TERRA_FULL_NEIGHBOURS_CROSS); + BIND_ENUM_CONSTANT(TERRA_FULL_SIDE_NEIGHBOURS); + BIND_ENUM_CONSTANT(TERRA_FULL_SIDE_NEIGHBOURS_TOP); + BIND_ENUM_CONSTANT(TERRA_FULL_SIDE_NEIGHBOURS_DOWN); } diff --git a/meshers/cubic/voxel_cube_points.h b/meshers/cubic/voxel_cube_points.h index be840e3..817ed72 100644 --- a/meshers/cubic/voxel_cube_points.h +++ b/meshers/cubic/voxel_cube_points.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef SUB_VOXEL_POINTS_H -#define SUB_VOXEL_POINTS_H +#ifndef SUB_TERRA_POINTS_H +#define SUB_TERRA_POINTS_H #include "core/version.h" @@ -33,11 +33,11 @@ SOFTWARE. #include "core/vector.h" #endif -class VoxelChunk; -class SubVoxelFacePointsHelper; +class TerraChunk; +class SubTerraFacePointsHelper; -class VoxelCubePoints : public Reference { - GDCLASS(VoxelCubePoints, Reference); +class TerraCubePoints : public Reference { + GDCLASS(TerraCubePoints, Reference); public: enum Points { @@ -54,55 +54,55 @@ public: POINT_COUNT = 8, }; - enum VoxelFaces { - VOXEL_FACE_FRONT = 0, - VOXEL_FACE_RIGHT = 1, - VOXEL_FACE_BACK = 2, - VOXEL_FACE_LEFT = 3, - VOXEL_FACE_TOP = 4, - VOXEL_FACE_BOTTOM = 5, - VOXEL_FACE_COUNT = 6, + enum TerraFaces { + TERRA_FACE_FRONT = 0, + TERRA_FACE_RIGHT = 1, + TERRA_FACE_BACK = 2, + TERRA_FACE_LEFT = 3, + TERRA_FACE_TOP = 4, + TERRA_FACE_BOTTOM = 5, + TERRA_FACE_COUNT = 6, }; - enum VoxelNeighbours { - VOXEL_NEIGHBOUR_NONE = 0, + enum TerraNeighbours { + TERRA_NEIGHBOUR_NONE = 0, - VOXEL_NEIGHBOUR_LEFT = 1 << 0, - VOXEL_NEIGHBOUR_RIGHT = 1 << 1, - VOXEL_NEIGHBOUR_FRONT = 1 << 2, - VOXEL_NEIGHBOUR_BACK = 1 << 3, - VOXEL_NEIGHBOUR_TOP = 1 << 4, - VOXEL_NEIGHBOUR_BOTTOM = 1 << 5, + TERRA_NEIGHBOUR_LEFT = 1 << 0, + TERRA_NEIGHBOUR_RIGHT = 1 << 1, + TERRA_NEIGHBOUR_FRONT = 1 << 2, + TERRA_NEIGHBOUR_BACK = 1 << 3, + TERRA_NEIGHBOUR_TOP = 1 << 4, + TERRA_NEIGHBOUR_BOTTOM = 1 << 5, - VOXEL_NEIGHBOUR_LEFT_FRONT = 1 << 6, - VOXEL_NEIGHBOUR_LEFT_BACK = 1 << 7, - VOXEL_NEIGHBOUR_RIGHT_FRONT = 1 << 8, - VOXEL_NEIGHBOUR_RIGHT_BACK = 1 << 9, + TERRA_NEIGHBOUR_LEFT_FRONT = 1 << 6, + TERRA_NEIGHBOUR_LEFT_BACK = 1 << 7, + TERRA_NEIGHBOUR_RIGHT_FRONT = 1 << 8, + TERRA_NEIGHBOUR_RIGHT_BACK = 1 << 9, - VOXEL_NEIGHBOUR_TOP_LEFT = 1 << 10, - VOXEL_NEIGHBOUR_TOP_RIGHT = 1 << 11, - VOXEL_NEIGHBOUR_TOP_FRONT = 1 << 12, - VOXEL_NEIGHBOUR_TOP_BACK = 1 << 13, + TERRA_NEIGHBOUR_TOP_LEFT = 1 << 10, + TERRA_NEIGHBOUR_TOP_RIGHT = 1 << 11, + TERRA_NEIGHBOUR_TOP_FRONT = 1 << 12, + TERRA_NEIGHBOUR_TOP_BACK = 1 << 13, - VOXEL_NEIGHBOUR_BOTTOM_LEFT = 1 << 14, - VOXEL_NEIGHBOUR_BOTTOM_RIGHT = 1 << 15, - VOXEL_NEIGHBOUR_BOTTOM_FRONT = 1 << 16, - VOXEL_NEIGHBOUR_BOTTOM_BACK = 1 << 17, + TERRA_NEIGHBOUR_BOTTOM_LEFT = 1 << 14, + TERRA_NEIGHBOUR_BOTTOM_RIGHT = 1 << 15, + TERRA_NEIGHBOUR_BOTTOM_FRONT = 1 << 16, + TERRA_NEIGHBOUR_BOTTOM_BACK = 1 << 17, - VOXEL_NEIGHBOUR_BOTTOM_LEFT_FRONT = 1 << 18, - VOXEL_NEIGHBOUR_BOTTOM_LEFT_BACK = 1 << 19, - VOXEL_NEIGHBOUR_BOTTOM_RIGHT_FRONT = 1 << 20, - VOXEL_NEIGHBOUR_BOTTOM_RIGHT_BACK = 1 << 21, + TERRA_NEIGHBOUR_BOTTOM_LEFT_FRONT = 1 << 18, + TERRA_NEIGHBOUR_BOTTOM_LEFT_BACK = 1 << 19, + TERRA_NEIGHBOUR_BOTTOM_RIGHT_FRONT = 1 << 20, + TERRA_NEIGHBOUR_BOTTOM_RIGHT_BACK = 1 << 21, - VOXEL_NEIGHBOUR_TOP_LEFT_FRONT = 1 << 22, - VOXEL_NEIGHBOUR_TOP_LEFT_BACK = 1 << 23, - VOXEL_NEIGHBOUR_TOP_RIGHT_FRONT = 1 << 24, - VOXEL_NEIGHBOUR_TOP_RIGHT_BACK = 1 << 25, + TERRA_NEIGHBOUR_TOP_LEFT_FRONT = 1 << 22, + TERRA_NEIGHBOUR_TOP_LEFT_BACK = 1 << 23, + TERRA_NEIGHBOUR_TOP_RIGHT_FRONT = 1 << 24, + TERRA_NEIGHBOUR_TOP_RIGHT_BACK = 1 << 25, - VOXEL_FULL_NEIGHBOURS_CROSS = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_TOP | VOXEL_NEIGHBOUR_BOTTOM, // | VOXEL_NEIGHBOUR_LEFT_BACK | VOXEL_NEIGHBOUR_LEFT_FRONT | VOXEL_NEIGHBOUR_RIGHT_BACK | VOXEL_NEIGHBOUR_RIGHT_FRONT; - VOXEL_FULL_SIDE_NEIGHBOURS = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT, - VOXEL_FULL_SIDE_NEIGHBOURS_TOP = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_TOP, - VOXEL_FULL_SIDE_NEIGHBOURS_DOWN = VOXEL_NEIGHBOUR_LEFT | VOXEL_NEIGHBOUR_RIGHT | VOXEL_NEIGHBOUR_BACK | VOXEL_NEIGHBOUR_FRONT | VOXEL_NEIGHBOUR_BOTTOM, + TERRA_FULL_NEIGHBOURS_CROSS = TERRA_NEIGHBOUR_LEFT | TERRA_NEIGHBOUR_RIGHT | TERRA_NEIGHBOUR_BACK | TERRA_NEIGHBOUR_FRONT | TERRA_NEIGHBOUR_TOP | TERRA_NEIGHBOUR_BOTTOM, // | TERRA_NEIGHBOUR_LEFT_BACK | TERRA_NEIGHBOUR_LEFT_FRONT | TERRA_NEIGHBOUR_RIGHT_BACK | TERRA_NEIGHBOUR_RIGHT_FRONT; + TERRA_FULL_SIDE_NEIGHBOURS = TERRA_NEIGHBOUR_LEFT | TERRA_NEIGHBOUR_RIGHT | TERRA_NEIGHBOUR_BACK | TERRA_NEIGHBOUR_FRONT, + TERRA_FULL_SIDE_NEIGHBOURS_TOP = TERRA_NEIGHBOUR_LEFT | TERRA_NEIGHBOUR_RIGHT | TERRA_NEIGHBOUR_BACK | TERRA_NEIGHBOUR_FRONT | TERRA_NEIGHBOUR_TOP, + TERRA_FULL_SIDE_NEIGHBOURS_DOWN = TERRA_NEIGHBOUR_LEFT | TERRA_NEIGHBOUR_RIGHT | TERRA_NEIGHBOUR_BACK | TERRA_NEIGHBOUR_FRONT | TERRA_NEIGHBOUR_BOTTOM, }; int get_x(); @@ -125,8 +125,8 @@ public: void refresh_points(); void recalculate_point(int point); - void refresh_neighbours(Ref chunk); - void setup(Ref chunk, int x, int y, int z, int size = 1); + void refresh_neighbours(Ref chunk); + void setup(Ref chunk, int x, int y, int z, int size = 1); void reset(); @@ -165,8 +165,8 @@ public: bool has_points(); int get_opposite_face(int face); - VoxelCubePoints(); - ~VoxelCubePoints(); + TerraCubePoints(); + ~TerraCubePoints(); protected: static void _bind_methods(); @@ -196,8 +196,8 @@ private: int _z; }; -VARIANT_ENUM_CAST(VoxelCubePoints::Points); -VARIANT_ENUM_CAST(VoxelCubePoints::VoxelFaces); -VARIANT_ENUM_CAST(VoxelCubePoints::VoxelNeighbours); +VARIANT_ENUM_CAST(TerraCubePoints::Points); +VARIANT_ENUM_CAST(TerraCubePoints::TerraFaces); +VARIANT_ENUM_CAST(TerraCubePoints::TerraNeighbours); #endif diff --git a/meshers/cubic/voxel_mesher_cubic.cpp b/meshers/cubic/voxel_mesher_cubic.cpp index b388967..0485495 100644 --- a/meshers/cubic/voxel_mesher_cubic.cpp +++ b/meshers/cubic/voxel_mesher_cubic.cpp @@ -28,8 +28,8 @@ SOFTWARE. #include visual_server_h -void VoxelMesherCubic::_add_chunk(Ref p_chunk) { - Ref chunk = p_chunk; +void TerraMesherCubic::_add_chunk(Ref p_chunk) { + Ref chunk = p_chunk; ERR_FAIL_COND(!chunk.is_valid()); @@ -37,7 +37,7 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { return; } - //if (chunk->get_channel(VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO)) { + //if (chunk->get_channel(TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO)) { // chunk->generate_ao(); //} @@ -48,7 +48,7 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { float voxel_size = 1; float voxel_scale = get_voxel_scale(); - Ref cube_points; + Ref cube_points; cube_points.instance(); cube_points->set_channel_index_type(_channel_index_type); cube_points->set_channel_index_isolevel(_channel_index_isolevel); @@ -64,13 +64,13 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { if (!cube_points->has_points()) continue; - for (int face = 0; face < VoxelCubePoints::VOXEL_FACE_COUNT; ++face) { + for (int face = 0; face < TerraCubePoints::TERRA_FACE_COUNT; ++face) { if (!cube_points->is_face_visible(face)) continue; uint8_t type = cube_points->get_face_type(face) - 1; - Ref surface = _library->voxel_surface_get(type); + Ref surface = _library->voxel_surface_get(type); if (!surface.is_valid()) continue; @@ -119,14 +119,14 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { Vector2 uv = cube_points->get_point_uv_direction(face, i) + Vector2(0.5, 0.5); - VoxelSurface::VoxelSurfaceSides side = VoxelSurface::VOXEL_SIDE_SIDE; + TerraSurface::TerraSurfaceSides side = TerraSurface::TERRA_SIDE_SIDE; switch (face) { - case VoxelCubePoints::VOXEL_FACE_TOP: - side = VoxelSurface::VOXEL_SIDE_TOP; + case TerraCubePoints::TERRA_FACE_TOP: + side = TerraSurface::TERRA_SIDE_TOP; break; - case VoxelCubePoints::VOXEL_FACE_BOTTOM: - side = VoxelSurface::VOXEL_SIDE_BOTTOM; + case TerraCubePoints::TERRA_FACE_BOTTOM: + side = TerraSurface::TERRA_SIDE_BOTTOM; break; } @@ -143,15 +143,15 @@ void VoxelMesherCubic::_add_chunk(Ref p_chunk) { } } -VoxelMesherCubic::VoxelMesherCubic() { +TerraMesherCubic::TerraMesherCubic() { _format = VisualServer::ARRAY_FORMAT_NORMAL | VisualServer::ARRAY_FORMAT_COLOR | VisualServer::ARRAY_FORMAT_TEX_UV; _texture_scale = 1; } -VoxelMesherCubic::~VoxelMesherCubic() { +TerraMesherCubic::~TerraMesherCubic() { } -void VoxelMesherCubic::_bind_methods() { - ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &VoxelMesherCubic::_add_chunk); +void TerraMesherCubic::_bind_methods() { + ClassDB::bind_method(D_METHOD("_add_chunk", "buffer"), &TerraMesherCubic::_add_chunk); } diff --git a/meshers/cubic/voxel_mesher_cubic.h b/meshers/cubic/voxel_mesher_cubic.h index ddce83b..38e7a5c 100644 --- a/meshers/cubic/voxel_mesher_cubic.h +++ b/meshers/cubic/voxel_mesher_cubic.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_MESHER_CUBIC_H -#define VOXEL_MESHER_CUBIC_H +#ifndef TERRA_MESHER_CUBIC_H +#define TERRA_MESHER_CUBIC_H #include "core/version.h" @@ -38,14 +38,14 @@ SOFTWARE. #include "voxel_cube_points.h" -class VoxelMesherCubic : public VoxelMesherDefault { - GDCLASS(VoxelMesherCubic, VoxelMesherDefault); +class TerraMesherCubic : public TerraMesherDefault { + GDCLASS(TerraMesherCubic, TerraMesherDefault); public: - void _add_chunk(Ref p_chunk); + void _add_chunk(Ref p_chunk); - VoxelMesherCubic(); - ~VoxelMesherCubic(); + TerraMesherCubic(); + ~TerraMesherCubic(); protected: static void _bind_methods(); diff --git a/meshers/default/voxel_mesher_default.cpp b/meshers/default/voxel_mesher_default.cpp index 2b22b8e..a889a79 100644 --- a/meshers/default/voxel_mesher_default.cpp +++ b/meshers/default/voxel_mesher_default.cpp @@ -29,23 +29,23 @@ SOFTWARE. #include visual_server_h #include mesh_instance_h -_FORCE_INLINE_ int VoxelMesherDefault::get_build_flags() const { +_FORCE_INLINE_ int TerraMesherDefault::get_build_flags() const { return _build_flags; } -_FORCE_INLINE_ void VoxelMesherDefault::set_build_flags(const int flags) { +_FORCE_INLINE_ void TerraMesherDefault::set_build_flags(const int flags) { _build_flags = flags; - if ((_build_flags & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((_build_flags & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { _format |= VisualServer::ARRAY_FORMAT_COLOR; } else { _format ^= VisualServer::ARRAY_FORMAT_COLOR; } } -void VoxelMesherDefault::_bake_colors(Ref chunk) { +void TerraMesherDefault::_bake_colors(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); - //if ((get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) + //if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) // return; if (_vertices.size() == 0) @@ -68,12 +68,12 @@ void VoxelMesherDefault::_bake_colors(Ref chunk) { if (chunk->validate_data_position(x, y, z)) { Color light = Color( - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - float ao = (chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength; - float rao = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; + float ao = (chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength; + float rao = chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; ao += rao; @@ -101,10 +101,10 @@ void VoxelMesherDefault::_bake_colors(Ref chunk) { } } -void VoxelMesherDefault::_bake_liquid_colors(Ref chunk) { +void TerraMesherDefault::_bake_liquid_colors(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); - if ((get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) + if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) return; if (_vertices.size() == 0) @@ -127,12 +127,12 @@ void VoxelMesherDefault::_bake_liquid_colors(Ref chunk) { if (chunk->validate_data_position(x, y, z)) { Color light = Color( - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, - chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, + chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - float ao = (chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength; - float rao = chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; + float ao = (chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * _ao_strength; + float rao = chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; ao += rao; @@ -160,20 +160,20 @@ void VoxelMesherDefault::_bake_liquid_colors(Ref chunk) { } } -VoxelMesherDefault::VoxelMesherDefault() { - _build_flags = VoxelChunkDefault::BUILD_FLAG_CREATE_COLLIDER | VoxelChunkDefault::BUILD_FLAG_CREATE_LODS; +TerraMesherDefault::TerraMesherDefault() { + _build_flags = TerraChunkDefault::BUILD_FLAG_CREATE_COLLIDER | TerraChunkDefault::BUILD_FLAG_CREATE_LODS; _format = VisualServer::ARRAY_FORMAT_NORMAL | VisualServer::ARRAY_FORMAT_TEX_UV; } -VoxelMesherDefault::~VoxelMesherDefault() { +TerraMesherDefault::~TerraMesherDefault() { } -void VoxelMesherDefault::_bind_methods() { - ClassDB::bind_method(D_METHOD("_bake_colors", "chunk"), &VoxelMesherDefault::_bake_colors); - ClassDB::bind_method(D_METHOD("_bake_liquid_colors", "chunk"), &VoxelMesherDefault::_bake_liquid_colors); +void TerraMesherDefault::_bind_methods() { + ClassDB::bind_method(D_METHOD("_bake_colors", "chunk"), &TerraMesherDefault::_bake_colors); + ClassDB::bind_method(D_METHOD("_bake_liquid_colors", "chunk"), &TerraMesherDefault::_bake_liquid_colors); - ClassDB::bind_method(D_METHOD("get_build_flags"), &VoxelMesherDefault::get_build_flags); - ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &VoxelMesherDefault::set_build_flags); - ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, VoxelChunkDefault::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); + ClassDB::bind_method(D_METHOD("get_build_flags"), &TerraMesherDefault::get_build_flags); + ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &TerraMesherDefault::set_build_flags); + ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, TerraChunkDefault::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); } diff --git a/meshers/default/voxel_mesher_default.h b/meshers/default/voxel_mesher_default.h index 719b78e..6140747 100644 --- a/meshers/default/voxel_mesher_default.h +++ b/meshers/default/voxel_mesher_default.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_MESHER_DEFAULT_H -#define VOXEL_MESHER_DEFAULT_H +#ifndef TERRA_MESHER_DEFAULT_H +#define TERRA_MESHER_DEFAULT_H #include "core/version.h" @@ -36,19 +36,19 @@ SOFTWARE. #include "../voxel_mesher.h" -class VoxelMesherDefault : public VoxelMesher { - GDCLASS(VoxelMesherDefault, VoxelMesher); +class TerraMesherDefault : public TerraMesher { + GDCLASS(TerraMesherDefault, TerraMesher); public: int get_build_flags() const; void set_build_flags(const int flags); - VoxelMesherDefault(); - ~VoxelMesherDefault(); + TerraMesherDefault(); + ~TerraMesherDefault(); protected: - virtual void _bake_colors(Ref p_chunk); - virtual void _bake_liquid_colors(Ref p_chunk); + virtual void _bake_colors(Ref p_chunk); + virtual void _bake_liquid_colors(Ref p_chunk); static void _bind_methods(); diff --git a/meshers/marching_cubes/marching_cubes_tables.cpp b/meshers/marching_cubes/marching_cubes_tables.cpp index 0255570..2adcf4b 100644 --- a/meshers/marching_cubes/marching_cubes_tables.cpp +++ b/meshers/marching_cubes/marching_cubes_tables.cpp @@ -26,7 +26,7 @@ // not claim that the entire implementation of the MarchingCubes Algorithm is your // own if you use the data in this file or any transformation of it. // -// The format of the data in this file is described in the dissertation "Voxel- +// The format of the data in this file is described in the dissertation "Terra- // Based Terrain for Real-Time Virtual Simulations", available at the web page // given above. References to sections and figures below pertain to that paper. // diff --git a/meshers/marching_cubes/marching_cubes_tables.h b/meshers/marching_cubes/marching_cubes_tables.h index 6af4635..f9ad611 100644 --- a/meshers/marching_cubes/marching_cubes_tables.h +++ b/meshers/marching_cubes/marching_cubes_tables.h @@ -23,7 +23,7 @@ // not claim that the entire implementation of the MarchingCubes Algorithm is your // own if you use the data in this file or any transformation of it. // -// The format of the data in this file is described in the dissertation "Voxel- +// The format of the data in this file is described in the dissertation "Terra- // Based Terrain for Real-Time Virtual Simulations", available at the web page // given above. References to sections and figures below pertain to that paper. // diff --git a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp index e0a7388..8bf237a 100644 --- a/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp +++ b/meshers/marching_cubes/voxel_mesher_marching_cubes.cpp @@ -47,7 +47,7 @@ SOFTWARE. typedef class RenderingServer VisualServer; #endif -void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref chunk, const int x, const int y, const int z, const int size) { +void TerraMesherMarchingCubes::get_voxel_type_array(int *arr, Ref chunk, const int x, const int y, const int z, const int size) { uint8_t *channel_type = chunk->channel_get(_channel_index_type); if (channel_type == NULL) { @@ -71,36 +71,36 @@ void VoxelMesherMarchingCubes::get_voxel_type_array(int *arr, Ref ch arr[6] = channel_type[chunk->get_index(x + size, y, z + size)]; arr[7] = channel_type[chunk->get_index(x + size, y + size, z + size)]; } -int VoxelMesherMarchingCubes::get_case_code_from_arr(const int *data) { +int TerraMesherMarchingCubes::get_case_code_from_arr(const int *data) { int case_code = 0; if (data[0] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_000; + case_code = case_code | TERRA_ENTRY_MASK_000; if (data[1] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_010; + case_code = case_code | TERRA_ENTRY_MASK_010; if (data[2] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_001; + case_code = case_code | TERRA_ENTRY_MASK_001; if (data[3] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_011; + case_code = case_code | TERRA_ENTRY_MASK_011; if (data[4] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_100; + case_code = case_code | TERRA_ENTRY_MASK_100; if (data[5] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_110; + case_code = case_code | TERRA_ENTRY_MASK_110; if (data[6] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_101; + case_code = case_code | TERRA_ENTRY_MASK_101; if (data[7] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_111; + case_code = case_code | TERRA_ENTRY_MASK_111; return case_code; } -int VoxelMesherMarchingCubes::get_case_code(Ref chunk, const int x, const int y, const int z, const int size) { +int TerraMesherMarchingCubes::get_case_code(Ref chunk, const int x, const int y, const int z, const int size) { uint8_t *channel_type = chunk->channel_get(_channel_index_type); if (channel_type == NULL) { @@ -110,33 +110,33 @@ int VoxelMesherMarchingCubes::get_case_code(Ref chunk, const int x, int case_code = 0; if (channel_type[chunk->get_index(x, y, z)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_000; + case_code = case_code | TERRA_ENTRY_MASK_000; if (channel_type[chunk->get_index(x, y + size, z)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_010; + case_code = case_code | TERRA_ENTRY_MASK_010; if (channel_type[chunk->get_index(x, y, z + size)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_001; + case_code = case_code | TERRA_ENTRY_MASK_001; if (channel_type[chunk->get_index(x, y + size, z + size)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_011; + case_code = case_code | TERRA_ENTRY_MASK_011; if (channel_type[chunk->get_index(x + size, y, z)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_100; + case_code = case_code | TERRA_ENTRY_MASK_100; if (channel_type[chunk->get_index(x + size, y + size, z)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_110; + case_code = case_code | TERRA_ENTRY_MASK_110; if (channel_type[chunk->get_index(x + size, y, z + size)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_101; + case_code = case_code | TERRA_ENTRY_MASK_101; if (channel_type[chunk->get_index(x + size, y + size, z + size)] != 0) - case_code = case_code | VOXEL_ENTRY_MASK_111; + case_code = case_code | TERRA_ENTRY_MASK_111; return case_code; } -int VoxelMesherMarchingCubes::get_voxel_type(Ref chunk, const int x, const int y, const int z, const int size) { +int TerraMesherMarchingCubes::get_voxel_type(Ref chunk, const int x, const int y, const int z, const int size) { uint8_t *channel_type = chunk->channel_get(_channel_index_type); if (channel_type == NULL) { @@ -185,12 +185,12 @@ int VoxelMesherMarchingCubes::get_voxel_type(Ref chunk, const int x, return type; } -void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { - Ref chunk = p_chunk; +void TerraMesherMarchingCubes::_add_chunk(Ref p_chunk) { + Ref chunk = p_chunk; ERR_FAIL_COND(!chunk.is_valid()); - Ref job = chunk->job_get_current(); + Ref job = chunk->job_get_current(); //if (!job->has_meta("ao_done")) { // job->set_meta("ao_done", true); @@ -315,8 +315,8 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { } } - Ref surface1 = _library->voxel_surface_get(type_id1 - 1); - Ref surface2 = _library->voxel_surface_get(type_id2 - 1); + Ref surface1 = _library->voxel_surface_get(type_id1 - 1); + Ref surface2 = _library->voxel_surface_get(type_id2 - 1); for (int i = 0; i < vertex_count; ++i) { int fv = get_regular_vertex_data_first_vertex(case_code, i); @@ -415,8 +415,8 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { uv.x += umargin.position.x; uv.y += umargin.position.y; - temp_uvs.set(cvi, surface1->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); - temp_uv2s.set(cvi, surface2->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uvs.set(cvi, surface1->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uv2s.set(cvi, surface2->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); } else if ((bz + 0.0001 > bx) && (bz + 0.0001 > by)) { Vector2 uv(s.z, t.z); Rect2 umargin = get_uv_margin(); @@ -426,8 +426,8 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { uv.x += umargin.position.x; uv.y += umargin.position.y; - temp_uvs.set(cvi, surface1->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); - temp_uv2s.set(cvi, surface2->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uvs.set(cvi, surface1->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uv2s.set(cvi, surface2->transform_uv_scaled(TerraSurface::TERRA_SIDE_SIDE, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); } else { Vector2 uv(s.y, t.y); Rect2 umargin = get_uv_margin(); @@ -437,8 +437,8 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { uv.x += umargin.position.x; uv.y += umargin.position.y; - temp_uvs.set(cvi, surface1->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_TOP, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); - temp_uv2s.set(cvi, surface2->transform_uv_scaled(VoxelSurface::VOXEL_SIDE_TOP, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uvs.set(cvi, surface1->transform_uv_scaled(TerraSurface::TERRA_SIDE_TOP, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); + temp_uv2s.set(cvi, surface2->transform_uv_scaled(TerraSurface::TERRA_SIDE_TOP, uv, x % get_texture_scale(), z % get_texture_scale(), get_texture_scale())); } } @@ -479,64 +479,64 @@ void VoxelMesherMarchingCubes::_add_chunk(Ref p_chunk) { } } -Vector3 VoxelMesherMarchingCubes::corner_id_to_vertex(int corner_id) const { +Vector3 TerraMesherMarchingCubes::corner_id_to_vertex(int corner_id) const { ERR_FAIL_COND_V(corner_id < 0 || corner_id > 8, Vector3()); return marching_cube_vertices[corner_id]; } -int VoxelMesherMarchingCubes::get_regular_cell_class(int index) const { +int TerraMesherMarchingCubes::get_regular_cell_class(int index) const { return static_cast(regularCellClass[index]); } -Ref VoxelMesherMarchingCubes::get_regular_cell_data(int index) const { +Ref TerraMesherMarchingCubes::get_regular_cell_data(int index) const { return _regular_cell_datas[index]; } -int VoxelMesherMarchingCubes::get_regular_vertex_data(int index1, int index2) const { +int TerraMesherMarchingCubes::get_regular_vertex_data(int index1, int index2) const { //return static_cast(regularVertexData[index1][index2]); return regularVertexData[index1][index2]; } -//void VoxelMesherMarchingCubes::set_regular_vertex_data(int index1, int index2, int value) { +//void TerraMesherMarchingCubes::set_regular_vertex_data(int index1, int index2, int value) { // ERR_FAIL_INDEX(index1, 256); // ERR_FAIL_INDEX(index2, 13); // regularVertexData[index1][index2] = value; //} -int VoxelMesherMarchingCubes::get_regular_vertex_data_first_vertex(int index1, int index2) const { +int TerraMesherMarchingCubes::get_regular_vertex_data_first_vertex(int index1, int index2) const { int vert1 = regularVertexData[index1][index2] & 0x000F; return vert1; } -int VoxelMesherMarchingCubes::get_regular_vertex_data_second_vertex(int index1, int index2) const { +int TerraMesherMarchingCubes::get_regular_vertex_data_second_vertex(int index1, int index2) const { int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4; return vert2; } -Vector3 VoxelMesherMarchingCubes::get_regular_vertex_first_position(int index1, int index2) const { +Vector3 TerraMesherMarchingCubes::get_regular_vertex_first_position(int index1, int index2) const { int vert = regularVertexData[index1][index2] & 0x000F; return marching_cube_vertices[vert]; } -Vector3 VoxelMesherMarchingCubes::get_regular_vertex_second_position(int index1, int index2) const { +Vector3 TerraMesherMarchingCubes::get_regular_vertex_second_position(int index1, int index2) const { int vert = (regularVertexData[index1][index2] & 0x00F0) >> 4; return marching_cube_vertices[vert]; } -Vector3 VoxelMesherMarchingCubes::get_regular_vertex_direction(int index1, int index2) const { +Vector3 TerraMesherMarchingCubes::get_regular_vertex_direction(int index1, int index2) const { int vert1 = regularVertexData[index1][index2] & 0x000F; int vert2 = (regularVertexData[index1][index2] & 0x00F0) >> 4; return marching_cube_vertices[vert2] - marching_cube_vertices[vert1]; } -VoxelMesherMarchingCubes::VoxelMesherMarchingCubes() { +TerraMesherMarchingCubes::TerraMesherMarchingCubes() { _format = VisualServer::ARRAY_FORMAT_NORMAL | VisualServer::ARRAY_FORMAT_COLOR | VisualServer::ARRAY_FORMAT_TEX_UV | VisualServer::ARRAY_FORMAT_TEX_UV2; for (int i = 0; i < 16; ++i) { @@ -544,45 +544,45 @@ VoxelMesherMarchingCubes::VoxelMesherMarchingCubes() { } } -VoxelMesherMarchingCubes::~VoxelMesherMarchingCubes() { +TerraMesherMarchingCubes::~TerraMesherMarchingCubes() { for (int i = 0; i < 16; ++i) { _regular_cell_datas[i].unref(); } } -void VoxelMesherMarchingCubes::_bind_methods() { +void TerraMesherMarchingCubes::_bind_methods() { - ClassDB::bind_method(D_METHOD("_add_chunk", "chunk"), &VoxelMesherMarchingCubes::_add_chunk); + ClassDB::bind_method(D_METHOD("_add_chunk", "chunk"), &TerraMesherMarchingCubes::_add_chunk); - ClassDB::bind_method(D_METHOD("corner_id_to_vertex", "index1"), &VoxelMesherMarchingCubes::corner_id_to_vertex); + ClassDB::bind_method(D_METHOD("corner_id_to_vertex", "index1"), &TerraMesherMarchingCubes::corner_id_to_vertex); - ClassDB::bind_method(D_METHOD("get_regular_cell_class", "index"), &VoxelMesherMarchingCubes::get_regular_cell_class); - ClassDB::bind_method(D_METHOD("get_regular_cell_data", "index"), &VoxelMesherMarchingCubes::get_regular_cell_data); - ClassDB::bind_method(D_METHOD("get_regular_vertex_data", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_data); - // ClassDB::bind_method(D_METHOD("set_regular_vertex_data", "index1", "index2", "value"), &VoxelMesherMarchingCubes::set_regular_vertex_data); - ClassDB::bind_method(D_METHOD("get_regular_vertex_data_first_vertex", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_data_first_vertex); - ClassDB::bind_method(D_METHOD("get_regular_vertex_data_second_vertex", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_data_second_vertex); - ClassDB::bind_method(D_METHOD("get_regular_vertex_first_position", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_first_position); - ClassDB::bind_method(D_METHOD("get_regular_vertex_second_position", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_second_position); - ClassDB::bind_method(D_METHOD("get_regular_vertex_direction", "index1", "index2"), &VoxelMesherMarchingCubes::get_regular_vertex_direction); + ClassDB::bind_method(D_METHOD("get_regular_cell_class", "index"), &TerraMesherMarchingCubes::get_regular_cell_class); + ClassDB::bind_method(D_METHOD("get_regular_cell_data", "index"), &TerraMesherMarchingCubes::get_regular_cell_data); + ClassDB::bind_method(D_METHOD("get_regular_vertex_data", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_data); + // ClassDB::bind_method(D_METHOD("set_regular_vertex_data", "index1", "index2", "value"), &TerraMesherMarchingCubes::set_regular_vertex_data); + ClassDB::bind_method(D_METHOD("get_regular_vertex_data_first_vertex", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_data_first_vertex); + ClassDB::bind_method(D_METHOD("get_regular_vertex_data_second_vertex", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_data_second_vertex); + ClassDB::bind_method(D_METHOD("get_regular_vertex_first_position", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_first_position); + ClassDB::bind_method(D_METHOD("get_regular_vertex_second_position", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_second_position); + ClassDB::bind_method(D_METHOD("get_regular_vertex_direction", "index1", "index2"), &TerraMesherMarchingCubes::get_regular_vertex_direction); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_000); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_100); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_010); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_110); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_001); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_101); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_011); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_INDEX_111); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_000); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_100); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_010); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_110); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_001); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_101); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_011); + BIND_ENUM_CONSTANT(TERRA_ENTRY_INDEX_111); - BIND_ENUM_CONSTANT(VOXEL_ENTRIES_SIZE); + BIND_ENUM_CONSTANT(TERRA_ENTRIES_SIZE); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_000); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_100); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_010); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_110); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_001); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_101); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_011); - BIND_ENUM_CONSTANT(VOXEL_ENTRY_MASK_111); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_000); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_100); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_010); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_110); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_001); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_101); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_011); + BIND_ENUM_CONSTANT(TERRA_ENTRY_MASK_111); } diff --git a/meshers/marching_cubes/voxel_mesher_marching_cubes.h b/meshers/marching_cubes/voxel_mesher_marching_cubes.h index 09c05ca..95b9d73 100644 --- a/meshers/marching_cubes/voxel_mesher_marching_cubes.h +++ b/meshers/marching_cubes/voxel_mesher_marching_cubes.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_MESHER_MARCHING_CUBES_H -#define VOXEL_MESHER_MARCHING_CUBES_H +#ifndef TERRA_MESHER_MARCHING_CUBES_H +#define TERRA_MESHER_MARCHING_CUBES_H #include "core/version.h" @@ -39,45 +39,45 @@ SOFTWARE. using namespace MarchingCubes; -class VoxelMesherMarchingCubes : public VoxelMesherDefault { - GDCLASS(VoxelMesherMarchingCubes, VoxelMesherDefault) +class TerraMesherMarchingCubes : public TerraMesherDefault { + GDCLASS(TerraMesherMarchingCubes, TerraMesherDefault) public: - static const String BINDING_STRING_VOXEL_ENTRY_INDICES; - static const String BINDING_STRING_VOXEL_ENTRY_MASK; + static const String BINDING_STRING_TERRA_ENTRY_INDICES; + static const String BINDING_STRING_TERRA_ENTRY_MASK; - enum VoxelEntryIndices { - VOXEL_ENTRY_INDEX_000 = 0, - VOXEL_ENTRY_INDEX_100 = 1, - VOXEL_ENTRY_INDEX_001 = 2, - VOXEL_ENTRY_INDEX_101 = 3, + enum TerraEntryIndices { + TERRA_ENTRY_INDEX_000 = 0, + TERRA_ENTRY_INDEX_100 = 1, + TERRA_ENTRY_INDEX_001 = 2, + TERRA_ENTRY_INDEX_101 = 3, - VOXEL_ENTRY_INDEX_010 = 4, - VOXEL_ENTRY_INDEX_110 = 5, - VOXEL_ENTRY_INDEX_011 = 6, - VOXEL_ENTRY_INDEX_111 = 7, + TERRA_ENTRY_INDEX_010 = 4, + TERRA_ENTRY_INDEX_110 = 5, + TERRA_ENTRY_INDEX_011 = 6, + TERRA_ENTRY_INDEX_111 = 7, - VOXEL_ENTRIES_SIZE = 8, + TERRA_ENTRIES_SIZE = 8, }; - enum VoxelEntryMask { - VOXEL_ENTRY_MASK_000 = 1 << 0, - VOXEL_ENTRY_MASK_100 = 1 << 1, - VOXEL_ENTRY_MASK_001 = 1 << 2, - VOXEL_ENTRY_MASK_101 = 1 << 3, + enum TerraEntryMask { + TERRA_ENTRY_MASK_000 = 1 << 0, + TERRA_ENTRY_MASK_100 = 1 << 1, + TERRA_ENTRY_MASK_001 = 1 << 2, + TERRA_ENTRY_MASK_101 = 1 << 3, - VOXEL_ENTRY_MASK_010 = 1 << 4, - VOXEL_ENTRY_MASK_110 = 1 << 5, - VOXEL_ENTRY_MASK_011 = 1 << 6, - VOXEL_ENTRY_MASK_111 = 1 << 7, + TERRA_ENTRY_MASK_010 = 1 << 4, + TERRA_ENTRY_MASK_110 = 1 << 5, + TERRA_ENTRY_MASK_011 = 1 << 6, + TERRA_ENTRY_MASK_111 = 1 << 7, }; //arr should have a size of 8 - void get_voxel_type_array(int *arr, Ref chunk, const int x, const int y, const int z, const int size = 1); + void get_voxel_type_array(int *arr, Ref chunk, const int x, const int y, const int z, const int size = 1); int get_case_code_from_arr(const int *data); - int get_case_code(Ref chunk, const int x, const int y, const int z, const int size = 1); - int get_voxel_type(Ref chunk, const int x, const int y, const int z, const int size = 1); - void _add_chunk(Ref p_chunk); + int get_case_code(Ref chunk, const int x, const int y, const int z, const int size = 1); + int get_voxel_type(Ref chunk, const int x, const int y, const int z, const int size = 1); + void _add_chunk(Ref p_chunk); Vector3 corner_id_to_vertex(int corner_id) const; @@ -92,8 +92,8 @@ public: Vector3 get_regular_vertex_second_position(int index1, int index2) const; Vector3 get_regular_vertex_direction(int index1, int index2) const; - VoxelMesherMarchingCubes(); - ~VoxelMesherMarchingCubes(); + TerraMesherMarchingCubes(); + ~TerraMesherMarchingCubes(); protected: static void _bind_methods(); @@ -101,7 +101,7 @@ protected: Ref _regular_cell_datas[16]; }; -VARIANT_ENUM_CAST(VoxelMesherMarchingCubes::VoxelEntryIndices); -VARIANT_ENUM_CAST(VoxelMesherMarchingCubes::VoxelEntryMask); +VARIANT_ENUM_CAST(TerraMesherMarchingCubes::TerraEntryIndices); +VARIANT_ENUM_CAST(TerraMesherMarchingCubes::TerraEntryMask); -#endif // VOXEL_MESHER_SMOOTH_H +#endif // TERRA_MESHER_SMOOTH_H diff --git a/meshers/voxel_mesher.cpp b/meshers/voxel_mesher.cpp index 05241b3..22aa3b1 100644 --- a/meshers/voxel_mesher.cpp +++ b/meshers/voxel_mesher.cpp @@ -29,7 +29,7 @@ SOFTWARE. #include "../world/default/voxel_chunk_default.h" #include "../world/voxel_chunk.h" -bool VoxelMesher::Vertex::operator==(const Vertex &p_vertex) const { +bool TerraMesher::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -65,7 +65,7 @@ bool VoxelMesher::Vertex::operator==(const Vertex &p_vertex) const { return true; } -uint32_t VoxelMesher::VertexHasher::hash(const Vertex &p_vtx) { +uint32_t TerraMesher::VertexHasher::hash(const Vertex &p_vtx) { uint32_t h = hash_djb2_buffer((const uint8_t *)&p_vtx.vertex, sizeof(real_t) * 3); h = hash_djb2_buffer((const uint8_t *)&p_vtx.normal, sizeof(real_t) * 3, h); @@ -79,84 +79,84 @@ uint32_t VoxelMesher::VertexHasher::hash(const Vertex &p_vtx) { return h; } -int VoxelMesher::get_channel_index_type() const { +int TerraMesher::get_channel_index_type() const { return _channel_index_type; } -void VoxelMesher::set_channel_index_type(const int value) { +void TerraMesher::set_channel_index_type(const int value) { _channel_index_type = value; } -int VoxelMesher::get_channel_index_isolevel() const { +int TerraMesher::get_channel_index_isolevel() const { return _channel_index_isolevel; } -void VoxelMesher::set_channel_index_isolevel(const int value) { +void TerraMesher::set_channel_index_isolevel(const int value) { _channel_index_isolevel = value; } -int VoxelMesher::get_mesher_index() const { +int TerraMesher::get_mesher_index() const { return _mesher_index; } -void VoxelMesher::set_mesher_index(const int value) { +void TerraMesher::set_mesher_index(const int value) { _mesher_index = value; } -int VoxelMesher::get_format() const { +int TerraMesher::get_format() const { return _format; } -void VoxelMesher::set_format(const int value) { +void TerraMesher::set_format(const int value) { _format = value; } -int VoxelMesher::get_texture_scale() const { +int TerraMesher::get_texture_scale() const { return _texture_scale; } -void VoxelMesher::set_texture_scale(const int value) { +void TerraMesher::set_texture_scale(const int value) { _texture_scale = value; } -Ref VoxelMesher::get_library() { +Ref TerraMesher::get_library() { return _library; } -void VoxelMesher::set_library(const Ref &library) { +void TerraMesher::set_library(const Ref &library) { _library = library; } -Ref VoxelMesher::get_material() { +Ref TerraMesher::get_material() { return _material; } -void VoxelMesher::set_material(const Ref &material) { +void TerraMesher::set_material(const Ref &material) { _material = material; } -float VoxelMesher::get_ao_strength() const { +float TerraMesher::get_ao_strength() const { return _ao_strength; } -void VoxelMesher::set_ao_strength(float value) { +void TerraMesher::set_ao_strength(float value) { _ao_strength = value; } -float VoxelMesher::get_base_light_value() const { +float TerraMesher::get_base_light_value() const { return _base_light_value; } -void VoxelMesher::set_base_light_value(float value) { +void TerraMesher::set_base_light_value(float value) { _base_light_value = value; } -float VoxelMesher::get_voxel_scale() const { +float TerraMesher::get_voxel_scale() const { return _voxel_scale; } -void VoxelMesher::set_voxel_scale(const float voxel_scale) { +void TerraMesher::set_voxel_scale(const float voxel_scale) { _voxel_scale = voxel_scale; } -Rect2 VoxelMesher::get_uv_margin() const { +Rect2 TerraMesher::get_uv_margin() const { return _uv_margin; } -void VoxelMesher::set_uv_margin(const Rect2 margin) { +void TerraMesher::set_uv_margin(const Rect2 margin) { _uv_margin = margin; } -Array VoxelMesher::build_mesh() { +Array TerraMesher::build_mesh() { Array a; a.resize(VisualServer::ARRAY_MAX); @@ -276,7 +276,7 @@ Array VoxelMesher::build_mesh() { return a; } -void VoxelMesher::build_mesh_into(RID mesh) { +void TerraMesher::build_mesh_into(RID mesh) { ERR_FAIL_COND(mesh == RID()); VS::get_singleton()->mesh_clear(mesh); @@ -294,7 +294,7 @@ void VoxelMesher::build_mesh_into(RID mesh) { VS::get_singleton()->mesh_surface_set_material(mesh, 0, _library->material_get(0)->get_rid()); } -void VoxelMesher::generate_normals(bool p_flip) { +void TerraMesher::generate_normals(bool p_flip) { _format = _format | VisualServer::ARRAY_FORMAT_NORMAL; @@ -327,7 +327,7 @@ void VoxelMesher::generate_normals(bool p_flip) { } } -void VoxelMesher::remove_doubles() { +void TerraMesher::remove_doubles() { if (_vertices.size() == 0) return; @@ -373,7 +373,7 @@ void VoxelMesher::remove_doubles() { } //lot faster that normal remove_doubles, but false positives can happen curtesy of hash collisions -void VoxelMesher::remove_doubles_hashed() { +void TerraMesher::remove_doubles_hashed() { if (_vertices.size() == 0) return; @@ -425,7 +425,7 @@ void VoxelMesher::remove_doubles_hashed() { //print_error("after " + String::num(_vertices.size()) + " " + String::num(duration.count())); } -void VoxelMesher::reset() { +void TerraMesher::reset() { _vertices.resize(0); _indices.resize(0); @@ -438,7 +438,7 @@ void VoxelMesher::reset() { _last_tangent = Plane(); } -void VoxelMesher::add_chunk(Ref chunk) { +void TerraMesher::add_chunk(Ref chunk) { ERR_FAIL_COND(!has_method("_add_chunk")); ERR_FAIL_COND(!chunk.is_valid()); @@ -446,13 +446,13 @@ void VoxelMesher::add_chunk(Ref chunk) { } #ifdef MESH_DATA_RESOURCE_PRESENT -void VoxelMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { +void TerraMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { Transform transform = Transform(Basis(rotation).scaled(scale), position); add_mesh_data_resource_transform(mesh, transform, uv_rect); } -void VoxelMesher::add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect) { +void TerraMesher::add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect) { if (mesh->get_array().size() == 0) return; @@ -496,7 +496,7 @@ void VoxelMesher::add_mesh_data_resource_transform(Ref mesh, c } } -void VoxelMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { +void TerraMesher::add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect) { if (mesh->get_array().size() == 0) return; @@ -540,10 +540,10 @@ void VoxelMesher::add_mesh_data_resource_transform_colored(Ref } #endif -void VoxelMesher::add_mesher(const Ref &mesher) { +void TerraMesher::add_mesher(const Ref &mesher) { call("_add_mesher", mesher); } -void VoxelMesher::_add_mesher(const Ref &mesher) { +void TerraMesher::_add_mesher(const Ref &mesher) { int orig_size = _vertices.size(); _vertices.append_array(mesher->_vertices); @@ -561,21 +561,21 @@ void VoxelMesher::_add_mesher(const Ref &mesher) { } } -void VoxelMesher::bake_colors(Ref chunk) { +void TerraMesher::bake_colors(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (has_method("_bake_colors")) call("_bake_colors", chunk); } -void VoxelMesher::bake_liquid_colors(Ref chunk) { +void TerraMesher::bake_liquid_colors(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (has_method("_bake_liquid_colors")) call("_bake_liquid_colors", chunk); } -PoolVector VoxelMesher::build_collider() const { +PoolVector TerraMesher::build_collider() const { PoolVector face_points; if (_vertices.size() == 0) @@ -607,7 +607,7 @@ PoolVector VoxelMesher::build_collider() const { return face_points; } -void VoxelMesher::bake_lights(MeshInstance *node, Vector > &lights) { +void TerraMesher::bake_lights(MeshInstance *node, Vector > &lights) { ERR_FAIL_COND(node == NULL); Color darkColor(0, 0, 0, 1); @@ -624,7 +624,7 @@ void VoxelMesher::bake_lights(MeshInstance *node, Vector > &ligh //calculate the lights value for (int i = 0; i < lights.size(); ++i) { - Ref light = lights.get(i); + Ref light = lights.get(i); Vector3 lightDir = light->get_world_position() - vertex; @@ -694,7 +694,7 @@ void VoxelMesher::bake_lights(MeshInstance *node, Vector > &ligh // } } -PoolVector VoxelMesher::get_vertices() const { +PoolVector TerraMesher::get_vertices() const { PoolVector arr; arr.resize(_vertices.size()); @@ -705,7 +705,7 @@ PoolVector VoxelMesher::get_vertices() const { return arr; } -void VoxelMesher::set_vertices(const PoolVector &values) { +void TerraMesher::set_vertices(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -717,11 +717,11 @@ void VoxelMesher::set_vertices(const PoolVector &values) { } } -int VoxelMesher::get_vertex_count() const { +int TerraMesher::get_vertex_count() const { return _vertices.size(); } -void VoxelMesher::add_vertex(const Vector3 &vertex) { +void TerraMesher::add_vertex(const Vector3 &vertex) { Vertex vtx; vtx.vertex = vertex; vtx.color = _last_color; @@ -737,15 +737,15 @@ void VoxelMesher::add_vertex(const Vector3 &vertex) { _vertices.push_back(vtx); } -Vector3 VoxelMesher::get_vertex(const int idx) const { +Vector3 TerraMesher::get_vertex(const int idx) const { return _vertices.get(idx).vertex; } -void VoxelMesher::remove_vertex(const int idx) { +void TerraMesher::remove_vertex(const int idx) { _vertices.remove(idx); } -PoolVector VoxelMesher::get_normals() const { +PoolVector TerraMesher::get_normals() const { PoolVector arr; arr.resize(_vertices.size()); @@ -756,7 +756,7 @@ PoolVector VoxelMesher::get_normals() const { return arr; } -void VoxelMesher::set_normals(const PoolVector &values) { +void TerraMesher::set_normals(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -768,15 +768,15 @@ void VoxelMesher::set_normals(const PoolVector &values) { } } -void VoxelMesher::add_normal(const Vector3 &normal) { +void TerraMesher::add_normal(const Vector3 &normal) { _last_normal = normal; } -Vector3 VoxelMesher::get_normal(int idx) const { +Vector3 TerraMesher::get_normal(int idx) const { return _vertices.get(idx).normal; } -PoolVector VoxelMesher::get_colors() const { +PoolVector TerraMesher::get_colors() const { PoolVector arr; arr.resize(_vertices.size()); @@ -787,7 +787,7 @@ PoolVector VoxelMesher::get_colors() const { return arr; } -void VoxelMesher::set_colors(const PoolVector &values) { +void TerraMesher::set_colors(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -799,15 +799,15 @@ void VoxelMesher::set_colors(const PoolVector &values) { } } -void VoxelMesher::add_color(const Color &color) { +void TerraMesher::add_color(const Color &color) { _last_color = color; } -Color VoxelMesher::get_color(const int idx) const { +Color TerraMesher::get_color(const int idx) const { return _vertices.get(idx).color; } -PoolVector VoxelMesher::get_uvs() const { +PoolVector TerraMesher::get_uvs() const { PoolVector arr; arr.resize(_vertices.size()); @@ -818,7 +818,7 @@ PoolVector VoxelMesher::get_uvs() const { return arr; } -void VoxelMesher::set_uvs(const PoolVector &values) { +void TerraMesher::set_uvs(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -830,15 +830,15 @@ void VoxelMesher::set_uvs(const PoolVector &values) { } } -void VoxelMesher::add_uv(const Vector2 &uv) { +void TerraMesher::add_uv(const Vector2 &uv) { _last_uv = uv; } -Vector2 VoxelMesher::get_uv(const int idx) const { +Vector2 TerraMesher::get_uv(const int idx) const { return _vertices.get(idx).uv; } -PoolVector VoxelMesher::get_uv2s() const { +PoolVector TerraMesher::get_uv2s() const { PoolVector arr; arr.resize(_vertices.size()); @@ -849,7 +849,7 @@ PoolVector VoxelMesher::get_uv2s() const { return arr; } -void VoxelMesher::set_uv2s(const PoolVector &values) { +void TerraMesher::set_uv2s(const PoolVector &values) { ERR_FAIL_COND(values.size() != _vertices.size()); for (int i = 0; i < _vertices.size(); ++i) { @@ -861,39 +861,39 @@ void VoxelMesher::set_uv2s(const PoolVector &values) { } } -void VoxelMesher::add_uv2(const Vector2 &uv) { +void TerraMesher::add_uv2(const Vector2 &uv) { _last_uv2 = uv; } -Vector2 VoxelMesher::get_uv2(const int idx) const { +Vector2 TerraMesher::get_uv2(const int idx) const { return _vertices.get(idx).uv2; } -PoolVector VoxelMesher::get_indices() const { +PoolVector TerraMesher::get_indices() const { return _indices; } -void VoxelMesher::set_indices(const PoolVector &values) { +void TerraMesher::set_indices(const PoolVector &values) { _indices = values; } -int VoxelMesher::get_indices_count() const { +int TerraMesher::get_indices_count() const { return _indices.size(); } -void VoxelMesher::add_indices(const int index) { +void TerraMesher::add_indices(const int index) { _indices.push_back(index); } -int VoxelMesher::get_index(const int idx) const { +int TerraMesher::get_index(const int idx) const { return _indices.get(idx); } -void VoxelMesher::remove_index(const int idx) { +void TerraMesher::remove_index(const int idx) { _indices.remove(idx); } -VoxelMesher::VoxelMesher(const Ref &library) { +TerraMesher::TerraMesher(const Ref &library) { _library = library; _mesher_index = 0; @@ -908,7 +908,7 @@ VoxelMesher::VoxelMesher(const Ref &library) { _texture_scale = 1; } -VoxelMesher::VoxelMesher() { +TerraMesher::TerraMesher() { _mesher_index = 0; _voxel_scale = 1; _ao_strength = 0.25; @@ -920,120 +920,120 @@ VoxelMesher::VoxelMesher() { _texture_scale = 1; } -VoxelMesher::~VoxelMesher() { +TerraMesher::~TerraMesher() { if (_library.is_valid()) { _library.unref(); } } -void VoxelMesher::_bind_methods() { - BIND_VMETHOD(MethodInfo("_add_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - BIND_VMETHOD(MethodInfo("_bake_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - BIND_VMETHOD(MethodInfo("_bake_liquid_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); +void TerraMesher::_bind_methods() { + BIND_VMETHOD(MethodInfo("_add_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); + BIND_VMETHOD(MethodInfo("_bake_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); + BIND_VMETHOD(MethodInfo("_bake_liquid_colors", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("get_channel_index_type"), &VoxelMesher::get_channel_index_type); - ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &VoxelMesher::set_channel_index_type); + ClassDB::bind_method(D_METHOD("get_channel_index_type"), &TerraMesher::get_channel_index_type); + ClassDB::bind_method(D_METHOD("set_channel_index_type", "value"), &TerraMesher::set_channel_index_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_type"), "set_channel_index_type", "get_channel_index_type"); - ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &VoxelMesher::get_channel_index_isolevel); - ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &VoxelMesher::set_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("get_channel_index_isolevel"), &TerraMesher::get_channel_index_isolevel); + ClassDB::bind_method(D_METHOD("set_channel_index_isolevel", "value"), &TerraMesher::set_channel_index_isolevel); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_index_isolevel"), "set_channel_index_isolevel", "get_channel_index_isolevel"); - ClassDB::bind_method(D_METHOD("get_mesher_index"), &VoxelMesher::get_mesher_index); - ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &VoxelMesher::set_mesher_index); + ClassDB::bind_method(D_METHOD("get_mesher_index"), &TerraMesher::get_mesher_index); + ClassDB::bind_method(D_METHOD("set_mesher_index", "value"), &TerraMesher::set_mesher_index); ADD_PROPERTY(PropertyInfo(Variant::INT, "mesher_index"), "set_mesher_index", "get_mesher_index"); - ClassDB::bind_method(D_METHOD("get_format"), &VoxelMesher::get_format); - ClassDB::bind_method(D_METHOD("set_format", "value"), &VoxelMesher::set_format); + ClassDB::bind_method(D_METHOD("get_format"), &TerraMesher::get_format); + ClassDB::bind_method(D_METHOD("set_format", "value"), &TerraMesher::set_format); ADD_PROPERTY(PropertyInfo(Variant::INT, "format"), "set_format", "get_format"); - ClassDB::bind_method(D_METHOD("get_texture_scale"), &VoxelMesher::get_texture_scale); - ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &VoxelMesher::set_texture_scale); + ClassDB::bind_method(D_METHOD("get_texture_scale"), &TerraMesher::get_texture_scale); + ClassDB::bind_method(D_METHOD("set_texture_scale", "value"), &TerraMesher::set_texture_scale); ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ClassDB::bind_method(D_METHOD("get_library"), &VoxelMesher::get_library); - ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelMesher::set_library); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"), "set_library", "get_library"); + ClassDB::bind_method(D_METHOD("get_library"), &TerraMesher::get_library); + ClassDB::bind_method(D_METHOD("set_library", "value"), &TerraMesher::set_library); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"), "set_library", "get_library"); - ClassDB::bind_method(D_METHOD("get_material"), &VoxelMesher::get_material); - ClassDB::bind_method(D_METHOD("set_material", "value"), &VoxelMesher::set_material); + ClassDB::bind_method(D_METHOD("get_material"), &TerraMesher::get_material); + ClassDB::bind_method(D_METHOD("set_material", "value"), &TerraMesher::set_material); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material"); - ClassDB::bind_method(D_METHOD("get_voxel_scale"), &VoxelMesher::get_voxel_scale); - ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &VoxelMesher::set_voxel_scale); + ClassDB::bind_method(D_METHOD("get_voxel_scale"), &TerraMesher::get_voxel_scale); + ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &TerraMesher::set_voxel_scale); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); - ClassDB::bind_method(D_METHOD("get_ao_strength"), &VoxelMesher::get_ao_strength); - ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &VoxelMesher::set_ao_strength); + ClassDB::bind_method(D_METHOD("get_ao_strength"), &TerraMesher::get_ao_strength); + ClassDB::bind_method(D_METHOD("set_ao_strength", "value"), &TerraMesher::set_ao_strength); ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_strength"), "set_ao_strength", "get_ao_strength"); - ClassDB::bind_method(D_METHOD("get_base_light_value"), &VoxelMesher::get_base_light_value); - ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &VoxelMesher::set_base_light_value); + ClassDB::bind_method(D_METHOD("get_base_light_value"), &TerraMesher::get_base_light_value); + ClassDB::bind_method(D_METHOD("set_base_light_value", "value"), &TerraMesher::set_base_light_value); ADD_PROPERTY(PropertyInfo(Variant::REAL, "base_light_value"), "set_base_light_value", "get_base_light_value"); - ClassDB::bind_method(D_METHOD("get_uv_margin"), &VoxelMesher::get_uv_margin); - ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &VoxelMesher::set_uv_margin); + ClassDB::bind_method(D_METHOD("get_uv_margin"), &TerraMesher::get_uv_margin); + ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &TerraMesher::set_uv_margin); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin"); - ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &VoxelMesher::add_chunk); + ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &TerraMesher::add_chunk); #ifdef MESH_DATA_RESOURCE_PRESENT - ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &VoxelMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); - ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); - ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &TerraMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &TerraMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); + ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &TerraMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); #endif - BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"))); - ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &VoxelMesher::add_mesher); - ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &VoxelMesher::_add_mesher); + BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "TerraMesher"))); + ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &TerraMesher::add_mesher); + ClassDB::bind_method(D_METHOD("_add_mesher", "mesher"), &TerraMesher::_add_mesher); - ClassDB::bind_method(D_METHOD("bake_colors", "chunk"), &VoxelMesher::bake_colors); - ClassDB::bind_method(D_METHOD("bake_liquid_colors", "chunk"), &VoxelMesher::bake_liquid_colors); + ClassDB::bind_method(D_METHOD("bake_colors", "chunk"), &TerraMesher::bake_colors); + ClassDB::bind_method(D_METHOD("bake_liquid_colors", "chunk"), &TerraMesher::bake_liquid_colors); - ClassDB::bind_method(D_METHOD("get_vertices"), &VoxelMesher::get_vertices); - ClassDB::bind_method(D_METHOD("set_vertices", "values"), &VoxelMesher::set_vertices); - ClassDB::bind_method(D_METHOD("get_vertex_count"), &VoxelMesher::get_vertex_count); - ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &VoxelMesher::get_vertex); - ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &VoxelMesher::remove_vertex); - ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &VoxelMesher::add_vertex); + ClassDB::bind_method(D_METHOD("get_vertices"), &TerraMesher::get_vertices); + ClassDB::bind_method(D_METHOD("set_vertices", "values"), &TerraMesher::set_vertices); + ClassDB::bind_method(D_METHOD("get_vertex_count"), &TerraMesher::get_vertex_count); + ClassDB::bind_method(D_METHOD("get_vertex", "idx"), &TerraMesher::get_vertex); + ClassDB::bind_method(D_METHOD("remove_vertex", "idx"), &TerraMesher::remove_vertex); + ClassDB::bind_method(D_METHOD("add_vertex", "vertex"), &TerraMesher::add_vertex); - ClassDB::bind_method(D_METHOD("get_normals"), &VoxelMesher::get_normals); - ClassDB::bind_method(D_METHOD("set_normals", "values"), &VoxelMesher::set_normals); - ClassDB::bind_method(D_METHOD("get_normal", "idx"), &VoxelMesher::get_normal); - ClassDB::bind_method(D_METHOD("add_normal", "normal"), &VoxelMesher::add_normal); + ClassDB::bind_method(D_METHOD("get_normals"), &TerraMesher::get_normals); + ClassDB::bind_method(D_METHOD("set_normals", "values"), &TerraMesher::set_normals); + ClassDB::bind_method(D_METHOD("get_normal", "idx"), &TerraMesher::get_normal); + ClassDB::bind_method(D_METHOD("add_normal", "normal"), &TerraMesher::add_normal); - ClassDB::bind_method(D_METHOD("get_colors"), &VoxelMesher::get_colors); - ClassDB::bind_method(D_METHOD("set_colors", "values"), &VoxelMesher::set_colors); - ClassDB::bind_method(D_METHOD("get_color", "idx"), &VoxelMesher::get_color); - ClassDB::bind_method(D_METHOD("add_color", "color"), &VoxelMesher::add_color); + ClassDB::bind_method(D_METHOD("get_colors"), &TerraMesher::get_colors); + ClassDB::bind_method(D_METHOD("set_colors", "values"), &TerraMesher::set_colors); + ClassDB::bind_method(D_METHOD("get_color", "idx"), &TerraMesher::get_color); + ClassDB::bind_method(D_METHOD("add_color", "color"), &TerraMesher::add_color); - ClassDB::bind_method(D_METHOD("get_uvs"), &VoxelMesher::get_uvs); - ClassDB::bind_method(D_METHOD("set_uvs", "values"), &VoxelMesher::set_uvs); - ClassDB::bind_method(D_METHOD("get_uv", "idx"), &VoxelMesher::get_uv); - ClassDB::bind_method(D_METHOD("add_uv", "uv"), &VoxelMesher::add_uv); + ClassDB::bind_method(D_METHOD("get_uvs"), &TerraMesher::get_uvs); + ClassDB::bind_method(D_METHOD("set_uvs", "values"), &TerraMesher::set_uvs); + ClassDB::bind_method(D_METHOD("get_uv", "idx"), &TerraMesher::get_uv); + ClassDB::bind_method(D_METHOD("add_uv", "uv"), &TerraMesher::add_uv); - ClassDB::bind_method(D_METHOD("get_uv2s"), &VoxelMesher::get_uv2s); - ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &VoxelMesher::set_uv2s); - ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &VoxelMesher::get_uv2); - ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &VoxelMesher::add_uv2); + ClassDB::bind_method(D_METHOD("get_uv2s"), &TerraMesher::get_uv2s); + ClassDB::bind_method(D_METHOD("set_uv2s", "values"), &TerraMesher::set_uv2s); + ClassDB::bind_method(D_METHOD("get_uv2", "idx"), &TerraMesher::get_uv2); + ClassDB::bind_method(D_METHOD("add_uv2", "uv"), &TerraMesher::add_uv2); - ClassDB::bind_method(D_METHOD("get_indices"), &VoxelMesher::get_indices); - ClassDB::bind_method(D_METHOD("set_indices", "values"), &VoxelMesher::set_indices); - ClassDB::bind_method(D_METHOD("get_indices_count"), &VoxelMesher::get_indices_count); - ClassDB::bind_method(D_METHOD("get_index", "idx"), &VoxelMesher::get_index); - ClassDB::bind_method(D_METHOD("remove_index", "idx"), &VoxelMesher::remove_index); - ClassDB::bind_method(D_METHOD("add_indices", "indice"), &VoxelMesher::add_indices); + ClassDB::bind_method(D_METHOD("get_indices"), &TerraMesher::get_indices); + ClassDB::bind_method(D_METHOD("set_indices", "values"), &TerraMesher::set_indices); + ClassDB::bind_method(D_METHOD("get_indices_count"), &TerraMesher::get_indices_count); + ClassDB::bind_method(D_METHOD("get_index", "idx"), &TerraMesher::get_index); + ClassDB::bind_method(D_METHOD("remove_index", "idx"), &TerraMesher::remove_index); + ClassDB::bind_method(D_METHOD("add_indices", "indice"), &TerraMesher::add_indices); - ClassDB::bind_method(D_METHOD("reset"), &VoxelMesher::reset); + ClassDB::bind_method(D_METHOD("reset"), &TerraMesher::reset); - //ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &VoxelMesher::calculate_vertex_ambient_occlusion_path); + //ClassDB::bind_method(D_METHOD("calculate_vertex_ambient_occlusion", "meshinstance_path", "radius", "intensity", "sampleCount"), &TerraMesher::calculate_vertex_ambient_occlusion_path); - ClassDB::bind_method(D_METHOD("build_mesh"), &VoxelMesher::build_mesh); - ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &VoxelMesher::build_mesh_into); - ClassDB::bind_method(D_METHOD("build_collider"), &VoxelMesher::build_collider); + ClassDB::bind_method(D_METHOD("build_mesh"), &TerraMesher::build_mesh); + ClassDB::bind_method(D_METHOD("build_mesh_into", "mesh_rid"), &TerraMesher::build_mesh_into); + ClassDB::bind_method(D_METHOD("build_collider"), &TerraMesher::build_collider); - ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &VoxelMesher::generate_normals, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("generate_normals", "flip"), &TerraMesher::generate_normals, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("remove_doubles"), &VoxelMesher::remove_doubles); - ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &VoxelMesher::remove_doubles_hashed); + ClassDB::bind_method(D_METHOD("remove_doubles"), &TerraMesher::remove_doubles); + ClassDB::bind_method(D_METHOD("remove_doubles_hashed"), &TerraMesher::remove_doubles_hashed); } diff --git a/meshers/voxel_mesher.h b/meshers/voxel_mesher.h index 8df00e6..2f68646 100644 --- a/meshers/voxel_mesher.h +++ b/meshers/voxel_mesher.h @@ -20,19 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_TOOLS_H -#define VOXEL_TOOLS_H +#ifndef TERRA_TOOLS_H +#define TERRA_TOOLS_H #include "core/version.h" #if VERSION_MAJOR > 3 +#include "core/math/color.h" #include "core/object/reference.h" #include "core/templates/vector.h" -#include "core/math/color.h" #else +#include "core/color.h" #include "core/reference.h" #include "core/vector.h" -#include "core/color.h" #endif #include "../defines.h" @@ -55,16 +55,16 @@ include_pool_vector #include "../library/voxelman_library.h" - const double PI_2 = 3.141592653589793238463 / 2; -const double PI = 3.141592653589793238463; + class TerramanLibrary; +class TerraChunk; -class VoxelmanLibrary; -class VoxelChunk; - -class VoxelMesher : public Reference { - GDCLASS(VoxelMesher, Reference); +class TerraMesher : public Reference { + GDCLASS(TerraMesher, Reference); public: + const double PI_2 = 3.141592653589793238463 / 2; + const double PI = 3.141592653589793238463; + struct Vertex { Vector3 vertex; @@ -110,8 +110,8 @@ public: int get_texture_scale() const; void set_texture_scale(const int value); - Ref get_library(); - void set_library(const Ref &library); + Ref get_library(); + void set_library(const Ref &library); Ref get_material(); void set_material(const Ref &material); @@ -130,7 +130,7 @@ public: void reset(); - void add_chunk(Ref chunk); + void add_chunk(Ref chunk); #ifdef MESH_DATA_RESOURCE_PRESENT void add_mesh_data_resource(Ref mesh, const Vector3 position = Vector3(0, 0, 0), const Vector3 rotation = Vector3(0, 0, 0), const Vector3 scale = Vector3(1.0, 1.0, 1.0), const Rect2 uv_rect = Rect2(0, 0, 1, 1)); @@ -138,15 +138,15 @@ public: void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); #endif - void add_mesher(const Ref &mesher); - void _add_mesher(const Ref &mesher); + void add_mesher(const Ref &mesher); + void _add_mesher(const Ref &mesher); - void bake_colors(Ref chunk); - void bake_liquid_colors(Ref chunk); + void bake_colors(Ref chunk); + void bake_liquid_colors(Ref chunk); PoolVector build_collider() const; - void bake_lights(MeshInstance *node, Vector > &lights); + void bake_lights(MeshInstance *node, Vector > &lights); Array build_mesh(); void build_mesh_into(RID mesh); @@ -189,9 +189,9 @@ public: void remove_index(const int idx); void add_indices(const int index); - VoxelMesher(const Ref &library); - VoxelMesher(); - ~VoxelMesher(); + TerraMesher(const Ref &library); + TerraMesher(); + ~TerraMesher(); protected: static void _bind_methods(); @@ -216,7 +216,7 @@ protected: Vector _last_weights; Plane _last_tangent; - Ref _library; + Ref _library; Ref _material; float _voxel_scale; diff --git a/nodes/voxelman_light.cpp b/nodes/voxelman_light.cpp index a0748ee..bedca06 100644 --- a/nodes/voxelman_light.cpp +++ b/nodes/voxelman_light.cpp @@ -1,9 +1,9 @@ #include "voxelman_light.h" -VoxelmanLight::VoxelmanLight() { +TerramanLight::TerramanLight() { } -VoxelmanLight::~VoxelmanLight() { +TerramanLight::~TerramanLight() { } -void VoxelmanLight::_bind_methods() { +void TerramanLight::_bind_methods() { } diff --git a/nodes/voxelman_light.h b/nodes/voxelman_light.h index a960761..684ab26 100644 --- a/nodes/voxelman_light.h +++ b/nodes/voxelman_light.h @@ -35,15 +35,15 @@ SOFTWARE. #include "core/math/vector3.h" -class VoxelmanLight : public Spatial { - GDCLASS(VoxelmanLight, Spatial); +class TerramanLight : public Spatial { + GDCLASS(TerramanLight, Spatial); OBJ_CATEGORY("Props"); public: //make it turn into a normal light if voxelman isn't present? - VoxelmanLight(); - ~VoxelmanLight(); + TerramanLight(); + ~TerramanLight(); protected: static void _bind_methods(); diff --git a/register_types.cpp b/register_types.cpp index e28642f..1990208 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -22,7 +22,7 @@ SOFTWARE. #include "register_types.h" -/* + #include "library/voxel_surface.h" #include "library/voxel_surface_simple.h" @@ -77,67 +77,65 @@ SOFTWARE. #include "world/jobs/voxel_light_job.h" #include "world/jobs/voxel_prop_job.h" #include "world/jobs/voxel_terrarin_job.h" -*/ + void register_terraman_types() { - /* - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); #ifdef TEXTURE_PACKER_PRESENT - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); #endif - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); - ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); + ClassDB::register_class(); #ifdef TOOLS_ENABLED - EditorPlugins::add_by_type(); + EditorPlugins::add_by_type(); #endif -*/ } void unregister_terraman_types() { diff --git a/world/block_voxel_structure.cpp b/world/block_voxel_structure.cpp index 216ea73..9c0ba90 100644 --- a/world/block_voxel_structure.cpp +++ b/world/block_voxel_structure.cpp @@ -22,21 +22,21 @@ SOFTWARE. #include "block_voxel_structure.h" -int BlockVoxelStructure::get_channel_type() const { +int BlockTerraStructure::get_channel_type() const { return _channel_type; } -void BlockVoxelStructure::set_channel_type(const int value) { +void BlockTerraStructure::set_channel_type(const int value) { _channel_type = value; } -int BlockVoxelStructure::get_channel_isolevel() const { +int BlockTerraStructure::get_channel_isolevel() const { return _channel_isolevel; } -void BlockVoxelStructure::set_channel_isolevel(const int value) { +void BlockTerraStructure::set_channel_isolevel(const int value) { _channel_isolevel = value; } -int BlockVoxelStructure::get_voxel_type(int p_x, int p_y, int p_z) const { +int BlockTerraStructure::get_voxel_type(int p_x, int p_y, int p_z) const { DataEntry p; for (int i = 0; i < _data.size(); ++i) { @@ -49,7 +49,7 @@ int BlockVoxelStructure::get_voxel_type(int p_x, int p_y, int p_z) const { return 0; } -int BlockVoxelStructure::get_voxel_isolevel(int p_x, int p_y, int p_z) const { +int BlockTerraStructure::get_voxel_isolevel(int p_x, int p_y, int p_z) const { DataEntry p; for (int i = 0; i < _data.size(); ++i) { @@ -63,7 +63,7 @@ int BlockVoxelStructure::get_voxel_isolevel(int p_x, int p_y, int p_z) const { return 0; } -void BlockVoxelStructure::set_voxel(int p_x, int p_y, int p_z, int p_type, int p_isolevel) { +void BlockTerraStructure::set_voxel(int p_x, int p_y, int p_z, int p_type, int p_isolevel) { DataEntry p; p.x = p_x; p.y = p_y; @@ -74,36 +74,36 @@ void BlockVoxelStructure::set_voxel(int p_x, int p_y, int p_z, int p_type, int p _data.push_back(p); } -void BlockVoxelStructure::_write_to_chunk(Ref chunk) { - //Ref c = Object::cast_to(chunk); +void BlockTerraStructure::_write_to_chunk(Ref chunk) { + //Ref c = Object::cast_to(chunk); } -void BlockVoxelStructure::clear() { +void BlockTerraStructure::clear() { _data.clear(); } -BlockVoxelStructure::BlockVoxelStructure() { +BlockTerraStructure::BlockTerraStructure() { _channel_type = 0; _channel_isolevel = 0; } -BlockVoxelStructure::~BlockVoxelStructure() { +BlockTerraStructure::~BlockTerraStructure() { _data.clear(); } -void BlockVoxelStructure::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_channel_type"), &BlockVoxelStructure::get_channel_type); - ClassDB::bind_method(D_METHOD("set_channel_type", "value"), &BlockVoxelStructure::set_channel_type); +void BlockTerraStructure::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_channel_type"), &BlockTerraStructure::get_channel_type); + ClassDB::bind_method(D_METHOD("set_channel_type", "value"), &BlockTerraStructure::set_channel_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_type"), "set_channel_type", "get_channel_type"); - ClassDB::bind_method(D_METHOD("get_channel_isolevel"), &BlockVoxelStructure::get_channel_isolevel); - ClassDB::bind_method(D_METHOD("set_channel_isolevel", "value"), &BlockVoxelStructure::set_channel_isolevel); + ClassDB::bind_method(D_METHOD("get_channel_isolevel"), &BlockTerraStructure::get_channel_isolevel); + ClassDB::bind_method(D_METHOD("set_channel_isolevel", "value"), &BlockTerraStructure::set_channel_isolevel); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_isolevel"), "set_channel_isolevel", "get_channel_isolevel"); - ClassDB::bind_method(D_METHOD("get_voxel_type", "x", "y", "z"), &BlockVoxelStructure::get_voxel_type); - ClassDB::bind_method(D_METHOD("get_voxel_isolevel", "x", "y", "z"), &BlockVoxelStructure::get_voxel_isolevel); + ClassDB::bind_method(D_METHOD("get_voxel_type", "x", "y", "z"), &BlockTerraStructure::get_voxel_type); + ClassDB::bind_method(D_METHOD("get_voxel_isolevel", "x", "y", "z"), &BlockTerraStructure::get_voxel_isolevel); - ClassDB::bind_method(D_METHOD("set_voxel", "x", "y", "z", "type", "isolevel"), &BlockVoxelStructure::set_voxel); + ClassDB::bind_method(D_METHOD("set_voxel", "x", "y", "z", "type", "isolevel"), &BlockTerraStructure::set_voxel); - ClassDB::bind_method(D_METHOD("_write_to_chunk", "chunk"), &BlockVoxelStructure::_write_to_chunk); + ClassDB::bind_method(D_METHOD("_write_to_chunk", "chunk"), &BlockTerraStructure::_write_to_chunk); } diff --git a/world/block_voxel_structure.h b/world/block_voxel_structure.h index 05316ec..1d12c37 100644 --- a/world/block_voxel_structure.h +++ b/world/block_voxel_structure.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef BLOCK_VOXEL_STRUCTURE_H -#define BLOCK_VOXEL_STRUCTURE_H +#ifndef BLOCK_TERRA_STRUCTURE_H +#define BLOCK_TERRA_STRUCTURE_H #include "core/version.h" @@ -41,8 +41,8 @@ include_pool_vector #include "voxel_chunk.h" ; -class BlockVoxelStructure : public VoxelStructure { - GDCLASS(BlockVoxelStructure, VoxelStructure); +class BlockTerraStructure : public TerraStructure { + GDCLASS(BlockTerraStructure, TerraStructure); public: int get_channel_type() const; @@ -56,12 +56,12 @@ public: void set_voxel(int p_x, int p_y, int p_z, int p_type, int p_isolevel); - void _write_to_chunk(Ref chunk); + void _write_to_chunk(Ref chunk); void clear(); - BlockVoxelStructure(); - ~BlockVoxelStructure(); + BlockTerraStructure(); + ~BlockTerraStructure(); protected: static void _bind_methods(); diff --git a/world/blocky/voxel_chunk_blocky.cpp b/world/blocky/voxel_chunk_blocky.cpp index 21ae8e1..3e2b880 100644 --- a/world/blocky/voxel_chunk_blocky.cpp +++ b/world/blocky/voxel_chunk_blocky.cpp @@ -24,19 +24,19 @@ SOFTWARE. #include "../../defines.h" -VoxelChunkBlocky::VoxelChunkBlocky() { +TerraChunkBlocky::TerraChunkBlocky() { } -VoxelChunkBlocky::~VoxelChunkBlocky() { +TerraChunkBlocky::~TerraChunkBlocky() { } -void VoxelChunkBlocky::_setup_channels() { +void TerraChunkBlocky::_setup_channels() { channel_set_count(MAX_DEFAULT_CHANNELS); } -void VoxelChunkBlocky::_bind_methods() { +void TerraChunkBlocky::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0); - //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed); - //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); + //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &TerraChunk::get_channel_compressed); + //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &TerraChunk::set_channel_compressed); } diff --git a/world/blocky/voxel_chunk_blocky.h b/world/blocky/voxel_chunk_blocky.h index 9590f81..c3052cb 100644 --- a/world/blocky/voxel_chunk_blocky.h +++ b/world/blocky/voxel_chunk_blocky.h @@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_CHUNK_BLOCKY_H -#define VOXEL_CHUNK_BLOCKY_H +#ifndef TERRA_CHUNK_BLOCKY_H +#define TERRA_CHUNK_BLOCKY_H #include "../default/voxel_chunk_default.h" -class VoxelChunkBlocky : public VoxelChunkDefault { - GDCLASS(VoxelChunkBlocky, VoxelChunkDefault); +class TerraChunkBlocky : public TerraChunkDefault { + GDCLASS(TerraChunkBlocky, TerraChunkDefault); public: - VoxelChunkBlocky(); - ~VoxelChunkBlocky(); + TerraChunkBlocky(); + ~TerraChunkBlocky(); protected: virtual void _setup_channels(); diff --git a/world/blocky/voxel_world_blocky.cpp b/world/blocky/voxel_world_blocky.cpp index da24207..3c3580e 100644 --- a/world/blocky/voxel_world_blocky.cpp +++ b/world/blocky/voxel_world_blocky.cpp @@ -30,41 +30,41 @@ SOFTWARE. #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrarin_job.h" -Ref VoxelWorldBlocky::_create_chunk(int x, int y, int z, Ref chunk) { +Ref TerraWorldBlocky::_create_chunk(int x, int y, int z, Ref chunk) { if (!chunk.is_valid()) { - chunk = Ref(memnew(VoxelChunkBlocky)); + chunk = Ref(memnew(TerraChunkBlocky)); } if (chunk->job_get_count() == 0) { - Ref tj; + Ref tj; tj.instance(); - Ref lj; + Ref lj; lj.instance(); - Ref pj; + Ref pj; pj.instance(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherBlocky))); + pj->set_prop_mesher(Ref(memnew(TerraMesherBlocky))); - tj->add_mesher(Ref(memnew(VoxelMesherBlocky()))); - tj->add_liquid_mesher(Ref(memnew(VoxelMesherLiquidBlocky()))); + tj->add_mesher(Ref(memnew(TerraMesherBlocky()))); + tj->add_liquid_mesher(Ref(memnew(TerraMesherLiquidBlocky()))); chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); } - return VoxelWorld::_create_chunk(x, y, z, chunk); + return TerraWorld::_create_chunk(x, y, z, chunk); } -VoxelWorldBlocky::VoxelWorldBlocky() { +TerraWorldBlocky::TerraWorldBlocky() { set_data_margin_start(1); set_data_margin_end(1); } -VoxelWorldBlocky ::~VoxelWorldBlocky() { +TerraWorldBlocky ::~TerraWorldBlocky() { } -void VoxelWorldBlocky::_bind_methods() { +void TerraWorldBlocky::_bind_methods() { } \ No newline at end of file diff --git a/world/blocky/voxel_world_blocky.h b/world/blocky/voxel_world_blocky.h index de1e6aa..3d48b1d 100644 --- a/world/blocky/voxel_world_blocky.h +++ b/world/blocky/voxel_world_blocky.h @@ -20,20 +20,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_BLOCKY_H -#define VOXEL_WORLD_BLOCKY_H +#ifndef TERRA_WORLD_BLOCKY_H +#define TERRA_WORLD_BLOCKY_H #include "../default/voxel_world_default.h" -class VoxelWorldBlocky : public VoxelWorldDefault { - GDCLASS(VoxelWorldBlocky, VoxelWorldDefault); +class TerraWorldBlocky : public TerraWorldDefault { + GDCLASS(TerraWorldBlocky, TerraWorldDefault); public: - VoxelWorldBlocky(); - ~VoxelWorldBlocky(); + TerraWorldBlocky(); + ~TerraWorldBlocky(); protected: - Ref _create_chunk(int x, int y, int z, Ref p_chunk); + Ref _create_chunk(int x, int y, int z, Ref p_chunk); static void _bind_methods(); }; diff --git a/world/cubic/voxel_chunk_cubic.cpp b/world/cubic/voxel_chunk_cubic.cpp index a5bee8c..aad8985 100644 --- a/world/cubic/voxel_chunk_cubic.cpp +++ b/world/cubic/voxel_chunk_cubic.cpp @@ -24,20 +24,20 @@ SOFTWARE. #include "../../defines.h" -VoxelChunkCubic::VoxelChunkCubic() { +TerraChunkCubic::TerraChunkCubic() { } -VoxelChunkCubic::~VoxelChunkCubic() { +TerraChunkCubic::~TerraChunkCubic() { } -void VoxelChunkCubic::_setup_channels() { +void TerraChunkCubic::_setup_channels() { channel_set_count(MAX_DEFAULT_CHANNELS); } -void VoxelChunkCubic::_bind_methods() { +void TerraChunkCubic::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0); ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "channel_set_compressed", "channel_get_compressed", 1); - //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed); - //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); + //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &TerraChunk::get_channel_compressed); + //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &TerraChunk::set_channel_compressed); } diff --git a/world/cubic/voxel_chunk_cubic.h b/world/cubic/voxel_chunk_cubic.h index bf4b85a..38c6a2f 100644 --- a/world/cubic/voxel_chunk_cubic.h +++ b/world/cubic/voxel_chunk_cubic.h @@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_CHUNK_CUBIC_H -#define VOXEL_CHUNK_CUBIC_H +#ifndef TERRA_CHUNK_CUBIC_H +#define TERRA_CHUNK_CUBIC_H #include "../default/voxel_chunk_default.h" -class VoxelChunkCubic : public VoxelChunkDefault { - GDCLASS(VoxelChunkCubic, VoxelChunkDefault); +class TerraChunkCubic : public TerraChunkDefault { + GDCLASS(TerraChunkCubic, TerraChunkDefault); public: - VoxelChunkCubic(); - ~VoxelChunkCubic(); + TerraChunkCubic(); + ~TerraChunkCubic(); protected: virtual void _setup_channels(); diff --git a/world/cubic/voxel_world_cubic.cpp b/world/cubic/voxel_world_cubic.cpp index bec1fc0..bd86c96 100644 --- a/world/cubic/voxel_world_cubic.cpp +++ b/world/cubic/voxel_world_cubic.cpp @@ -29,45 +29,45 @@ SOFTWARE. #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrarin_job.h" -Ref VoxelWorldCubic::_create_chunk(int x, int y, int z, Ref chunk) { +Ref TerraWorldCubic::_create_chunk(int x, int y, int z, Ref chunk) { if (!chunk.is_valid()) { - chunk = Ref(memnew(VoxelChunkCubic)); + chunk = Ref(memnew(TerraChunkCubic)); } if (chunk->job_get_count() == 0) { - Ref tj; + Ref tj; tj.instance(); - Ref lj; + Ref lj; lj.instance(); - Ref pj; + Ref pj; pj.instance(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherCubic))); + pj->set_prop_mesher(Ref(memnew(TerraMesherCubic))); - Ref m = Ref(memnew(VoxelMesherCubic())); - m->set_channel_index_type(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); - m->set_channel_index_isolevel(VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + Ref m = Ref(memnew(TerraMesherCubic())); + m->set_channel_index_type(TerraChunkDefault::DEFAULT_CHANNEL_TYPE); + m->set_channel_index_isolevel(TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); tj->add_mesher(m); - //add_liquid_mesher(Ref(memnew(VoxelMesherLiquidMarchingCubes()))); + //add_liquid_mesher(Ref(memnew(TerraMesherLiquidMarchingCubes()))); chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); } - return VoxelWorld::_create_chunk(x, y, z, chunk); + return TerraWorld::_create_chunk(x, y, z, chunk); } -VoxelWorldCubic::VoxelWorldCubic() { +TerraWorldCubic::TerraWorldCubic() { set_data_margin_start(1); set_data_margin_end(1); } -VoxelWorldCubic ::~VoxelWorldCubic() { +TerraWorldCubic ::~TerraWorldCubic() { } -void VoxelWorldCubic::_bind_methods() { +void TerraWorldCubic::_bind_methods() { } \ No newline at end of file diff --git a/world/cubic/voxel_world_cubic.h b/world/cubic/voxel_world_cubic.h index 690f4fc..5c3e502 100644 --- a/world/cubic/voxel_world_cubic.h +++ b/world/cubic/voxel_world_cubic.h @@ -20,20 +20,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_CUBIC_H -#define VOXEL_WORLD_CUBIC_H +#ifndef TERRA_WORLD_CUBIC_H +#define TERRA_WORLD_CUBIC_H #include "../default/voxel_world_default.h" -class VoxelWorldCubic : public VoxelWorldDefault { - GDCLASS(VoxelWorldCubic, VoxelWorldDefault); +class TerraWorldCubic : public TerraWorldDefault { + GDCLASS(TerraWorldCubic, TerraWorldDefault); public: - VoxelWorldCubic(); - ~VoxelWorldCubic(); + TerraWorldCubic(); + ~TerraWorldCubic(); protected: - Ref _create_chunk(int x, int y, int z, Ref p_chunk); + Ref _create_chunk(int x, int y, int z, Ref p_chunk); static void _bind_methods(); }; diff --git a/world/default/voxel_chunk_default.cpp b/world/default/voxel_chunk_default.cpp index 857ce78..c190c7d 100644 --- a/world/default/voxel_chunk_default.cpp +++ b/world/default/voxel_chunk_default.cpp @@ -39,33 +39,33 @@ SOFTWARE. #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrarin_job.h" -const String VoxelChunkDefault::BINDING_STRING_BUILD_FLAGS = "Use Isolevel,Use Lighting,Use AO,Use RAO,Generate AO,Generate RAO,Bake Lights,Create Collider,Create Lods"; +const String TerraChunkDefault::BINDING_STRING_BUILD_FLAGS = "Use Isolevel,Use Lighting,Use AO,Use RAO,Generate AO,Generate RAO,Bake Lights,Create Collider,Create Lods"; -_FORCE_INLINE_ int VoxelChunkDefault::get_build_flags() const { +_FORCE_INLINE_ int TerraChunkDefault::get_build_flags() const { return _build_flags; } -_FORCE_INLINE_ void VoxelChunkDefault::set_build_flags(const int flags) { +_FORCE_INLINE_ void TerraChunkDefault::set_build_flags(const int flags) { _build_flags = flags; } -bool VoxelChunkDefault::get_lights_dirty() const { +bool TerraChunkDefault::get_lights_dirty() const { return _lights_dirty; } -void VoxelChunkDefault::set_lights_dirty(const bool value) { +void TerraChunkDefault::set_lights_dirty(const bool value) { _lights_dirty = value; } -int VoxelChunkDefault::get_lod_num() const { +int TerraChunkDefault::get_lod_num() const { return _lod_num; } -void VoxelChunkDefault::set_lod_num(const int value) { +void TerraChunkDefault::set_lod_num(const int value) { _lod_num = value; } -int VoxelChunkDefault::get_current_lod_level() const { +int TerraChunkDefault::get_current_lod_level() const { return _current_lod_level; } -void VoxelChunkDefault::set_current_lod_level(const int value) { +void TerraChunkDefault::set_current_lod_level(const int value) { _current_lod_level = value; if ((_build_flags & BUILD_FLAG_CREATE_LODS) == 0) @@ -95,7 +95,7 @@ void VoxelChunkDefault::set_current_lod_level(const int value) { } } -void VoxelChunkDefault::emit_build_finished() { +void TerraChunkDefault::emit_build_finished() { emit_signal("mesh_generation_finished", this); if (_voxel_world != NULL) { @@ -104,14 +104,14 @@ void VoxelChunkDefault::emit_build_finished() { } //Meshes -Dictionary VoxelChunkDefault::mesh_rids_get() { +Dictionary TerraChunkDefault::mesh_rids_get() { return _rids; } -void VoxelChunkDefault::mesh_rids_set(const Dictionary &rids) { +void TerraChunkDefault::mesh_rids_set(const Dictionary &rids) { _rids = rids; } -RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_index) { +RID TerraChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_index) { if (!_rids.has(mesh_index)) return RID(); @@ -132,7 +132,7 @@ RID VoxelChunkDefault::mesh_rid_get(const int mesh_index, const int mesh_type_in return v; } -void VoxelChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_index, RID value) { +void TerraChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_index, RID value) { if (!_rids.has(mesh_index)) _rids[mesh_index] = Dictionary(); @@ -155,7 +155,7 @@ void VoxelChunkDefault::mesh_rid_set(const int mesh_index, const int mesh_type_i m[mesh_type_index] = value; _rids[mesh_index] = m; } -RID VoxelChunkDefault::mesh_rid_get_index(const int mesh_index, const int mesh_type_index, const int index) { +RID TerraChunkDefault::mesh_rid_get_index(const int mesh_index, const int mesh_type_index, const int index) { if (!_rids.has(mesh_index)) return RID(); @@ -175,7 +175,7 @@ RID VoxelChunkDefault::mesh_rid_get_index(const int mesh_index, const int mesh_t return arr[index]; } -void VoxelChunkDefault::mesh_rid_set_index(const int mesh_index, const int mesh_type_index, const int index, RID value) { +void TerraChunkDefault::mesh_rid_set_index(const int mesh_index, const int mesh_type_index, const int index, RID value) { if (!_rids.has(mesh_index)) _rids[mesh_index] = Dictionary(); @@ -205,7 +205,7 @@ void VoxelChunkDefault::mesh_rid_set_index(const int mesh_index, const int mesh_ m[mesh_type_index] = arr; _rids[mesh_index] = m; } -int VoxelChunkDefault::mesh_rid_get_count(const int mesh_index, const int mesh_type_index) { +int TerraChunkDefault::mesh_rid_get_count(const int mesh_index, const int mesh_type_index) { if (!_rids.has(mesh_index)) return 0; @@ -223,7 +223,7 @@ int VoxelChunkDefault::mesh_rid_get_count(const int mesh_index, const int mesh_t return arr.size(); } -void VoxelChunkDefault::mesh_rids_clear(const int mesh_index, const int mesh_type_index) { +void TerraChunkDefault::mesh_rids_clear(const int mesh_index, const int mesh_type_index) { if (!_rids.has(mesh_index)) return; @@ -234,7 +234,7 @@ void VoxelChunkDefault::mesh_rids_clear(const int mesh_index, const int mesh_typ m.erase(mesh_type_index); } -Array VoxelChunkDefault::meshes_get(const int mesh_index, const int mesh_type_index) { +Array TerraChunkDefault::meshes_get(const int mesh_index, const int mesh_type_index) { if (!_rids.has(mesh_index)) return Array(); @@ -250,7 +250,7 @@ Array VoxelChunkDefault::meshes_get(const int mesh_index, const int mesh_type_in return v; } -void VoxelChunkDefault::meshes_set(const int mesh_index, const int mesh_type_index, const Array &meshes) { +void TerraChunkDefault::meshes_set(const int mesh_index, const int mesh_type_index, const Array &meshes) { if (!_rids.has(mesh_index)) _rids[mesh_index] = Dictionary(); @@ -259,7 +259,7 @@ void VoxelChunkDefault::meshes_set(const int mesh_index, const int mesh_type_ind m[mesh_type_index] = meshes; _rids[mesh_index] = m; } -bool VoxelChunkDefault::meshes_has(const int mesh_index, const int mesh_type_index) { +bool TerraChunkDefault::meshes_has(const int mesh_index, const int mesh_type_index) { if (!_rids.has(mesh_index)) return false; @@ -271,11 +271,11 @@ bool VoxelChunkDefault::meshes_has(const int mesh_index, const int mesh_type_ind return true; } -void VoxelChunkDefault::rids_clear() { +void TerraChunkDefault::rids_clear() { _rids.clear(); } -void VoxelChunkDefault::rids_free() { +void TerraChunkDefault::rids_free() { List keys; _rids.get_key_list(&keys); @@ -290,7 +290,7 @@ void VoxelChunkDefault::rids_free() { } } -void VoxelChunkDefault::meshes_create(const int mesh_index, const int mesh_count) { +void TerraChunkDefault::meshes_create(const int mesh_index, const int mesh_count) { ERR_FAIL_COND(_voxel_world == NULL); ERR_FAIL_COND(!get_library().is_valid()); @@ -329,7 +329,7 @@ void VoxelChunkDefault::meshes_create(const int mesh_index, const int mesh_count _rids[mesh_index] = m; } -void VoxelChunkDefault::meshes_free(const int mesh_index) { +void TerraChunkDefault::meshes_free(const int mesh_index) { if (!_rids.has(mesh_index)) return; @@ -364,7 +364,7 @@ void VoxelChunkDefault::meshes_free(const int mesh_index) { m.erase(MESH_TYPE_INDEX_MESH_INSTANCE); } -void VoxelChunkDefault::colliders_create(const int mesh_index, const int layer_mask) { +void TerraChunkDefault::colliders_create(const int mesh_index, const int layer_mask) { ERR_FAIL_COND(_voxel_world == NULL); ERR_FAIL_COND(PhysicsServer::get_singleton()->is_flushing_queries()); //ERR_FAIL_COND(!get_voxel_world()->is_inside_tree()); @@ -399,7 +399,7 @@ void VoxelChunkDefault::colliders_create(const int mesh_index, const int layer_m _rids[mesh_index] = m; } -void VoxelChunkDefault::colliders_create_area(const int mesh_index, const int layer_mask) { +void TerraChunkDefault::colliders_create_area(const int mesh_index, const int layer_mask) { ERR_FAIL_COND(_voxel_world == NULL); ERR_FAIL_COND(PhysicsServer::get_singleton()->is_flushing_queries()); @@ -440,7 +440,7 @@ void VoxelChunkDefault::colliders_create_area(const int mesh_index, const int la _rids[mesh_index] = m; } -void VoxelChunkDefault::colliders_free(const int mesh_index) { +void TerraChunkDefault::colliders_free(const int mesh_index) { if (!_rids.has(mesh_index)) return; @@ -465,12 +465,12 @@ void VoxelChunkDefault::colliders_free(const int mesh_index) { _rids[mesh_index] = m; } -void VoxelChunkDefault::free_index(const int mesh_index) { +void TerraChunkDefault::free_index(const int mesh_index) { meshes_free(mesh_index); colliders_free(mesh_index); } -void VoxelChunkDefault::update_transforms() { +void TerraChunkDefault::update_transforms() { RID empty_rid; Transform t = get_transform(); @@ -522,16 +522,16 @@ void VoxelChunkDefault::update_transforms() { } //Lights -Ref VoxelChunkDefault::get_light(const int index) { - ERR_FAIL_INDEX_V(index, _lights.size(), Ref()); +Ref TerraChunkDefault::get_light(const int index) { + ERR_FAIL_INDEX_V(index, _lights.size(), Ref()); return _lights.get(index); } -int VoxelChunkDefault::get_light_count() const { +int TerraChunkDefault::get_light_count() const { return _lights.size(); } -void VoxelChunkDefault::debug_mesh_allocate() { +void TerraChunkDefault::debug_mesh_allocate() { if (_debug_mesh_rid == RID()) { _debug_mesh_rid = VisualServer::get_singleton()->mesh_create(); } @@ -547,7 +547,7 @@ void VoxelChunkDefault::debug_mesh_allocate() { VS::get_singleton()->instance_set_visible(_debug_mesh_instance, true); } } -void VoxelChunkDefault::debug_mesh_free() { +void TerraChunkDefault::debug_mesh_free() { if (_debug_mesh_instance != RID()) { VisualServer::get_singleton()->free(_debug_mesh_instance); } @@ -556,25 +556,25 @@ void VoxelChunkDefault::debug_mesh_free() { VisualServer::get_singleton()->free(_debug_mesh_rid); } } -bool VoxelChunkDefault::debug_mesh_has() { +bool TerraChunkDefault::debug_mesh_has() { return _debug_mesh_rid != RID(); } -void VoxelChunkDefault::debug_mesh_clear() { +void TerraChunkDefault::debug_mesh_clear() { if (_debug_mesh_rid != RID()) { VisualServer::get_singleton()->mesh_clear(_debug_mesh_rid); } } -void VoxelChunkDefault::debug_mesh_array_clear() { +void TerraChunkDefault::debug_mesh_array_clear() { _debug_mesh_array.resize(0); } -void VoxelChunkDefault::debug_mesh_add_vertices_to(const PoolVector3Array &arr) { +void TerraChunkDefault::debug_mesh_add_vertices_to(const PoolVector3Array &arr) { _debug_mesh_array.append_array(arr); if (_debug_mesh_array.size() % 2 == 1) { _debug_mesh_array.append(_debug_mesh_array[_debug_mesh_array.size() - 1]); } } -void VoxelChunkDefault::debug_mesh_send() { +void TerraChunkDefault::debug_mesh_send() { debug_mesh_allocate(); debug_mesh_clear(); @@ -596,7 +596,7 @@ void VoxelChunkDefault::debug_mesh_send() { debug_mesh_array_clear(); } -void VoxelChunkDefault::draw_cross_voxels(Vector3 pos) { +void TerraChunkDefault::draw_cross_voxels(Vector3 pos) { pos *= _voxel_scale; int size = _debug_mesh_array.size(); @@ -612,7 +612,7 @@ void VoxelChunkDefault::draw_cross_voxels(Vector3 pos) { _debug_mesh_array.set(size + 5, pos + Vector3(0.2, 0, 0)); } -void VoxelChunkDefault::draw_cross_voxels_fill(Vector3 pos, float fill) { +void TerraChunkDefault::draw_cross_voxels_fill(Vector3 pos, float fill) { pos *= _voxel_scale; int size = _debug_mesh_array.size(); @@ -628,7 +628,7 @@ void VoxelChunkDefault::draw_cross_voxels_fill(Vector3 pos, float fill) { _debug_mesh_array.set(size + 5, pos + Vector3(0.2 * fill, 0, 0)); } -void VoxelChunkDefault::draw_debug_voxels(int max, Color color) { +void TerraChunkDefault::draw_debug_voxels(int max, Color color) { if (!debug_mesh_has()) { debug_mesh_allocate(); } @@ -646,13 +646,13 @@ void VoxelChunkDefault::draw_debug_voxels(int max, Color color) { for (int y = 0; y < sy; ++y) { for (int z = 0; z < sz; ++z) { for (int x = 0; x < sx; ++x) { - int type = get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); + int type = get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_TYPE); if (type == 0) { continue; } - draw_cross_voxels_fill(Vector3(x, y, z), get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL) / 255.0 * get_voxel_scale() * 2.0); + draw_cross_voxels_fill(Vector3(x, y, z), get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL) / 255.0 * get_voxel_scale() * 2.0); ++a; @@ -666,7 +666,7 @@ void VoxelChunkDefault::draw_debug_voxels(int max, Color color) { debug_mesh_send(); } -void VoxelChunkDefault::draw_debug_voxel_lights() { +void TerraChunkDefault::draw_debug_voxel_lights() { if (!debug_mesh_has()) { debug_mesh_allocate(); } @@ -676,7 +676,7 @@ void VoxelChunkDefault::draw_debug_voxel_lights() { //_debug_drawer->begin(Mesh::PrimitiveType::PRIMITIVE_LINES); for (int i = 0; i < _lights.size(); ++i) { - Ref v = _lights[i]; + Ref v = _lights[i]; int pos_x = v->get_world_position_x() - (_size_x * _position_x); int pos_y = v->get_world_position_y() - (_size_y * _position_y); @@ -688,7 +688,7 @@ void VoxelChunkDefault::draw_debug_voxel_lights() { debug_mesh_send(); } -void VoxelChunkDefault::draw_debug_mdr_colliders() { +void TerraChunkDefault::draw_debug_mdr_colliders() { if (!debug_mesh_has()) { debug_mesh_allocate(); } @@ -705,7 +705,7 @@ void VoxelChunkDefault::draw_debug_mdr_colliders() { } } -void VoxelChunkDefault::_visibility_changed(bool visible) { +void TerraChunkDefault::_visibility_changed(bool visible) { if (visible) { set_current_lod_level(_current_lod_level); return; @@ -729,27 +729,27 @@ void VoxelChunkDefault::_visibility_changed(bool visible) { } } -void VoxelChunkDefault::_exit_tree() { - VoxelChunk::_exit_tree(); +void TerraChunkDefault::_exit_tree() { + TerraChunk::_exit_tree(); rids_free(); } -void VoxelChunkDefault::_world_transform_changed() { - VoxelChunk::_world_transform_changed(); +void TerraChunkDefault::_world_transform_changed() { + TerraChunk::_world_transform_changed(); update_transforms(); } //Lights -void VoxelChunkDefault::_bake_lights() { +void TerraChunkDefault::_bake_lights() { clear_baked_lights(); for (int i = 0; i < _lights.size(); ++i) { bake_light(_lights.get(i)); } } -void VoxelChunkDefault::_bake_light(Ref light) { +void TerraChunkDefault::_bake_light(Ref light) { ERR_FAIL_COND(!light.is_valid()); Color color = light->get_color(); @@ -765,9 +765,9 @@ void VoxelChunkDefault::_bake_light(Ref light) { int64_t dsy = static_cast(_data_size_y); int64_t dsz = static_cast(_data_size_z); - uint8_t *channel_color_r = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); - uint8_t *channel_color_g = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); - uint8_t *channel_color_b = channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); + uint8_t *channel_color_r = channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R); + uint8_t *channel_color_g = channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G); + uint8_t *channel_color_b = channel_get(TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B); ERR_FAIL_COND(channel_color_r == NULL || channel_color_g == NULL || channel_color_b == NULL); @@ -819,17 +819,17 @@ void VoxelChunkDefault::_bake_light(Ref light) { } } } -void VoxelChunkDefault::_clear_baked_lights() { +void TerraChunkDefault::_clear_baked_lights() { channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_R); channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_G); channel_fill(0, DEFAULT_CHANNEL_LIGHT_COLOR_B); } -void VoxelChunkDefault::_world_light_added(const Ref &light) { +void TerraChunkDefault::_world_light_added(const Ref &light) { _lights.push_back(light); set_lights_dirty(true); } -void VoxelChunkDefault::_world_light_removed(const Ref &light) { +void TerraChunkDefault::_world_light_removed(const Ref &light) { int index = _lights.find(light); if (index != -1) { @@ -839,11 +839,11 @@ void VoxelChunkDefault::_world_light_removed(const Ref &light) { } } -void VoxelChunkDefault::free_chunk() { +void TerraChunkDefault::free_chunk() { rids_free(); } -void VoxelChunkDefault::_finalize_build() { +void TerraChunkDefault::_finalize_build() { ERR_FAIL_COND(!_library.is_valid()); #if TOOLS_ENABLED @@ -857,7 +857,7 @@ void VoxelChunkDefault::_finalize_build() { call_deferred("update_transforms"); } -VoxelChunkDefault::VoxelChunkDefault() { +TerraChunkDefault::TerraChunkDefault() { _abort_build = false; _enabled = true; @@ -868,7 +868,7 @@ VoxelChunkDefault::VoxelChunkDefault() { _build_flags = BUILD_FLAG_CREATE_COLLIDER | BUILD_FLAG_CREATE_LODS; } -VoxelChunkDefault::~VoxelChunkDefault() { +TerraChunkDefault::~TerraChunkDefault() { _abort_build = true; _lights.clear(); @@ -876,92 +876,92 @@ VoxelChunkDefault::~VoxelChunkDefault() { debug_mesh_free(); } -void VoxelChunkDefault::_channel_setup() { +void TerraChunkDefault::_channel_setup() { channel_set_count(MAX_DEFAULT_CHANNELS); } -void VoxelChunkDefault::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_build_flags"), &VoxelChunkDefault::get_build_flags); - ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &VoxelChunkDefault::set_build_flags); +void TerraChunkDefault::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_build_flags"), &TerraChunkDefault::get_build_flags); + ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &TerraChunkDefault::set_build_flags); ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, BINDING_STRING_BUILD_FLAGS, 0), "set_build_flags", "get_build_flags"); - ClassDB::bind_method(D_METHOD("get_lights_dirty"), &VoxelChunkDefault::get_lights_dirty); - ClassDB::bind_method(D_METHOD("set_lights_dirty", "value"), &VoxelChunkDefault::set_lights_dirty); + ClassDB::bind_method(D_METHOD("get_lights_dirty"), &TerraChunkDefault::get_lights_dirty); + ClassDB::bind_method(D_METHOD("set_lights_dirty", "value"), &TerraChunkDefault::set_lights_dirty); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "lights_dirty", PROPERTY_HINT_NONE, "", 0), "set_lights_dirty", "get_lights_dirty"); - ClassDB::bind_method(D_METHOD("get_lod_num"), &VoxelChunkDefault::get_lod_num); - ClassDB::bind_method(D_METHOD("set_lod_num"), &VoxelChunkDefault::set_lod_num); + ClassDB::bind_method(D_METHOD("get_lod_num"), &TerraChunkDefault::get_lod_num); + ClassDB::bind_method(D_METHOD("set_lod_num"), &TerraChunkDefault::set_lod_num); ADD_PROPERTY(PropertyInfo(Variant::INT, "lod_num", PROPERTY_HINT_NONE, "", 0), "set_lod_num", "get_lod_num"); - ClassDB::bind_method(D_METHOD("get_current_lod_level"), &VoxelChunkDefault::get_current_lod_level); - ClassDB::bind_method(D_METHOD("set_current_lod_level"), &VoxelChunkDefault::set_current_lod_level); + ClassDB::bind_method(D_METHOD("get_current_lod_level"), &TerraChunkDefault::get_current_lod_level); + ClassDB::bind_method(D_METHOD("set_current_lod_level"), &TerraChunkDefault::set_current_lod_level); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_lod_level"), "set_current_lod_level", "get_current_lod_level"); //Meshes - ClassDB::bind_method(D_METHOD("get_mesh_rids"), &VoxelChunkDefault::mesh_rids_get); - ClassDB::bind_method(D_METHOD("set_mesh_rids", "rids"), &VoxelChunkDefault::mesh_rids_set); - ClassDB::bind_method(D_METHOD("clear_rids"), &VoxelChunkDefault::rids_clear); + ClassDB::bind_method(D_METHOD("get_mesh_rids"), &TerraChunkDefault::mesh_rids_get); + ClassDB::bind_method(D_METHOD("set_mesh_rids", "rids"), &TerraChunkDefault::mesh_rids_set); + ClassDB::bind_method(D_METHOD("clear_rids"), &TerraChunkDefault::rids_clear); - ClassDB::bind_method(D_METHOD("mesh_rid_get", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rid_get); - ClassDB::bind_method(D_METHOD("mesh_rid_set", "mesh_index", "mesh_type_index", "value"), &VoxelChunkDefault::mesh_rid_set); - ClassDB::bind_method(D_METHOD("mesh_rid_get_index", "mesh_index", "mesh_type_index", "index"), &VoxelChunkDefault::mesh_rid_get_index); - ClassDB::bind_method(D_METHOD("mesh_rid_set_index", "mesh_index", "mesh_type_index", "index", "value"), &VoxelChunkDefault::mesh_rid_set_index); - ClassDB::bind_method(D_METHOD("mesh_rid_get_count", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rid_get_count); - ClassDB::bind_method(D_METHOD("mesh_rids_clear", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::mesh_rids_clear); - ClassDB::bind_method(D_METHOD("meshes_get", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::meshes_get); - ClassDB::bind_method(D_METHOD("meshes_set", "mesh_index", "mesh_type_index", "meshes"), &VoxelChunkDefault::meshes_set); - ClassDB::bind_method(D_METHOD("meshes_has", "mesh_index", "mesh_type_index"), &VoxelChunkDefault::meshes_has); + ClassDB::bind_method(D_METHOD("mesh_rid_get", "mesh_index", "mesh_type_index"), &TerraChunkDefault::mesh_rid_get); + ClassDB::bind_method(D_METHOD("mesh_rid_set", "mesh_index", "mesh_type_index", "value"), &TerraChunkDefault::mesh_rid_set); + ClassDB::bind_method(D_METHOD("mesh_rid_get_index", "mesh_index", "mesh_type_index", "index"), &TerraChunkDefault::mesh_rid_get_index); + ClassDB::bind_method(D_METHOD("mesh_rid_set_index", "mesh_index", "mesh_type_index", "index", "value"), &TerraChunkDefault::mesh_rid_set_index); + ClassDB::bind_method(D_METHOD("mesh_rid_get_count", "mesh_index", "mesh_type_index"), &TerraChunkDefault::mesh_rid_get_count); + ClassDB::bind_method(D_METHOD("mesh_rids_clear", "mesh_index", "mesh_type_index"), &TerraChunkDefault::mesh_rids_clear); + ClassDB::bind_method(D_METHOD("meshes_get", "mesh_index", "mesh_type_index"), &TerraChunkDefault::meshes_get); + ClassDB::bind_method(D_METHOD("meshes_set", "mesh_index", "mesh_type_index", "meshes"), &TerraChunkDefault::meshes_set); + ClassDB::bind_method(D_METHOD("meshes_has", "mesh_index", "mesh_type_index"), &TerraChunkDefault::meshes_has); - ClassDB::bind_method(D_METHOD("rids_free"), &VoxelChunkDefault::rids_free); - ClassDB::bind_method(D_METHOD("free_index", "mesh_index"), &VoxelChunkDefault::free_index); + ClassDB::bind_method(D_METHOD("rids_free"), &TerraChunkDefault::rids_free); + ClassDB::bind_method(D_METHOD("free_index", "mesh_index"), &TerraChunkDefault::free_index); - ClassDB::bind_method(D_METHOD("meshes_create", "mesh_index", "mesh_count"), &VoxelChunkDefault::meshes_create); - ClassDB::bind_method(D_METHOD("meshes_free", "mesh_index"), &VoxelChunkDefault::meshes_free); + ClassDB::bind_method(D_METHOD("meshes_create", "mesh_index", "mesh_count"), &TerraChunkDefault::meshes_create); + ClassDB::bind_method(D_METHOD("meshes_free", "mesh_index"), &TerraChunkDefault::meshes_free); - ClassDB::bind_method(D_METHOD("create_colliders", "mesh_index", "layer_mask"), &VoxelChunkDefault::colliders_create, DEFVAL(1)); - ClassDB::bind_method(D_METHOD("free_colliders", "mesh_index"), &VoxelChunkDefault::colliders_free); + ClassDB::bind_method(D_METHOD("create_colliders", "mesh_index", "layer_mask"), &TerraChunkDefault::colliders_create, DEFVAL(1)); + ClassDB::bind_method(D_METHOD("free_colliders", "mesh_index"), &TerraChunkDefault::colliders_free); //Lights - ClassDB::bind_method(D_METHOD("get_light", "index"), &VoxelChunkDefault::get_light); - ClassDB::bind_method(D_METHOD("get_light_count"), &VoxelChunkDefault::get_light_count); + ClassDB::bind_method(D_METHOD("get_light", "index"), &TerraChunkDefault::get_light); + ClassDB::bind_method(D_METHOD("get_light_count"), &TerraChunkDefault::get_light_count); //Debug - ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &VoxelChunkDefault::debug_mesh_allocate); - ClassDB::bind_method(D_METHOD("debug_mesh_free"), &VoxelChunkDefault::debug_mesh_free); + ClassDB::bind_method(D_METHOD("debug_mesh_allocate"), &TerraChunkDefault::debug_mesh_allocate); + ClassDB::bind_method(D_METHOD("debug_mesh_free"), &TerraChunkDefault::debug_mesh_free); - ClassDB::bind_method(D_METHOD("debug_mesh_has"), &VoxelChunkDefault::debug_mesh_has); - ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &VoxelChunkDefault::debug_mesh_clear); - ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &VoxelChunkDefault::debug_mesh_array_clear); - ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &VoxelChunkDefault::debug_mesh_add_vertices_to); - ClassDB::bind_method(D_METHOD("debug_mesh_send"), &VoxelChunkDefault::debug_mesh_send); + ClassDB::bind_method(D_METHOD("debug_mesh_has"), &TerraChunkDefault::debug_mesh_has); + ClassDB::bind_method(D_METHOD("debug_mesh_clear"), &TerraChunkDefault::debug_mesh_clear); + ClassDB::bind_method(D_METHOD("debug_mesh_array_clear"), &TerraChunkDefault::debug_mesh_array_clear); + ClassDB::bind_method(D_METHOD("debug_mesh_add_vertices_to", "arr"), &TerraChunkDefault::debug_mesh_add_vertices_to); + ClassDB::bind_method(D_METHOD("debug_mesh_send"), &TerraChunkDefault::debug_mesh_send); - ClassDB::bind_method(D_METHOD("draw_cross_voxels", "max"), &VoxelChunkDefault::draw_cross_voxels); - ClassDB::bind_method(D_METHOD("draw_cross_voxels_fill", "max", "fill"), &VoxelChunkDefault::draw_cross_voxels_fill); - ClassDB::bind_method(D_METHOD("draw_debug_voxels", "max", "color"), &VoxelChunkDefault::draw_debug_voxels, DEFVAL(Color(1, 1, 1))); + ClassDB::bind_method(D_METHOD("draw_cross_voxels", "max"), &TerraChunkDefault::draw_cross_voxels); + ClassDB::bind_method(D_METHOD("draw_cross_voxels_fill", "max", "fill"), &TerraChunkDefault::draw_cross_voxels_fill); + ClassDB::bind_method(D_METHOD("draw_debug_voxels", "max", "color"), &TerraChunkDefault::draw_debug_voxels, DEFVAL(Color(1, 1, 1))); - ClassDB::bind_method(D_METHOD("draw_debug_voxel_lights"), &VoxelChunkDefault::draw_debug_voxel_lights); - ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &VoxelChunkDefault::draw_debug_mdr_colliders); + ClassDB::bind_method(D_METHOD("draw_debug_voxel_lights"), &TerraChunkDefault::draw_debug_voxel_lights); + ClassDB::bind_method(D_METHOD("draw_debug_mdr_colliders"), &TerraChunkDefault::draw_debug_mdr_colliders); //Free - ClassDB::bind_method(D_METHOD("free_chunk"), &VoxelChunkDefault::free_chunk); + ClassDB::bind_method(D_METHOD("free_chunk"), &TerraChunkDefault::free_chunk); //etc - ClassDB::bind_method(D_METHOD("emit_build_finished"), &VoxelChunkDefault::emit_build_finished); + ClassDB::bind_method(D_METHOD("emit_build_finished"), &TerraChunkDefault::emit_build_finished); //virtuals - ClassDB::bind_method(D_METHOD("_channel_setup"), &VoxelChunkDefault::_channel_setup); + ClassDB::bind_method(D_METHOD("_channel_setup"), &TerraChunkDefault::_channel_setup); - ClassDB::bind_method(D_METHOD("_visibility_changed", "visible"), &VoxelChunkDefault::_visibility_changed); + ClassDB::bind_method(D_METHOD("_visibility_changed", "visible"), &TerraChunkDefault::_visibility_changed); //lights - ClassDB::bind_method(D_METHOD("_bake_lights"), &VoxelChunkDefault::_bake_lights); - ClassDB::bind_method(D_METHOD("_bake_light", "light"), &VoxelChunkDefault::_bake_light); - ClassDB::bind_method(D_METHOD("_clear_baked_lights"), &VoxelChunkDefault::_clear_baked_lights); + ClassDB::bind_method(D_METHOD("_bake_lights"), &TerraChunkDefault::_bake_lights); + ClassDB::bind_method(D_METHOD("_bake_light", "light"), &TerraChunkDefault::_bake_light); + ClassDB::bind_method(D_METHOD("_clear_baked_lights"), &TerraChunkDefault::_clear_baked_lights); - ClassDB::bind_method(D_METHOD("_world_light_added", "light"), &VoxelChunkDefault::_world_light_added); - ClassDB::bind_method(D_METHOD("_world_light_removed", "light"), &VoxelChunkDefault::_world_light_removed); + ClassDB::bind_method(D_METHOD("_world_light_added", "light"), &TerraChunkDefault::_world_light_added); + ClassDB::bind_method(D_METHOD("_world_light_removed", "light"), &TerraChunkDefault::_world_light_removed); - ClassDB::bind_method(D_METHOD("_finalize_build"), &VoxelChunkDefault::_finalize_build); + ClassDB::bind_method(D_METHOD("_finalize_build"), &TerraChunkDefault::_finalize_build); BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_TYPE); BIND_ENUM_CONSTANT(DEFAULT_CHANNEL_ISOLEVEL); diff --git a/world/default/voxel_chunk_default.h b/world/default/voxel_chunk_default.h index 690e19a..bfa1457 100644 --- a/world/default/voxel_chunk_default.h +++ b/world/default/voxel_chunk_default.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_CHUNK_DEFAULT_H -#define VOXEL_CHUNK_DEFAULT_H +#ifndef TERRA_CHUNK_DEFAULT_H +#define TERRA_CHUNK_DEFAULT_H #include "core/version.h" @@ -51,11 +51,11 @@ SOFTWARE. #include "../../library/voxel_surface.h" #include "../../library/voxelman_library.h" -class VoxelWorld; -class VoxelJob; +class TerraWorld; +class TerraJob; -class VoxelChunkDefault : public VoxelChunk { - GDCLASS(VoxelChunkDefault, VoxelChunk); +class TerraChunkDefault : public TerraChunk { + GDCLASS(TerraChunkDefault, TerraChunk); _THREAD_SAFE_CLASS_ @@ -150,7 +150,7 @@ public: void update_transforms(); //Lights - Ref get_light(const int index); + Ref get_light(const int index); int get_light_count() const; //Debug @@ -184,8 +184,8 @@ public: void _finalize_build(); - VoxelChunkDefault(); - ~VoxelChunkDefault(); + TerraChunkDefault(); + ~TerraChunkDefault(); protected: virtual void _channel_setup(); @@ -197,10 +197,10 @@ protected: //lights virtual void _bake_lights(); - virtual void _bake_light(Ref light); + virtual void _bake_light(Ref light); virtual void _clear_baked_lights(); - virtual void _world_light_added(const Ref &light); - virtual void _world_light_removed(const Ref &light); + virtual void _world_light_added(const Ref &light); + virtual void _world_light_removed(const Ref &light); static void _bind_methods(); @@ -222,10 +222,10 @@ protected: RID _debug_mesh_instance; PoolVector3Array _debug_mesh_array; - Vector > _lights; + Vector > _lights; }; -VARIANT_ENUM_CAST(VoxelChunkDefault::DefaultChannels); -VARIANT_ENUM_CAST(VoxelChunkDefault::BuildFlags); +VARIANT_ENUM_CAST(TerraChunkDefault::DefaultChannels); +VARIANT_ENUM_CAST(TerraChunkDefault::BuildFlags); #endif diff --git a/world/default/voxel_world_default.cpp b/world/default/voxel_world_default.cpp index e754cee..994a4a2 100644 --- a/world/default/voxel_world_default.cpp +++ b/world/default/voxel_world_default.cpp @@ -31,14 +31,14 @@ SOFTWARE. #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrarin_job.h" -_FORCE_INLINE_ int VoxelWorldDefault::get_build_flags() const { +_FORCE_INLINE_ int TerraWorldDefault::get_build_flags() const { return _build_flags; } -_FORCE_INLINE_ void VoxelWorldDefault::set_build_flags(const int flags) { +_FORCE_INLINE_ void TerraWorldDefault::set_build_flags(const int flags) { _build_flags = flags; for (int i = 0; i < chunk_get_count(); ++i) { - Ref c = chunk_get_index(i); + Ref c = chunk_get_index(i); if (!c.is_valid()) continue; @@ -47,32 +47,32 @@ _FORCE_INLINE_ void VoxelWorldDefault::set_build_flags(const int flags) { } } -float VoxelWorldDefault::get_lod_update_interval() const { +float TerraWorldDefault::get_lod_update_interval() const { return _lod_update_interval; } -void VoxelWorldDefault::set_lod_update_interval(const float value) { +void TerraWorldDefault::set_lod_update_interval(const float value) { _lod_update_interval = value; } -int VoxelWorldDefault::get_num_lods() const { +int TerraWorldDefault::get_num_lods() const { return _num_lods; } -void VoxelWorldDefault::set_num_lods(const int value) { +void TerraWorldDefault::set_num_lods(const int value) { _num_lods = value; } -void VoxelWorldDefault::update_lods() { +void TerraWorldDefault::update_lods() { call("_update_lods"); } -int VoxelWorldDefault::get_chunk_lod_falloff() const { +int TerraWorldDefault::get_chunk_lod_falloff() const { return _chunk_lod_falloff; } -void VoxelWorldDefault::set_chunk_lod_falloff(const int value) { +void TerraWorldDefault::set_chunk_lod_falloff(const int value) { _chunk_lod_falloff = value; } -PoolColorArray VoxelWorldDefault::get_vertex_colors(const Transform &transform, const PoolVector3Array &vertices, const float base_light_value, const float ao_strength) { +PoolColorArray TerraWorldDefault::get_vertex_colors(const Transform &transform, const PoolVector3Array &vertices, const float base_light_value, const float ao_strength) { PoolColorArray arr; arr.resize(vertices.size()); @@ -102,16 +102,16 @@ PoolColorArray VoxelWorldDefault::get_vertex_colors(const Transform &transform, bz += get_chunk_size_z(); } - Ref chunk = chunk_get(x, y, z); + Ref chunk = chunk_get(x, y, z); if (chunk.is_valid()) { Color light = Color( - chunk->get_voxel(bx, by, bz, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, - chunk->get_voxel(bx, by, bz, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, - chunk->get_voxel(bx, by, bz, VoxelChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); + chunk->get_voxel(bx, by, bz, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_R) / 255.0, + chunk->get_voxel(bx, by, bz, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_G) / 255.0, + chunk->get_voxel(bx, by, bz, TerraChunkDefault::DEFAULT_CHANNEL_LIGHT_COLOR_B) / 255.0); - float ao = (chunk->get_voxel(bx, by, bz, VoxelChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * ao_strength; - float rao = chunk->get_voxel(bx, by, bz, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; + float ao = (chunk->get_voxel(bx, by, bz, TerraChunkDefault::DEFAULT_CHANNEL_AO) / 255.0) * ao_strength; + float rao = chunk->get_voxel(bx, by, bz, TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO) / 255.0; ao += rao; @@ -136,7 +136,7 @@ PoolColorArray VoxelWorldDefault::get_vertex_colors(const Transform &transform, return arr; } -void VoxelWorldDefault::_update_lods() { +void TerraWorldDefault::_update_lods() { if (!get_player() || !INSTANCE_VALIDATE(get_player())) { return; } @@ -151,7 +151,7 @@ void VoxelWorldDefault::_update_lods() { int ppz = int(ppos.z / get_chunk_size_z() / get_voxel_scale()); for (int i = 0; i < chunk_get_count(); ++i) { - Ref c = chunk_get_index(i); + Ref c = chunk_get_index(i); if (!c.is_valid()) continue; @@ -172,79 +172,79 @@ void VoxelWorldDefault::_update_lods() { } } -Ref VoxelWorldDefault::_create_chunk(int x, int y, int z, Ref chunk) { +Ref TerraWorldDefault::_create_chunk(int x, int y, int z, Ref chunk) { if (!chunk.is_valid()) { - chunk = Ref(memnew(VoxelChunkDefault)); + chunk = Ref(memnew(TerraChunkDefault)); } if (chunk->job_get_count() == 0) { - Ref tj; + Ref tj; tj.instance(); - Ref lj; + Ref lj; lj.instance(); - Ref pj; + Ref pj; pj.instance(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherDefault))); + pj->set_prop_mesher(Ref(memnew(TerraMesherDefault))); chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); } - Ref vcd = chunk; + Ref vcd = chunk; if (vcd.is_valid()) { vcd->set_build_flags(_build_flags); vcd->set_lod_num(_num_lods); } - return VoxelWorld::_create_chunk(x, y, z, chunk); + return TerraWorld::_create_chunk(x, y, z, chunk); } -void VoxelWorldDefault::_chunk_added(Ref chunk) { - Ref c = chunk; +void TerraWorldDefault::_chunk_added(Ref chunk) { + Ref c = chunk; if (c.is_valid()) { c->set_build_flags(_build_flags); } } -int VoxelWorldDefault::_get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) { +int TerraWorldDefault::_get_channel_index_info(const TerraWorld::ChannelTypeInfo channel_type) { switch (channel_type) { case CHANNEL_TYPE_INFO_TYPE: - return VoxelChunkDefault::DEFAULT_CHANNEL_TYPE; + return TerraChunkDefault::DEFAULT_CHANNEL_TYPE; case CHANNEL_TYPE_INFO_ISOLEVEL: - return VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL; + return TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL; case CHANNEL_TYPE_INFO_LIQUID_FLOW: - return VoxelChunkDefault::DEFAULT_CHANNEL_LIQUID_FLOW; + return TerraChunkDefault::DEFAULT_CHANNEL_LIQUID_FLOW; default: return -1; } } -VoxelWorldDefault::VoxelWorldDefault() { +TerraWorldDefault::TerraWorldDefault() { _chunk_lod_falloff = 2; _lod_update_timer = 0; _lod_update_interval = 0.5; - _build_flags = VoxelChunkDefault::BUILD_FLAG_CREATE_COLLIDER | VoxelChunkDefault::BUILD_FLAG_CREATE_LODS; + _build_flags = TerraChunkDefault::BUILD_FLAG_CREATE_COLLIDER | TerraChunkDefault::BUILD_FLAG_CREATE_LODS; _num_lods = 4; set_data_margin_start(1); set_data_margin_end(1); } -VoxelWorldDefault ::~VoxelWorldDefault() { +TerraWorldDefault ::~TerraWorldDefault() { } /* -void VoxelWorldDefault::_notification(int p_what) { - VoxelWorld::_notification(p_what); +void TerraWorldDefault::_notification(int p_what) { + TerraWorld::_notification(p_what); switch (p_what) { case NOTIFICATION_INTERNAL_PROCESS: { - if ((get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) == 0) + if ((get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_LODS) == 0) return; if (!get_player()) { @@ -267,28 +267,28 @@ void VoxelWorldDefault::_notification(int p_what) { } }*/ -void VoxelWorldDefault::_bind_methods() { - ClassDB::bind_method(D_METHOD("_chunk_added", "chunk"), &VoxelWorldDefault::_chunk_added); +void TerraWorldDefault::_bind_methods() { + ClassDB::bind_method(D_METHOD("_chunk_added", "chunk"), &TerraWorldDefault::_chunk_added); - ClassDB::bind_method(D_METHOD("get_build_flags"), &VoxelWorldDefault::get_build_flags); - ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &VoxelWorldDefault::set_build_flags); - ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, VoxelChunkDefault::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); + ClassDB::bind_method(D_METHOD("get_build_flags"), &TerraWorldDefault::get_build_flags); + ClassDB::bind_method(D_METHOD("set_build_flags", "value"), &TerraWorldDefault::set_build_flags); + ADD_PROPERTY(PropertyInfo(Variant::INT, "build_flags", PROPERTY_HINT_FLAGS, TerraChunkDefault::BINDING_STRING_BUILD_FLAGS), "set_build_flags", "get_build_flags"); - ClassDB::bind_method(D_METHOD("get_lod_update_interval"), &VoxelWorldDefault::get_lod_update_interval); - ClassDB::bind_method(D_METHOD("set_lod_update_interval", "value"), &VoxelWorldDefault::set_lod_update_interval); + ClassDB::bind_method(D_METHOD("get_lod_update_interval"), &TerraWorldDefault::get_lod_update_interval); + ClassDB::bind_method(D_METHOD("set_lod_update_interval", "value"), &TerraWorldDefault::set_lod_update_interval); ADD_PROPERTY(PropertyInfo(Variant::REAL, "lod_update_interval"), "set_lod_update_interval", "get_lod_update_interval"); - ClassDB::bind_method(D_METHOD("get_chunk_lod_falloff"), &VoxelWorldDefault::get_chunk_lod_falloff); - ClassDB::bind_method(D_METHOD("set_chunk_lod_falloff", "value"), &VoxelWorldDefault::set_chunk_lod_falloff); + ClassDB::bind_method(D_METHOD("get_chunk_lod_falloff"), &TerraWorldDefault::get_chunk_lod_falloff); + ClassDB::bind_method(D_METHOD("set_chunk_lod_falloff", "value"), &TerraWorldDefault::set_chunk_lod_falloff); ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_lod_falloff"), "set_chunk_lod_falloff", "get_chunk_lod_falloff"); - ClassDB::bind_method(D_METHOD("get_num_lods"), &VoxelWorldDefault::get_num_lods); - ClassDB::bind_method(D_METHOD("set_num_lods", "value"), &VoxelWorldDefault::set_num_lods); + ClassDB::bind_method(D_METHOD("get_num_lods"), &TerraWorldDefault::get_num_lods); + ClassDB::bind_method(D_METHOD("set_num_lods", "value"), &TerraWorldDefault::set_num_lods); ADD_PROPERTY(PropertyInfo(Variant::INT, "num_lods"), "set_num_lods", "get_num_lods"); BIND_VMETHOD(MethodInfo("_update_lods")); - ClassDB::bind_method(D_METHOD("update_lods"), &VoxelWorldDefault::update_lods); - ClassDB::bind_method(D_METHOD("_update_lods"), &VoxelWorldDefault::_update_lods); + ClassDB::bind_method(D_METHOD("update_lods"), &TerraWorldDefault::update_lods); + ClassDB::bind_method(D_METHOD("_update_lods"), &TerraWorldDefault::_update_lods); - ClassDB::bind_method(D_METHOD("get_vertex_colors", "transform", "vertices", "base_light_value", "ao_strength"), &VoxelWorldDefault::get_vertex_colors, DEFVAL(0.45), DEFVAL(0.2)); + ClassDB::bind_method(D_METHOD("get_vertex_colors", "transform", "vertices", "base_light_value", "ao_strength"), &TerraWorldDefault::get_vertex_colors, DEFVAL(0.45), DEFVAL(0.2)); } \ No newline at end of file diff --git a/world/default/voxel_world_default.h b/world/default/voxel_world_default.h index fa45bf3..cee47e7 100644 --- a/world/default/voxel_world_default.h +++ b/world/default/voxel_world_default.h @@ -20,13 +20,13 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_DEFAULT_H -#define VOXEL_WORLD_DEFAULT_H +#ifndef TERRA_WORLD_DEFAULT_H +#define TERRA_WORLD_DEFAULT_H #include "../voxel_world.h" -class VoxelWorldDefault : public VoxelWorld { - GDCLASS(VoxelWorldDefault, VoxelWorld); +class TerraWorldDefault : public TerraWorld { + GDCLASS(TerraWorldDefault, TerraWorld); public: int get_build_flags() const; @@ -45,13 +45,13 @@ public: PoolColorArray get_vertex_colors(const Transform &transform, const PoolVector3Array &vertices, const float base_light_value = 0.45, const float ao_strength = 0.2); - VoxelWorldDefault(); - ~VoxelWorldDefault(); + TerraWorldDefault(); + ~TerraWorldDefault(); protected: void _update_lods(); - Ref _create_chunk(int x, int y, int z, Ref p_chunk); - virtual void _chunk_added(Ref chunk); + Ref _create_chunk(int x, int y, int z, Ref p_chunk); + virtual void _chunk_added(Ref chunk); int _get_channel_index_info(const ChannelTypeInfo channel_type); //virtual void _notification(int p_what); diff --git a/world/jobs/voxel_job.cpp b/world/jobs/voxel_job.cpp index 684bb0e..57c4730 100644 --- a/world/jobs/voxel_job.cpp +++ b/world/jobs/voxel_job.cpp @@ -26,52 +26,52 @@ SOFTWARE. #include "../../../opensimplex/open_simplex_noise.h" -const String VoxelJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; +const String TerraJob::BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE = "Normal,Process,Physics Process"; -VoxelJob::ActiveBuildPhaseType VoxelJob::get_build_phase_type() { +TerraJob::ActiveBuildPhaseType TerraJob::get_build_phase_type() { return _build_phase_type; } -void VoxelJob::set_build_phase_type(VoxelJob::ActiveBuildPhaseType build_phase_type) { +void TerraJob::set_build_phase_type(TerraJob::ActiveBuildPhaseType build_phase_type) { _build_phase_type = build_phase_type; } -void VoxelJob::set_chunk(const Ref &chunk) { +void TerraJob::set_chunk(const Ref &chunk) { _chunk = chunk; _in_tree = true; } -int VoxelJob::get_phase() { +int TerraJob::get_phase() { return _phase; } -void VoxelJob::set_phase(const int phase) { +void TerraJob::set_phase(const int phase) { _phase = phase; } -void VoxelJob::next_phase() { +void TerraJob::next_phase() { ++_phase; } -bool VoxelJob::get_build_done() { +bool TerraJob::get_build_done() { return _build_done; } -void VoxelJob::set_build_done(const bool val) { +void TerraJob::set_build_done(const bool val) { _build_done = val; } -void VoxelJob::next_job() { +void TerraJob::next_job() { _chunk->job_next(); set_build_done(true); } -void VoxelJob::reset() { +void TerraJob::reset() { call("_reset"); } -void VoxelJob::_reset() { +void TerraJob::_reset() { _build_done = false; _phase = 0; } -void VoxelJob::_execute() { +void TerraJob::_execute() { ActiveBuildPhaseType origpt = _build_phase_type; @@ -84,25 +84,25 @@ void VoxelJob::_execute() { } } -void VoxelJob::execute_phase() { +void TerraJob::execute_phase() { call("_execute_phase"); } -void VoxelJob::_execute_phase() { +void TerraJob::_execute_phase() { next_job(); } -void VoxelJob::process(const float delta) { +void TerraJob::process(const float delta) { if (has_method("_process")) call("_process", delta); } -void VoxelJob::physics_process(const float delta) { +void TerraJob::physics_process(const float delta) { if (has_method("_physics_process")) call("_physics_process", delta); } //Data Management functions -void VoxelJob::generate_ao() { +void TerraJob::generate_ao() { ERR_FAIL_COND(!_chunk.is_valid()); int data_size_x = _chunk->get_data_size_x(); @@ -125,14 +125,14 @@ void VoxelJob::generate_ao() { for (int y = margin_start - 1; y < size_y - 1; ++y) { for (int z = margin_start - 1; z < size_z - 1; ++z) { for (int x = margin_start - 1; x < size_x - 1; ++x) { - int current = _chunk->get_voxel(x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + int current = _chunk->get_voxel(x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - int sum = _chunk->get_voxel(x + 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - sum += _chunk->get_voxel(x - 1, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - sum += _chunk->get_voxel(x, y + 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - sum += _chunk->get_voxel(x, y - 1, z, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - sum += _chunk->get_voxel(x, y, z + 1, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); - sum += _chunk->get_voxel(x, y, z - 1, VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + int sum = _chunk->get_voxel(x + 1, y, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + sum += _chunk->get_voxel(x - 1, y, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + sum += _chunk->get_voxel(x, y + 1, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + sum += _chunk->get_voxel(x, y - 1, z, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + sum += _chunk->get_voxel(x, y, z + 1, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + sum += _chunk->get_voxel(x, y, z - 1, TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); sum /= 6; @@ -141,13 +141,13 @@ void VoxelJob::generate_ao() { if (sum < 0) sum = 0; - _chunk->set_voxel(sum, x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_AO); + _chunk->set_voxel(sum, x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_AO); } } } } -void VoxelJob::generate_random_ao(int seed, int octaves, int period, float persistence, float scale_factor) { +void TerraJob::generate_random_ao(int seed, int octaves, int period, float persistence, float scale_factor) { ERR_FAIL_COND(!_chunk.is_valid()); int margin_start = _chunk->get_margin_start(); @@ -182,13 +182,13 @@ void VoxelJob::generate_random_ao(int seed, int octaves, int period, float persi if (val < 0) val = -val; - _chunk->set_voxel(int(val * 255.0), x, y, z, VoxelChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); + _chunk->set_voxel(int(val * 255.0), x, y, z, TerraChunkDefault::DEFAULT_CHANNEL_RANDOM_AO); } } } } -Array VoxelJob::merge_mesh_array(Array arr) const { +Array TerraJob::merge_mesh_array(Array arr) const { ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); PoolVector3Array verts = arr[VisualServer::ARRAY_VERTEX]; @@ -252,7 +252,7 @@ Array VoxelJob::merge_mesh_array(Array arr) const { return arr; } -Array VoxelJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { +Array TerraJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_color) const { ERR_FAIL_COND_V(arr.size() != VisualServer::ARRAY_MAX, arr); ERR_FAIL_COND_V(!tex.is_valid(), arr); @@ -293,7 +293,7 @@ Array VoxelJob::bake_mesh_array_uv(Array arr, Ref tex, const float mul_ return arr; } -void VoxelJob::chunk_exit_tree() { +void TerraJob::chunk_exit_tree() { _in_tree = false; @@ -304,7 +304,7 @@ void VoxelJob::chunk_exit_tree() { } } -VoxelJob::VoxelJob() { +TerraJob::TerraJob() { _in_tree = false; _build_phase_type = BUILD_PHASE_TYPE_NORMAL; @@ -323,138 +323,138 @@ VoxelJob::VoxelJob() { #endif } -VoxelJob::~VoxelJob() { +TerraJob::~TerraJob() { _chunk.unref(); } -void VoxelJob::_bind_methods() { +void TerraJob::_bind_methods() { BIND_VMETHOD(MethodInfo("_process", PropertyInfo(Variant::REAL, "delta"))); BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta"))); - ClassDB::bind_method(D_METHOD("get_build_phase_type"), &VoxelJob::get_build_phase_type); - ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &VoxelJob::set_build_phase_type); + ClassDB::bind_method(D_METHOD("get_build_phase_type"), &TerraJob::get_build_phase_type); + ClassDB::bind_method(D_METHOD("set_build_phase_type", "value"), &TerraJob::set_build_phase_type); ADD_PROPERTY(PropertyInfo(Variant::INT, "build_phase_type", PROPERTY_HINT_ENUM, BINDING_STRING_ACTIVE_BUILD_PHASE_TYPE), "set_build_phase_type", "get_build_phase_type"); - ClassDB::bind_method(D_METHOD("set_chunk", "chunk"), &VoxelJob::set_chunk); + ClassDB::bind_method(D_METHOD("set_chunk", "chunk"), &TerraJob::set_chunk); - ClassDB::bind_method(D_METHOD("get_phase"), &VoxelJob::get_phase); - ClassDB::bind_method(D_METHOD("set_phase", "phase"), &VoxelJob::set_phase); - ClassDB::bind_method(D_METHOD("next_phase"), &VoxelJob::next_phase); + ClassDB::bind_method(D_METHOD("get_phase"), &TerraJob::get_phase); + ClassDB::bind_method(D_METHOD("set_phase", "phase"), &TerraJob::set_phase); + ClassDB::bind_method(D_METHOD("next_phase"), &TerraJob::next_phase); - ClassDB::bind_method(D_METHOD("get_build_done"), &VoxelJob::get_build_done); - ClassDB::bind_method(D_METHOD("set_build_done", "val"), &VoxelJob::set_build_done); + ClassDB::bind_method(D_METHOD("get_build_done"), &TerraJob::get_build_done); + ClassDB::bind_method(D_METHOD("set_build_done", "val"), &TerraJob::set_build_done); - ClassDB::bind_method(D_METHOD("next_job"), &VoxelJob::next_job); + ClassDB::bind_method(D_METHOD("next_job"), &TerraJob::next_job); BIND_VMETHOD(MethodInfo("_reset")); - ClassDB::bind_method(D_METHOD("reset"), &VoxelJob::reset); - ClassDB::bind_method(D_METHOD("_reset"), &VoxelJob::_reset); + ClassDB::bind_method(D_METHOD("reset"), &TerraJob::reset); + ClassDB::bind_method(D_METHOD("_reset"), &TerraJob::_reset); - ClassDB::bind_method(D_METHOD("_execute"), &VoxelJob::_execute); + ClassDB::bind_method(D_METHOD("_execute"), &TerraJob::_execute); BIND_VMETHOD(MethodInfo("_execute_phase")); - ClassDB::bind_method(D_METHOD("execute_phase"), &VoxelJob::execute_phase); - ClassDB::bind_method(D_METHOD("_execute_phase"), &VoxelJob::_execute_phase); + ClassDB::bind_method(D_METHOD("execute_phase"), &TerraJob::execute_phase); + ClassDB::bind_method(D_METHOD("_execute_phase"), &TerraJob::_execute_phase); - ClassDB::bind_method(D_METHOD("generate_ao"), &VoxelJob::generate_ao); - ClassDB::bind_method(D_METHOD("generate_random_ao", "seed", "octaves", "period", "persistence", "scale_factor"), &VoxelJob::generate_random_ao, DEFVAL(4), DEFVAL(30), DEFVAL(0.3), DEFVAL(0.6)); + ClassDB::bind_method(D_METHOD("generate_ao"), &TerraJob::generate_ao); + ClassDB::bind_method(D_METHOD("generate_random_ao", "seed", "octaves", "period", "persistence", "scale_factor"), &TerraJob::generate_random_ao, DEFVAL(4), DEFVAL(30), DEFVAL(0.3), DEFVAL(0.6)); - ClassDB::bind_method(D_METHOD("chunk_exit_tree"), &VoxelJob::chunk_exit_tree); + ClassDB::bind_method(D_METHOD("chunk_exit_tree"), &TerraJob::chunk_exit_tree); #if !THREAD_POOL_PRESENT - ClassDB::bind_method(D_METHOD("get_complete"), &VoxelJob::get_complete); - ClassDB::bind_method(D_METHOD("set_complete", "value"), &VoxelJob::set_complete); + ClassDB::bind_method(D_METHOD("get_complete"), &TerraJob::get_complete); + ClassDB::bind_method(D_METHOD("set_complete", "value"), &TerraJob::set_complete); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "complete"), "set_complete", "get_complete"); - ClassDB::bind_method(D_METHOD("get_start_time"), &VoxelJob::get_start_time); - ClassDB::bind_method(D_METHOD("set_start_time", "value"), &VoxelJob::set_start_time); + ClassDB::bind_method(D_METHOD("get_start_time"), &TerraJob::get_start_time); + ClassDB::bind_method(D_METHOD("set_start_time", "value"), &TerraJob::set_start_time); ADD_PROPERTY(PropertyInfo(Variant::INT, "start_time"), "set_start_time", "get_start_time"); - ClassDB::bind_method(D_METHOD("get_current_run_stage"), &VoxelJob::get_current_run_stage); - ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &VoxelJob::set_current_run_stage); + ClassDB::bind_method(D_METHOD("get_current_run_stage"), &TerraJob::get_current_run_stage); + ClassDB::bind_method(D_METHOD("set_current_run_stage", "value"), &TerraJob::set_current_run_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_run_stage"), "set_current_run_stage", "get_current_run_stage"); - ClassDB::bind_method(D_METHOD("get_stage"), &VoxelJob::get_stage); - ClassDB::bind_method(D_METHOD("set_stage", "value"), &VoxelJob::set_stage); + ClassDB::bind_method(D_METHOD("get_stage"), &TerraJob::get_stage); + ClassDB::bind_method(D_METHOD("set_stage", "value"), &TerraJob::set_stage); ADD_PROPERTY(PropertyInfo(Variant::INT, "stage"), "set_stage", "get_stage"); - ClassDB::bind_method(D_METHOD("get_current_execution_time"), &VoxelJob::get_current_execution_time); + ClassDB::bind_method(D_METHOD("get_current_execution_time"), &TerraJob::get_current_execution_time); - ClassDB::bind_method(D_METHOD("should_do", "just_check"), &VoxelJob::should_do, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("should_return"), &VoxelJob::should_return); + ClassDB::bind_method(D_METHOD("should_do", "just_check"), &TerraJob::should_do, DEFVAL(false)); + ClassDB::bind_method(D_METHOD("should_return"), &TerraJob::should_return); BIND_VMETHOD(MethodInfo("_execute")); - ClassDB::bind_method(D_METHOD("execute"), &VoxelJob::execute); + ClassDB::bind_method(D_METHOD("execute"), &TerraJob::execute); ADD_SIGNAL(MethodInfo("completed")); #endif } #if !THREAD_POOL_PRESENT -bool VoxelJob::get_complete() const { +bool TerraJob::get_complete() const { return _complete; } -void VoxelJob::set_complete(const bool value) { +void TerraJob::set_complete(const bool value) { _complete = value; } -bool VoxelJob::get_cancelled() const { +bool TerraJob::get_cancelled() const { return _cancelled; } -void VoxelJob::set_cancelled(const bool value) { +void TerraJob::set_cancelled(const bool value) { _cancelled = value; } -float VoxelJob::get_max_allocated_time() const { +float TerraJob::get_max_allocated_time() const { return _max_allocated_time; } -void VoxelJob::set_max_allocated_time(const float value) { +void TerraJob::set_max_allocated_time(const float value) { _max_allocated_time = value; } -int VoxelJob::get_start_time() const { +int TerraJob::get_start_time() const { return _start_time; } -void VoxelJob::set_start_time(const int value) { +void TerraJob::set_start_time(const int value) { _start_time = value; } -int VoxelJob::get_current_run_stage() const { +int TerraJob::get_current_run_stage() const { return _current_run_stage; } -void VoxelJob::set_current_run_stage(const int value) { +void TerraJob::set_current_run_stage(const int value) { _current_run_stage = value; } -int VoxelJob::get_stage() const { +int TerraJob::get_stage() const { return _stage; } -void VoxelJob::set_stage(const int value) { +void TerraJob::set_stage(const int value) { _stage = value; } -void VoxelJob::reset_stages() { +void TerraJob::reset_stages() { _current_run_stage = 0; _stage = 0; } -float VoxelJob::get_current_execution_time() { +float TerraJob::get_current_execution_time() { return 0; } -bool VoxelJob::should_do(const bool just_check) { +bool TerraJob::should_do(const bool just_check) { return true; } -bool VoxelJob::should_return() { +bool TerraJob::should_return() { if (_cancelled) return true; return false; } -void VoxelJob::execute() { +void TerraJob::execute() { ERR_FAIL_COND(!has_method("_execute")); call("_execute"); diff --git a/world/jobs/voxel_job.h b/world/jobs/voxel_job.h index 2f00691..63e1a66 100644 --- a/world/jobs/voxel_job.h +++ b/world/jobs/voxel_job.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_JOB_H -#define VOXEL_JOB_H +#ifndef TERRA_JOB_H +#define TERRA_JOB_H #include "scene/resources/texture.h" @@ -45,14 +45,14 @@ SOFTWARE. #define Texture Texture2D #endif -class VoxelChunk; +class TerraChunk; #if THREAD_POOL_PRESENT -class VoxelJob : public ThreadPoolJob { - GDCLASS(VoxelJob, ThreadPoolJob); +class TerraJob : public ThreadPoolJob { + GDCLASS(TerraJob, ThreadPoolJob); #else -class VoxelJob : public Reference { - GDCLASS(VoxelJob, Reference); +class TerraJob : public Reference { + GDCLASS(TerraJob, Reference); #endif public: @@ -66,9 +66,9 @@ public: public: ActiveBuildPhaseType get_build_phase_type(); - void set_build_phase_type(VoxelJob::ActiveBuildPhaseType build_phase_type); + void set_build_phase_type(TerraJob::ActiveBuildPhaseType build_phase_type); - void set_chunk(const Ref &chunk); + void set_chunk(const Ref &chunk); int get_phase(); void set_phase(const int phase); @@ -97,8 +97,8 @@ public: void chunk_exit_tree(); - VoxelJob(); - ~VoxelJob(); + TerraJob(); + ~TerraJob(); protected: static void _bind_methods(); @@ -107,7 +107,7 @@ protected: bool _build_done; int _phase; bool _in_tree; - Ref _chunk; + Ref _chunk; public: #if !THREAD_POOL_PRESENT @@ -150,6 +150,6 @@ private: #endif }; -VARIANT_ENUM_CAST(VoxelJob::ActiveBuildPhaseType); +VARIANT_ENUM_CAST(TerraJob::ActiveBuildPhaseType); #endif diff --git a/world/jobs/voxel_light_job.cpp b/world/jobs/voxel_light_job.cpp index 35298f6..6ffc0df 100644 --- a/world/jobs/voxel_light_job.cpp +++ b/world/jobs/voxel_light_job.cpp @@ -30,21 +30,21 @@ SOFTWARE. #include "../../meshers/voxel_mesher.h" #include "../default/voxel_chunk_default.h" -void VoxelLightJob::phase_light() { - Ref chunk = _chunk; +void TerraLightJob::phase_light() { + Ref chunk = _chunk; - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) - if (!chunk->channel_get(VoxelChunkDefault::DEFAULT_CHANNEL_AO)) + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_GENERATE_AO) != 0) + if (!chunk->channel_get(TerraChunkDefault::DEFAULT_CHANNEL_AO)) generate_ao(); - bool gr = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0; + bool gr = (chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_AUTO_GENERATE_RAO) != 0; - if (!gr && (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) { + if (!gr && (chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) == 0) { next_phase(); return; } - bool bl = (chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_BAKE_LIGHTS) != 0; + bool bl = (chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_BAKE_LIGHTS) != 0; if (bl && should_do()) { chunk->clear_baked_lights(); @@ -71,10 +71,10 @@ void VoxelLightJob::phase_light() { next_phase(); } -void VoxelLightJob::_execute_phase() { +void TerraLightJob::_execute_phase() { ERR_FAIL_COND(!_chunk.is_valid()); - Ref library = _chunk->get_library(); + Ref library = _chunk->get_library(); ERR_FAIL_COND(!library.is_valid()); @@ -83,11 +83,11 @@ void VoxelLightJob::_execute_phase() { next_job(); } -VoxelLightJob::VoxelLightJob() { +TerraLightJob::TerraLightJob() { } -VoxelLightJob::~VoxelLightJob() { +TerraLightJob::~TerraLightJob() { } -void VoxelLightJob::_bind_methods() { +void TerraLightJob::_bind_methods() { } diff --git a/world/jobs/voxel_light_job.h b/world/jobs/voxel_light_job.h index 16e4939..455df17 100644 --- a/world/jobs/voxel_light_job.h +++ b/world/jobs/voxel_light_job.h @@ -20,23 +20,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_LIGHT_JOB_H -#define VOXEL_LIGHT_JOB_H +#ifndef TERRA_LIGHT_JOB_H +#define TERRA_LIGHT_JOB_H #include "voxel_job.h" -class VoxelMesher; +class TerraMesher; -class VoxelLightJob : public VoxelJob { - GDCLASS(VoxelLightJob, VoxelJob); +class TerraLightJob : public TerraJob { + GDCLASS(TerraLightJob, TerraJob); public: void phase_light(); void _execute_phase(); - VoxelLightJob(); - ~VoxelLightJob(); + TerraLightJob(); + ~TerraLightJob(); protected: static void _bind_methods(); diff --git a/world/jobs/voxel_prop_job.cpp b/world/jobs/voxel_prop_job.cpp index 13ae478..0c3e75b 100644 --- a/world/jobs/voxel_prop_job.cpp +++ b/world/jobs/voxel_prop_job.cpp @@ -40,15 +40,15 @@ SOFTWARE. #include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h" #endif -Ref VoxelPropJob::get_prop_mesher() const { +Ref TerraPropJob::get_prop_mesher() const { return _prop_mesher; } -void VoxelPropJob::set_prop_mesher(const Ref &mesher) { +void TerraPropJob::set_prop_mesher(const Ref &mesher) { _prop_mesher = mesher; } -void VoxelPropJob::phase_physics_process() { - Ref chunk = _chunk; +void TerraPropJob::phase_physics_process() { + Ref chunk = _chunk; //TODO this should only update the differences for (int i = 0; i < chunk->collider_get_count(); ++i) { @@ -105,9 +105,9 @@ void VoxelPropJob::phase_physics_process() { next_phase(); } -void VoxelPropJob::phase_prop() { +void TerraPropJob::phase_prop() { #ifdef MESH_DATA_RESOURCE_PRESENT - Ref chunk = _chunk; + Ref chunk = _chunk; if (!get_prop_mesher().is_valid()) { set_complete(true); //So threadpool knows it's done @@ -142,7 +142,7 @@ void VoxelPropJob::phase_prop() { } if (should_do()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { get_prop_mesher()->bake_colors(_chunk); } @@ -152,8 +152,8 @@ void VoxelPropJob::phase_prop() { } if (should_do()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { - VoxelWorldDefault *world = Object::cast_to(chunk->get_voxel_world()); + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { + TerraWorldDefault *world = Object::cast_to(chunk->get_voxel_world()); if (world) { for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { @@ -198,16 +198,16 @@ void VoxelPropJob::phase_prop() { } } - RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + RID mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); if (should_do()) { if (mesh_rid == RID()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, chunk->get_lod_num() + 1); + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) + chunk->meshes_create(TerraChunkDefault::MESH_INDEX_PROP, chunk->get_lod_num() + 1); else - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_PROP, 1); + chunk->meshes_create(TerraChunkDefault::MESH_INDEX_PROP, 1); - mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); } if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) @@ -234,17 +234,17 @@ void VoxelPropJob::phase_prop() { } } - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { if (should_do()) { if (chunk->get_lod_num() >= 1) { //for lod 1 just remove uv2 temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant(); - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->prop_material_get(1).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->prop_material_get(1)->get_rid()); + VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->prop_material_get(1)->get_rid()); } if (should_return()) { @@ -257,10 +257,10 @@ void VoxelPropJob::phase_prop() { Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); temp_mesh_arr = temp_mesh_arr2; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2); if (chunk->get_library()->prop_material_get(2).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->prop_material_get(2)->get_rid()); + VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->prop_material_get(2)->get_rid()); } if (should_return()) { return; @@ -283,10 +283,10 @@ void VoxelPropJob::phase_prop() { temp_mesh_arr = bake_mesh_array_uv(temp_mesh_arr, tex); temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant(); - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->prop_material_get(3).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_PROP, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->prop_material_get(3)->get_rid()); + VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_PROP, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->prop_material_get(3)->get_rid()); } } @@ -303,12 +303,12 @@ void VoxelPropJob::phase_prop() { temp_mesh_arr = fqms->get_arrays(); VisualServer::get_singleton()->mesh_add_surface_from_arrays( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, i), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->prop_material_get(i).is_valid()) VisualServer::get_singleton()->mesh_surface_set_material( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0, + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, i), 0, chunk->get_library()->prop_material_get(i)->get_rid()); } } @@ -327,19 +327,19 @@ void VoxelPropJob::phase_prop() { next_job(); } -void VoxelPropJob::_physics_process(float delta) { +void TerraPropJob::_physics_process(float delta) { if (_phase == 0) phase_physics_process(); } -void VoxelPropJob::_execute_phase() { +void TerraPropJob::_execute_phase() { ERR_FAIL_COND(!_chunk.is_valid()); - Ref library = _chunk->get_library(); + Ref library = _chunk->get_library(); ERR_FAIL_COND(!library.is_valid()); - Ref chunk = _chunk; + Ref chunk = _chunk; if (!chunk.is_valid() #ifdef MESH_DATA_RESOURCE_PRESENT @@ -356,12 +356,12 @@ void VoxelPropJob::_execute_phase() { } else if (_phase > 1) { set_complete(true); //So threadpool knows it's done next_job(); - ERR_FAIL_MSG("VoxelPropJob: _phase is too high!"); + ERR_FAIL_MSG("TerraPropJob: _phase is too high!"); } } -void VoxelPropJob::_reset() { - VoxelJob::_reset(); +void TerraPropJob::_reset() { + TerraJob::_reset(); _build_done = false; _phase = 0; @@ -374,17 +374,17 @@ void VoxelPropJob::_reset() { set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); } -VoxelPropJob::VoxelPropJob() { +TerraPropJob::TerraPropJob() { set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); } -VoxelPropJob::~VoxelPropJob() { +TerraPropJob::~TerraPropJob() { } -void VoxelPropJob::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_prop_mesher"), &VoxelPropJob::get_prop_mesher); - ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &VoxelPropJob::set_prop_mesher); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher", 0), "set_prop_mesher", "get_prop_mesher"); +void TerraPropJob::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_prop_mesher"), &TerraPropJob::get_prop_mesher); + ClassDB::bind_method(D_METHOD("set_prop_mesher", "mesher"), &TerraPropJob::set_prop_mesher); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop_mesher", PROPERTY_HINT_RESOURCE_TYPE, "TerraMesher", 0), "set_prop_mesher", "get_prop_mesher"); - ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &VoxelPropJob::_physics_process); + ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &TerraPropJob::_physics_process); } diff --git a/world/jobs/voxel_prop_job.h b/world/jobs/voxel_prop_job.h index 9d57d1b..32995ff 100644 --- a/world/jobs/voxel_prop_job.h +++ b/world/jobs/voxel_prop_job.h @@ -20,19 +20,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_PROP_JOB_H -#define VOXEL_PROP_JOB_H +#ifndef TERRA_PROP_JOB_H +#define TERRA_PROP_JOB_H #include "voxel_job.h" -class VoxelMesher; +class TerraMesher; -class VoxelPropJob : public VoxelJob { - GDCLASS(VoxelPropJob, VoxelJob); +class TerraPropJob : public TerraJob { + GDCLASS(TerraPropJob, TerraJob); public: - Ref get_prop_mesher() const; - void set_prop_mesher(const Ref &mesher); + Ref get_prop_mesher() const; + void set_prop_mesher(const Ref &mesher); void phase_physics_process(); void phase_prop(); @@ -41,13 +41,13 @@ public: void _execute_phase(); void _reset(); - VoxelPropJob(); - ~VoxelPropJob(); + TerraPropJob(); + ~TerraPropJob(); protected: static void _bind_methods(); - Ref _prop_mesher; + Ref _prop_mesher; Array temp_mesh_arr; }; diff --git a/world/jobs/voxel_terrarin_job.cpp b/world/jobs/voxel_terrarin_job.cpp index 3a9fa71..0eeb553 100644 --- a/world/jobs/voxel_terrarin_job.cpp +++ b/world/jobs/voxel_terrarin_job.cpp @@ -34,53 +34,53 @@ SOFTWARE. #include "../../../mesh_utils/fast_quadratic_mesh_simplifier.h" #endif -Ref VoxelTerrarinJob::get_mesher(int index) const { - ERR_FAIL_INDEX_V(index, _meshers.size(), Ref()); +Ref TerraTerrarinJob::get_mesher(int index) const { + ERR_FAIL_INDEX_V(index, _meshers.size(), Ref()); return _meshers.get(index); } -void VoxelTerrarinJob::set_mesher(int index, const Ref &mesher) { +void TerraTerrarinJob::set_mesher(int index, const Ref &mesher) { ERR_FAIL_INDEX(index, _meshers.size()); _meshers.set(index, mesher); } -void VoxelTerrarinJob::remove_mesher(const int index) { +void TerraTerrarinJob::remove_mesher(const int index) { ERR_FAIL_INDEX(index, _meshers.size()); _meshers.remove(index); } -void VoxelTerrarinJob::add_mesher(const Ref &mesher) { +void TerraTerrarinJob::add_mesher(const Ref &mesher) { _meshers.push_back(mesher); } -int VoxelTerrarinJob::get_mesher_count() const { +int TerraTerrarinJob::get_mesher_count() const { return _meshers.size(); } -Ref VoxelTerrarinJob::get_liquid_mesher(int index) const { - ERR_FAIL_INDEX_V(index, _liquid_meshers.size(), Ref()); +Ref TerraTerrarinJob::get_liquid_mesher(int index) const { + ERR_FAIL_INDEX_V(index, _liquid_meshers.size(), Ref()); return _liquid_meshers.get(index); } -void VoxelTerrarinJob::set_liquid_mesher(int index, const Ref &mesher) { +void TerraTerrarinJob::set_liquid_mesher(int index, const Ref &mesher) { ERR_FAIL_INDEX(index, _liquid_meshers.size()); _liquid_meshers.set(index, mesher); } -void VoxelTerrarinJob::remove_liquid_mesher(const int index) { +void TerraTerrarinJob::remove_liquid_mesher(const int index) { ERR_FAIL_INDEX(index, _liquid_meshers.size()); _liquid_meshers.remove(index); } -void VoxelTerrarinJob::add_liquid_mesher(const Ref &mesher) { +void TerraTerrarinJob::add_liquid_mesher(const Ref &mesher) { _liquid_meshers.push_back(mesher); } -int VoxelTerrarinJob::get_liquid_mesher_count() const { +int TerraTerrarinJob::get_liquid_mesher_count() const { return _liquid_meshers.size(); } -void VoxelTerrarinJob::phase_setup() { +void TerraTerrarinJob::phase_setup() { for (int i = 0; i < _meshers.size(); ++i) { - Ref mesher = _meshers.get(i); + Ref mesher = _meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -89,7 +89,7 @@ void VoxelTerrarinJob::phase_setup() { } for (int i = 0; i < _liquid_meshers.size(); ++i) { - Ref mesher = _liquid_meshers.get(i); + Ref mesher = _liquid_meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -100,7 +100,7 @@ void VoxelTerrarinJob::phase_setup() { next_phase(); } -void VoxelTerrarinJob::phase_terrarin_mesh_setup() { +void TerraTerrarinJob::phase_terrarin_mesh_setup() { int starti = 0; if (has_meta("tms_m")) { @@ -113,7 +113,7 @@ void VoxelTerrarinJob::phase_terrarin_mesh_setup() { return; } - Ref mesher = _meshers.get(i); + Ref mesher = _meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -132,7 +132,7 @@ void VoxelTerrarinJob::phase_terrarin_mesh_setup() { return; } - Ref mesher = _liquid_meshers.get(i); + Ref mesher = _liquid_meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -150,10 +150,10 @@ void VoxelTerrarinJob::phase_terrarin_mesh_setup() { next_phase(); } -void VoxelTerrarinJob::phase_collider() { - Ref chunk = _chunk; +void TerraTerrarinJob::phase_collider() { + Ref chunk = _chunk; - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_COLLIDER) == 0) { + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_COLLIDER) == 0) { next_phase(); return; } @@ -170,7 +170,7 @@ void VoxelTerrarinJob::phase_collider() { return; } - Ref mesher = _meshers.get(i); + Ref mesher = _meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -190,7 +190,7 @@ void VoxelTerrarinJob::phase_collider() { return; } - Ref mesher = _liquid_meshers.get(i); + Ref mesher = _liquid_meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -216,23 +216,23 @@ void VoxelTerrarinJob::phase_collider() { next_phase(); } -void VoxelTerrarinJob::phase_physics_process() { - Ref chunk = _chunk; +void TerraTerrarinJob::phase_physics_process() { + Ref chunk = _chunk; if (temp_arr_collider.size() != 0) { - if (!chunk->meshes_has(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) { - chunk->colliders_create(VoxelChunkDefault::MESH_INDEX_TERRARIN); + if (!chunk->meshes_has(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_BODY)) { + chunk->colliders_create(TerraChunkDefault::MESH_INDEX_TERRARIN); } - PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider); + PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider); temp_arr_collider.resize(0); } if (temp_arr_collider_liquid.size() != 0) { if (Engine::get_singleton()->is_editor_hint()) { - if (!chunk->meshes_has(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_BODY)) { - chunk->colliders_create(VoxelChunkDefault::MESH_INDEX_LIQUID); + if (!chunk->meshes_has(TerraChunkDefault::MESH_INDEX_LIQUID, TerraChunkDefault::MESH_TYPE_INDEX_BODY)) { + chunk->colliders_create(TerraChunkDefault::MESH_INDEX_LIQUID); } } /* @@ -242,7 +242,7 @@ void VoxelTerrarinJob::phase_physics_process() { } }*/ - PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider_liquid); + PhysicsServer::get_singleton()->shape_set_data(chunk->mesh_rid_get(TerraChunkDefault::MESH_INDEX_LIQUID, TerraChunkDefault::MESH_TYPE_INDEX_SHAPE), temp_arr_collider_liquid); temp_arr_collider_liquid.resize(0); } @@ -251,10 +251,10 @@ void VoxelTerrarinJob::phase_physics_process() { next_phase(); } -void VoxelTerrarinJob::phase_terrarin_mesh() { - Ref chunk = _chunk; +void TerraTerrarinJob::phase_terrarin_mesh() { + Ref chunk = _chunk; - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_USE_LIGHTING) != 0) { int starti = 0; if (has_meta("bptm_ulm")) { @@ -266,7 +266,7 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { set_meta("bptm_ulm", i); } - Ref mesher = _meshers.get(i); + Ref mesher = _meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -284,7 +284,7 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { set_meta("bptm_ullm", i); } - Ref mesher = _liquid_meshers.get(i); + Ref mesher = _liquid_meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); @@ -298,13 +298,13 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { starti = get_meta("bptm_mm"); } - Ref mesher; + Ref mesher; for (int i = starti; i < _meshers.size(); ++i) { if (should_return()) { set_meta("bptm_mm", i); } - Ref m = _meshers.get(i); + Ref m = _meshers.get(i); ERR_CONTINUE(!m.is_valid()); @@ -326,13 +326,13 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { starti = get_meta("bptm_lmm"); } - Ref liquid_mesher; + Ref liquid_mesher; for (int i = starti; i < _liquid_meshers.size(); ++i) { if (should_return()) { set_meta("bptm_lmm", i); } - Ref m = _liquid_meshers.get(i); + Ref m = _liquid_meshers.get(i); ERR_CONTINUE(!m.is_valid()); @@ -378,16 +378,16 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { } } - RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + RID mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); if (should_do()) { if (mesh_rid == RID()) { - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_TERRARIN, chunk->get_lod_num() + 1); + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) + chunk->meshes_create(TerraChunkDefault::MESH_INDEX_TERRARIN, chunk->get_lod_num() + 1); else - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_TERRARIN, 1); + chunk->meshes_create(TerraChunkDefault::MESH_INDEX_TERRARIN, 1); - mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); } if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) @@ -413,16 +413,16 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { } } - if ((chunk->get_build_flags() & VoxelChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { + if ((chunk->get_build_flags() & TerraChunkDefault::BUILD_FLAG_CREATE_LODS) != 0) { if (should_do()) { if (chunk->get_lod_num() >= 1) { //for lod 1 just remove uv2 temp_mesh_arr[VisualServer::ARRAY_TEX_UV2] = Variant(); - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 1), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->material_get(1).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->material_get(1)->get_rid()); + VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 1), 0, chunk->get_library()->material_get(1)->get_rid()); } if (should_return()) { return; @@ -434,10 +434,10 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { Array temp_mesh_arr2 = merge_mesh_array(temp_mesh_arr); temp_mesh_arr = temp_mesh_arr2; - VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2); + VisualServer::get_singleton()->mesh_add_surface_from_arrays(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 2), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr2); if (chunk->get_library()->material_get(2).is_valid()) - VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->material_get(2)->get_rid()); + VisualServer::get_singleton()->mesh_surface_set_material(chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 2), 0, chunk->get_library()->material_get(2)->get_rid()); } if (should_return()) { @@ -462,12 +462,12 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { temp_mesh_arr[VisualServer::ARRAY_TEX_UV] = Variant(); VisualServer::get_singleton()->mesh_add_surface_from_arrays( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 3), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->material_get(3).is_valid()) VisualServer::get_singleton()->mesh_surface_set_material( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 3), 0, chunk->get_library()->material_get(3)->get_rid()); } } @@ -490,12 +490,12 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { temp_mesh_arr = fqms->get_arrays(); VisualServer::get_singleton()->mesh_add_surface_from_arrays( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, i), VisualServer::PRIMITIVE_TRIANGLES, temp_mesh_arr); if (chunk->get_library()->material_get(i).is_valid()) VisualServer::get_singleton()->mesh_surface_set_material( - chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_TERRARIN, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, i), 0, + chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_TERRARIN, TerraChunkDefault::MESH_TYPE_INDEX_MESH, i), 0, chunk->get_library()->material_get(i)->get_rid()); } } @@ -517,13 +517,13 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { } } - RID mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + RID mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_LIQUID, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); if (should_do()) { if (mesh_rid == RID()) { - chunk->meshes_create(VoxelChunkDefault::MESH_INDEX_LIQUID, 1); + chunk->meshes_create(TerraChunkDefault::MESH_INDEX_LIQUID, 1); - mesh_rid = chunk->mesh_rid_get_index(VoxelChunkDefault::MESH_INDEX_LIQUID, VoxelChunkDefault::MESH_TYPE_INDEX_MESH, 0); + mesh_rid = chunk->mesh_rid_get_index(TerraChunkDefault::MESH_INDEX_LIQUID, TerraChunkDefault::MESH_TYPE_INDEX_MESH, 0); } if (VS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) @@ -570,16 +570,16 @@ void VoxelTerrarinJob::phase_terrarin_mesh() { next_phase(); } -void VoxelTerrarinJob::phase_finalize() { +void TerraTerrarinJob::phase_finalize() { set_complete(true); //So threadpool knows it's done next_job(); } -void VoxelTerrarinJob::_execute_phase() { +void TerraTerrarinJob::_execute_phase() { ERR_FAIL_COND(!_chunk.is_valid()); - Ref library = _chunk->get_library(); + Ref library = _chunk->get_library(); ERR_FAIL_COND(!library.is_valid()); @@ -596,25 +596,25 @@ void VoxelTerrarinJob::_execute_phase() { } else if (_phase > 5) { set_complete(true); //So threadpool knows it's done next_job(); - ERR_FAIL_MSG("VoxelTerrarinJob: _phase is too high!"); + ERR_FAIL_MSG("TerraTerrarinJob: _phase is too high!"); } } -void VoxelTerrarinJob::_reset() { - VoxelJob::_reset(); +void TerraTerrarinJob::_reset() { + TerraJob::_reset(); _build_done = false; _phase = 0; for (int i = 0; i < _meshers.size(); ++i) { - Ref mesher = _meshers.get(i); + Ref mesher = _meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); mesher->set_voxel_scale(_chunk->get_voxel_scale()); - Ref chunk = _chunk; - Ref md = mesher; + Ref chunk = _chunk; + Ref md = mesher; if (chunk.is_valid() && md.is_valid()) { md->set_build_flags(chunk->get_build_flags()); @@ -622,14 +622,14 @@ void VoxelTerrarinJob::_reset() { } for (int i = 0; i < _liquid_meshers.size(); ++i) { - Ref mesher = _liquid_meshers.get(i); + Ref mesher = _liquid_meshers.get(i); ERR_CONTINUE(!mesher.is_valid()); mesher->set_voxel_scale(_chunk->get_voxel_scale()); - Ref chunk = _chunk; - Ref md = mesher; + Ref chunk = _chunk; + Ref md = mesher; if (chunk.is_valid() && md.is_valid()) { md->set_build_flags(chunk->get_build_flags()); @@ -637,31 +637,31 @@ void VoxelTerrarinJob::_reset() { } } -void VoxelTerrarinJob::_physics_process(float delta) { +void TerraTerrarinJob::_physics_process(float delta) { if (_phase == 3) phase_physics_process(); } -VoxelTerrarinJob::VoxelTerrarinJob() { +TerraTerrarinJob::TerraTerrarinJob() { } -VoxelTerrarinJob::~VoxelTerrarinJob() { +TerraTerrarinJob::~TerraTerrarinJob() { _meshers.clear(); _liquid_meshers.clear(); } -void VoxelTerrarinJob::_bind_methods() { - ClassDB::bind_method(D_METHOD("get_mesher", "index"), &VoxelTerrarinJob::get_mesher); - ClassDB::bind_method(D_METHOD("set_mesher", "index", "mesher"), &VoxelTerrarinJob::set_mesher); - ClassDB::bind_method(D_METHOD("remove_mesher", "index"), &VoxelTerrarinJob::remove_mesher); - ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &VoxelTerrarinJob::add_mesher); - ClassDB::bind_method(D_METHOD("get_mesher_count"), &VoxelTerrarinJob::get_mesher_count); +void TerraTerrarinJob::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_mesher", "index"), &TerraTerrarinJob::get_mesher); + ClassDB::bind_method(D_METHOD("set_mesher", "index", "mesher"), &TerraTerrarinJob::set_mesher); + ClassDB::bind_method(D_METHOD("remove_mesher", "index"), &TerraTerrarinJob::remove_mesher); + ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &TerraTerrarinJob::add_mesher); + ClassDB::bind_method(D_METHOD("get_mesher_count"), &TerraTerrarinJob::get_mesher_count); - ClassDB::bind_method(D_METHOD("get_liquid_mesher", "index"), &VoxelTerrarinJob::get_liquid_mesher); - ClassDB::bind_method(D_METHOD("set_liquid_mesher", "index", "mesher"), &VoxelTerrarinJob::set_liquid_mesher); - ClassDB::bind_method(D_METHOD("remove_liquid_mesher", "index"), &VoxelTerrarinJob::remove_liquid_mesher); - ClassDB::bind_method(D_METHOD("add_liquid_mesher", "mesher"), &VoxelTerrarinJob::add_liquid_mesher); - ClassDB::bind_method(D_METHOD("get_liquid_mesher_count"), &VoxelTerrarinJob::get_liquid_mesher_count); + ClassDB::bind_method(D_METHOD("get_liquid_mesher", "index"), &TerraTerrarinJob::get_liquid_mesher); + ClassDB::bind_method(D_METHOD("set_liquid_mesher", "index", "mesher"), &TerraTerrarinJob::set_liquid_mesher); + ClassDB::bind_method(D_METHOD("remove_liquid_mesher", "index"), &TerraTerrarinJob::remove_liquid_mesher); + ClassDB::bind_method(D_METHOD("add_liquid_mesher", "mesher"), &TerraTerrarinJob::add_liquid_mesher); + ClassDB::bind_method(D_METHOD("get_liquid_mesher_count"), &TerraTerrarinJob::get_liquid_mesher_count); - ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &VoxelTerrarinJob::_physics_process); + ClassDB::bind_method(D_METHOD("_physics_process", "delta"), &TerraTerrarinJob::_physics_process); } diff --git a/world/jobs/voxel_terrarin_job.h b/world/jobs/voxel_terrarin_job.h index 1d0311f..19f9ff6 100644 --- a/world/jobs/voxel_terrarin_job.h +++ b/world/jobs/voxel_terrarin_job.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_TERRARIN_JOB_H -#define VOXEL_TERRARIN_JOB_H +#ifndef TERRA_TERRARIN_JOB_H +#define TERRA_TERRARIN_JOB_H #include "voxel_job.h" @@ -31,24 +31,24 @@ SOFTWARE. include_pool_vector - class VoxelMesher; + class TerraMesher; -class VoxelTerrarinJob : public VoxelJob { - GDCLASS(VoxelTerrarinJob, VoxelJob); +class TerraTerrarinJob : public TerraJob { + GDCLASS(TerraTerrarinJob, TerraJob); public: //Meshers - Ref get_mesher(const int index) const; - void set_mesher(const int index, const Ref &mesher); + Ref get_mesher(const int index) const; + void set_mesher(const int index, const Ref &mesher); void remove_mesher(const int index); - void add_mesher(const Ref &mesher); + void add_mesher(const Ref &mesher); int get_mesher_count() const; //Liquid Meshers - Ref get_liquid_mesher(const int index) const; - void set_liquid_mesher(const int index, const Ref &mesher); + Ref get_liquid_mesher(const int index) const; + void set_liquid_mesher(const int index, const Ref &mesher); void remove_liquid_mesher(const int index); - void add_liquid_mesher(const Ref &mesher); + void add_liquid_mesher(const Ref &mesher); int get_liquid_mesher_count() const; void phase_setup(); @@ -63,14 +63,14 @@ public: void _reset(); void _physics_process(float delta); - VoxelTerrarinJob(); - ~VoxelTerrarinJob(); + TerraTerrarinJob(); + ~TerraTerrarinJob(); protected: static void _bind_methods(); - Vector> _meshers; - Vector> _liquid_meshers; + Vector> _meshers; + Vector> _liquid_meshers; PoolVector temp_arr_collider; PoolVector temp_arr_collider_liquid; diff --git a/world/marching_cubes/voxel_chunk_marching_cubes.cpp b/world/marching_cubes/voxel_chunk_marching_cubes.cpp index 76031be..0154401 100644 --- a/world/marching_cubes/voxel_chunk_marching_cubes.cpp +++ b/world/marching_cubes/voxel_chunk_marching_cubes.cpp @@ -24,20 +24,20 @@ SOFTWARE. #include "../../defines.h" -VoxelChunkMarchingCubes::VoxelChunkMarchingCubes() { +TerraChunkMarchingCubes::TerraChunkMarchingCubes() { } -VoxelChunkMarchingCubes::~VoxelChunkMarchingCubes() { +TerraChunkMarchingCubes::~TerraChunkMarchingCubes() { } -void VoxelChunkMarchingCubes::_channel_setup() { +void TerraChunkMarchingCubes::_channel_setup() { channel_set_count(MAX_DEFAULT_CHANNELS); } -void VoxelChunkMarchingCubes::_bind_methods() { +void TerraChunkMarchingCubes::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "data_channel"), "channel_set_compressed", "channel_get_compressed", 0); ADD_PROPERTYI(PropertyInfo(Variant::POOL_BYTE_ARRAY, "isolevel_channel"), "channel_set_compressed", "channel_get_compressed", 1); - //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &VoxelChunk::get_channel_compressed); - //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &VoxelChunk::set_channel_compressed); + //ClassDB::bind_method(D_METHOD("get_channel_compressed", "channel_index"), &TerraChunk::get_channel_compressed); + //ClassDB::bind_method(D_METHOD("set_channel_compressed", "channel_index", "array"), &TerraChunk::set_channel_compressed); } diff --git a/world/marching_cubes/voxel_chunk_marching_cubes.h b/world/marching_cubes/voxel_chunk_marching_cubes.h index febd742..dc91cc6 100644 --- a/world/marching_cubes/voxel_chunk_marching_cubes.h +++ b/world/marching_cubes/voxel_chunk_marching_cubes.h @@ -20,17 +20,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_CHUNK_MARCHING_CUBES_H -#define VOXEL_CHUNK_MARCHING_CUBES_H +#ifndef TERRA_CHUNK_MARCHING_CUBES_H +#define TERRA_CHUNK_MARCHING_CUBES_H #include "../default/voxel_chunk_default.h" -class VoxelChunkMarchingCubes : public VoxelChunkDefault { - GDCLASS(VoxelChunkMarchingCubes, VoxelChunkDefault); +class TerraChunkMarchingCubes : public TerraChunkDefault { + GDCLASS(TerraChunkMarchingCubes, TerraChunkDefault); public: - VoxelChunkMarchingCubes(); - ~VoxelChunkMarchingCubes(); + TerraChunkMarchingCubes(); + ~TerraChunkMarchingCubes(); protected: virtual void _channel_setup(); diff --git a/world/marching_cubes/voxel_world_marching_cubes.cpp b/world/marching_cubes/voxel_world_marching_cubes.cpp index 2303e2e..37ba925 100644 --- a/world/marching_cubes/voxel_world_marching_cubes.cpp +++ b/world/marching_cubes/voxel_world_marching_cubes.cpp @@ -29,38 +29,38 @@ SOFTWARE. #include "../jobs/voxel_prop_job.h" #include "../jobs/voxel_terrarin_job.h" -Ref VoxelWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref chunk) { +Ref TerraWorldMarchingCubes::_create_chunk(int x, int y, int z, Ref chunk) { if (!chunk.is_valid()) { - chunk = Ref(memnew(VoxelChunkMarchingCubes)); + chunk = Ref(memnew(TerraChunkMarchingCubes)); } if (chunk->job_get_count() == 0) { - Ref tj; + Ref tj; tj.instance(); - Ref lj; + Ref lj; lj.instance(); - Ref pj; + Ref pj; pj.instance(); - pj->set_prop_mesher(Ref(memnew(VoxelMesherMarchingCubes))); + pj->set_prop_mesher(Ref(memnew(TerraMesherMarchingCubes))); - Ref m = Ref(memnew(VoxelMesherMarchingCubes())); - m->set_channel_index_type(VoxelChunkDefault::DEFAULT_CHANNEL_TYPE); - m->set_channel_index_isolevel(VoxelChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); + Ref m = Ref(memnew(TerraMesherMarchingCubes())); + m->set_channel_index_type(TerraChunkDefault::DEFAULT_CHANNEL_TYPE); + m->set_channel_index_isolevel(TerraChunkDefault::DEFAULT_CHANNEL_ISOLEVEL); tj->add_mesher(m); - //add_liquid_mesher(Ref(memnew(VoxelMesherLiquidMarchingCubes()))); + //add_liquid_mesher(Ref(memnew(TerraMesherLiquidMarchingCubes()))); chunk->job_add(lj); chunk->job_add(tj); chunk->job_add(pj); } - return VoxelWorld::_create_chunk(x, y, z, chunk); + return TerraWorld::_create_chunk(x, y, z, chunk); } -void VoxelWorldMarchingCubes::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { +void TerraWorldMarchingCubes::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { Vector3 pos; Vector3 hp = hit_position; @@ -89,8 +89,8 @@ void VoxelWorldMarchingCubes::_set_voxel_with_tool(const bool mode_add, const Ve pos = (hit_position + (Vector3(0.8, 0.8, 0.8) * -hit_normal * get_voxel_scale())); } - int channel_type = get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_TYPE); - int channel_isolevel = get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_ISOLEVEL); + int channel_type = get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_TYPE); + int channel_isolevel = get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_ISOLEVEL); if (channel_isolevel == -1) { set_voxel_at_world_position(pos, selected_voxel, channel_type); @@ -100,13 +100,13 @@ void VoxelWorldMarchingCubes::_set_voxel_with_tool(const bool mode_add, const Ve } } -VoxelWorldMarchingCubes::VoxelWorldMarchingCubes() { +TerraWorldMarchingCubes::TerraWorldMarchingCubes() { set_data_margin_start(1); set_data_margin_end(2); } -VoxelWorldMarchingCubes ::~VoxelWorldMarchingCubes() { +TerraWorldMarchingCubes ::~TerraWorldMarchingCubes() { } -void VoxelWorldMarchingCubes::_bind_methods() { +void TerraWorldMarchingCubes::_bind_methods() { } \ No newline at end of file diff --git a/world/marching_cubes/voxel_world_marching_cubes.h b/world/marching_cubes/voxel_world_marching_cubes.h index a198072..9193a5e 100644 --- a/world/marching_cubes/voxel_world_marching_cubes.h +++ b/world/marching_cubes/voxel_world_marching_cubes.h @@ -20,20 +20,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_MARCHING_CUBES_H -#define VOXEL_WORLD_MARCHING_CUBES_H +#ifndef TERRA_WORLD_MARCHING_CUBES_H +#define TERRA_WORLD_MARCHING_CUBES_H #include "../default/voxel_world_default.h" -class VoxelWorldMarchingCubes : public VoxelWorldDefault { - GDCLASS(VoxelWorldMarchingCubes, VoxelWorldDefault); +class TerraWorldMarchingCubes : public TerraWorldDefault { + GDCLASS(TerraWorldMarchingCubes, TerraWorldDefault); public: - VoxelWorldMarchingCubes(); - ~VoxelWorldMarchingCubes(); + TerraWorldMarchingCubes(); + ~TerraWorldMarchingCubes(); protected: - Ref _create_chunk(int x, int y, int z, Ref p_chunk); + Ref _create_chunk(int x, int y, int z, Ref p_chunk); void _set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) override; static void _bind_methods(); diff --git a/world/voxel_chunk.cpp b/world/voxel_chunk.cpp index ffd47e8..27b3ad6 100644 --- a/world/voxel_chunk.cpp +++ b/world/voxel_chunk.cpp @@ -35,214 +35,214 @@ SOFTWARE. #include "../../thread_pool/thread_pool.h" #endif -_FORCE_INLINE_ bool VoxelChunk::get_is_build_threaded() const { +_FORCE_INLINE_ bool TerraChunk::get_is_build_threaded() const { return _is_build_threaded; } -_FORCE_INLINE_ void VoxelChunk::set_is_build_threaded(const bool value) { +_FORCE_INLINE_ void TerraChunk::set_is_build_threaded(const bool value) { _is_build_threaded = value; } -_FORCE_INLINE_ bool VoxelChunk::get_process() const { +_FORCE_INLINE_ bool TerraChunk::get_process() const { return _is_processing; } -_FORCE_INLINE_ void VoxelChunk::set_process(const bool value) { +_FORCE_INLINE_ void TerraChunk::set_process(const bool value) { _is_processing = value; } -_FORCE_INLINE_ bool VoxelChunk::get_physics_process() const { +_FORCE_INLINE_ bool TerraChunk::get_physics_process() const { return _is_phisics_processing; } -_FORCE_INLINE_ void VoxelChunk::set_physics_process(const bool value) { +_FORCE_INLINE_ void TerraChunk::set_physics_process(const bool value) { _is_phisics_processing = value; } -bool VoxelChunk::get_visible() const { +bool TerraChunk::get_visible() const { return _is_visible; } -void VoxelChunk::set_visible(const bool value) { +void TerraChunk::set_visible(const bool value) { _is_visible = value; visibility_changed(value); } -_FORCE_INLINE_ bool VoxelChunk::get_is_generating() const { +_FORCE_INLINE_ bool TerraChunk::get_is_generating() const { return _is_generating; } -_FORCE_INLINE_ void VoxelChunk::set_is_generating(const bool value) { +_FORCE_INLINE_ void TerraChunk::set_is_generating(const bool value) { _is_generating = value; } -bool VoxelChunk::is_in_tree() const { +bool TerraChunk::is_in_tree() const { return _is_in_tree; } -_FORCE_INLINE_ bool VoxelChunk::get_dirty() const { +_FORCE_INLINE_ bool TerraChunk::get_dirty() const { return _dirty; } -_FORCE_INLINE_ void VoxelChunk::set_dirty(const bool value) { +_FORCE_INLINE_ void TerraChunk::set_dirty(const bool value) { _dirty = value; } -_FORCE_INLINE_ int VoxelChunk::get_state() const { +_FORCE_INLINE_ int TerraChunk::get_state() const { return _state; } -_FORCE_INLINE_ void VoxelChunk::set_state(const int value) { +_FORCE_INLINE_ void TerraChunk::set_state(const int value) { _state = value; } -_FORCE_INLINE_ int VoxelChunk::get_position_x() const { +_FORCE_INLINE_ int TerraChunk::get_position_x() const { return _position_x; } -void VoxelChunk::set_position_x(const int value) { +void TerraChunk::set_position_x(const int value) { _position_x = value; } -_FORCE_INLINE_ int VoxelChunk::get_position_y() const { +_FORCE_INLINE_ int TerraChunk::get_position_y() const { return _position_y; } -void VoxelChunk::set_position_y(const int value) { +void TerraChunk::set_position_y(const int value) { _position_y = value; } -_FORCE_INLINE_ int VoxelChunk::get_position_z() const { +_FORCE_INLINE_ int TerraChunk::get_position_z() const { return _position_z; } -void VoxelChunk::set_position_z(const int value) { +void TerraChunk::set_position_z(const int value) { _position_z = value; } -_FORCE_INLINE_ Vector3 VoxelChunk::get_position() const { +_FORCE_INLINE_ Vector3 TerraChunk::get_position() const { return Vector3(_position_x, _position_y, _position_z); } -_FORCE_INLINE_ Vector3 VoxelChunk::get_world_position() const { +_FORCE_INLINE_ Vector3 TerraChunk::get_world_position() const { return Vector3(_position_x * _size_x * _voxel_scale, _position_y * _size_y * _voxel_scale, _position_z * _size_z * _voxel_scale); } -_FORCE_INLINE_ Vector3 VoxelChunk::get_world_size() const { +_FORCE_INLINE_ Vector3 TerraChunk::get_world_size() const { return Vector3(_size_x * _voxel_scale, _size_y * _voxel_scale, _size_z * _voxel_scale); } -_FORCE_INLINE_ AABB VoxelChunk::get_world_aabb() const { +_FORCE_INLINE_ AABB TerraChunk::get_world_aabb() const { return AABB(get_world_position(), get_world_size()); } -_FORCE_INLINE_ int VoxelChunk::get_size_x() const { +_FORCE_INLINE_ int TerraChunk::get_size_x() const { return _size_x; } -_FORCE_INLINE_ int VoxelChunk::get_size_y() const { +_FORCE_INLINE_ int TerraChunk::get_size_y() const { return _size_y; } -_FORCE_INLINE_ int VoxelChunk::get_size_z() const { +_FORCE_INLINE_ int TerraChunk::get_size_z() const { return _size_z; } -_FORCE_INLINE_ void VoxelChunk::set_size_x(const int value) { +_FORCE_INLINE_ void TerraChunk::set_size_x(const int value) { _size_x = value; } -_FORCE_INLINE_ void VoxelChunk::set_size_y(const int value) { +_FORCE_INLINE_ void TerraChunk::set_size_y(const int value) { _size_y = value; } -_FORCE_INLINE_ void VoxelChunk::set_size_z(const int value) { +_FORCE_INLINE_ void TerraChunk::set_size_z(const int value) { _size_z = value; } -_FORCE_INLINE_ Vector3 VoxelChunk::get_size() const { +_FORCE_INLINE_ Vector3 TerraChunk::get_size() const { return Vector3(_size_x, _size_y, _size_z); } -_FORCE_INLINE_ int VoxelChunk::get_data_size_x() const { +_FORCE_INLINE_ int TerraChunk::get_data_size_x() const { return _data_size_x; } -_FORCE_INLINE_ int VoxelChunk::get_data_size_y() const { +_FORCE_INLINE_ int TerraChunk::get_data_size_y() const { return _data_size_y; } -_FORCE_INLINE_ int VoxelChunk::get_data_size_z() const { +_FORCE_INLINE_ int TerraChunk::get_data_size_z() const { return _data_size_z; } -_FORCE_INLINE_ void VoxelChunk::set_data_size_x(const int value) { +_FORCE_INLINE_ void TerraChunk::set_data_size_x(const int value) { _data_size_x = value; } -_FORCE_INLINE_ void VoxelChunk::set_data_size_y(const int value) { +_FORCE_INLINE_ void TerraChunk::set_data_size_y(const int value) { _data_size_y = value; } -_FORCE_INLINE_ void VoxelChunk::set_data_size_z(const int value) { +_FORCE_INLINE_ void TerraChunk::set_data_size_z(const int value) { _data_size_z = value; } -void VoxelChunk::set_position(const int x, const int y, const int z) { +void TerraChunk::set_position(const int x, const int y, const int z) { _position_x = x; _position_y = y; _position_z = z; } -_FORCE_INLINE_ int VoxelChunk::get_margin_start() const { +_FORCE_INLINE_ int TerraChunk::get_margin_start() const { return _margin_start; } -_FORCE_INLINE_ int VoxelChunk::get_margin_end() const { +_FORCE_INLINE_ int TerraChunk::get_margin_end() const { return _margin_end; } -_FORCE_INLINE_ void VoxelChunk::set_margin_start(const int value) { +_FORCE_INLINE_ void TerraChunk::set_margin_start(const int value) { _margin_start = value; } -_FORCE_INLINE_ void VoxelChunk::set_margin_end(const int value) { +_FORCE_INLINE_ void TerraChunk::set_margin_end(const int value) { _margin_end = value; } -Ref VoxelChunk::get_library() { +Ref TerraChunk::get_library() { return _library; } -void VoxelChunk::set_library(const Ref &value) { +void TerraChunk::set_library(const Ref &value) { _library = value; } -float VoxelChunk::get_voxel_scale() const { +float TerraChunk::get_voxel_scale() const { return _voxel_scale; } -void VoxelChunk::set_voxel_scale(const float value) { +void TerraChunk::set_voxel_scale(const float value) { _voxel_scale = value; } -VoxelWorld *VoxelChunk::get_voxel_world() const { +TerraWorld *TerraChunk::get_voxel_world() const { return _voxel_world; } -void VoxelChunk::set_voxel_world(VoxelWorld *world) { +void TerraChunk::set_voxel_world(TerraWorld *world) { _voxel_world = world; } -void VoxelChunk::set_voxel_world_bind(Node *world) { +void TerraChunk::set_voxel_world_bind(Node *world) { if (world == NULL) { _voxel_world = NULL; return; } - _voxel_world = Object::cast_to(world); + _voxel_world = Object::cast_to(world); } -Ref VoxelChunk::job_get(int index) const { - ERR_FAIL_INDEX_V(index, _jobs.size(), Ref()); +Ref TerraChunk::job_get(int index) const { + ERR_FAIL_INDEX_V(index, _jobs.size(), Ref()); return _jobs.get(index); } -void VoxelChunk::job_set(int index, const Ref &job) { +void TerraChunk::job_set(int index, const Ref &job) { ERR_FAIL_INDEX(index, _jobs.size()); _jobs.set(index, job); } -void VoxelChunk::job_remove(const int index) { +void TerraChunk::job_remove(const int index) { ERR_FAIL_INDEX(index, _jobs.size()); _jobs.remove(index); } -void VoxelChunk::job_add(const Ref &job) { +void TerraChunk::job_add(const Ref &job) { _jobs.push_back(job); } -int VoxelChunk::job_get_count() const { +int TerraChunk::job_get_count() const { return _jobs.size(); } -int VoxelChunk::job_get_current_index() { +int TerraChunk::job_get_current_index() { return _current_job; } -void VoxelChunk::job_next() { +void TerraChunk::job_next() { _THREAD_SAFE_METHOD_ ++_current_job; @@ -254,7 +254,7 @@ void VoxelChunk::job_next() { return; } - Ref j = _jobs[_current_job]; + Ref j = _jobs[_current_job]; if (!j.is_valid()) { //skip if invalid @@ -264,7 +264,7 @@ void VoxelChunk::job_next() { j->reset(); j->set_complete(false); - if (j->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) { + if (j->get_build_phase_type() == TerraJob::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(j); #else @@ -272,24 +272,24 @@ void VoxelChunk::job_next() { #endif } } -Ref VoxelChunk::job_get_current() { +Ref TerraChunk::job_get_current() { _THREAD_SAFE_METHOD_ if (_current_job < 0 || _current_job >= _jobs.size()) { - return Ref(); + return Ref(); } return _jobs[_current_job]; } -//Voxel Data -void VoxelChunk::channel_setup() { - ERR_FAIL_COND_MSG(!has_method("_channel_setup"), "VoxelChunk: _setup_channels() is missing! Please implement it!"); +//Terra Data +void TerraChunk::channel_setup() { + ERR_FAIL_COND_MSG(!has_method("_channel_setup"), "TerraChunk: _setup_channels() is missing! Please implement it!"); call("_channel_setup"); } -void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) { +void TerraChunk::set_size(const int size_x, const int size_y, const int size_z, const int margin_start, const int margin_end) { if (_size_x == size_x && _size_y == size_y && _size_z == size_z && _margin_start == margin_start && _margin_end == margin_end) { return; } @@ -316,11 +316,11 @@ void VoxelChunk::set_size(const int size_x, const int size_y, const int size_z, _margin_end = margin_end; } -bool VoxelChunk::validate_data_position(const int x, const int y, const int z) const { +bool TerraChunk::validate_data_position(const int x, const int y, const int z) const { return x < _data_size_x && y < _data_size_y && z < _data_size_z; } -uint8_t VoxelChunk::get_voxel(const int p_x, const int p_y, const int p_z, const int p_channel_index) const { +uint8_t TerraChunk::get_voxel(const int p_x, const int p_y, const int p_z, const int p_channel_index) const { int x = p_x + _margin_start; int y = p_y + _margin_start; int z = p_z + _margin_start; @@ -335,7 +335,7 @@ uint8_t VoxelChunk::get_voxel(const int p_x, const int p_y, const int p_z, const return ch[get_data_index(x, y, z)]; } -void VoxelChunk::set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_channel_index) { +void TerraChunk::set_voxel(const uint8_t p_value, const int p_x, const int p_y, const int p_z, const int p_channel_index) { int x = p_x + _margin_start; int y = p_y + _margin_start; int z = p_z + _margin_start; @@ -348,11 +348,11 @@ void VoxelChunk::set_voxel(const uint8_t p_value, const int p_x, const int p_y, ch[get_data_index(x, y, z)] = p_value; } -int VoxelChunk::channel_get_count() const { +int TerraChunk::channel_get_count() const { return _channels.size(); } -void VoxelChunk::channel_set_count(const int count) { +void TerraChunk::channel_set_count(const int count) { if (count == _channels.size()) return; @@ -376,18 +376,18 @@ void VoxelChunk::channel_set_count(const int count) { _channels.set(i, NULL); } } -bool VoxelChunk::channel_is_allocated(const int channel_index) { +bool TerraChunk::channel_is_allocated(const int channel_index) { ERR_FAIL_INDEX_V(channel_index, _channels.size(), false); return _channels[channel_index] != NULL; } -void VoxelChunk::channel_ensure_allocated(const int channel_index, const uint8_t default_value) { +void TerraChunk::channel_ensure_allocated(const int channel_index, const uint8_t default_value) { ERR_FAIL_INDEX(channel_index, _channels.size()); if (_channels[channel_index] == NULL) channel_allocate(channel_index, default_value); } -void VoxelChunk::channel_allocate(const int channel_index, const uint8_t default_value) { +void TerraChunk::channel_allocate(const int channel_index, const uint8_t default_value) { ERR_FAIL_INDEX(channel_index, _channels.size()); if (_channels[channel_index] != NULL) @@ -400,7 +400,7 @@ void VoxelChunk::channel_allocate(const int channel_index, const uint8_t default _channels.set(channel_index, ch); } -void VoxelChunk::channel_fill(const uint8_t value, const int channel_index) { +void TerraChunk::channel_fill(const uint8_t value, const int channel_index) { ERR_FAIL_INDEX(channel_index, _channels.size()); uint8_t *ch = _channels.get(channel_index); @@ -416,7 +416,7 @@ void VoxelChunk::channel_fill(const uint8_t value, const int channel_index) { ch[i] = value; } } -void VoxelChunk::channel_dealloc(const int channel_index) { +void TerraChunk::channel_dealloc(const int channel_index) { ERR_FAIL_INDEX(channel_index, _channels.size()); uint8_t *ch = _channels.get(channel_index); @@ -428,12 +428,12 @@ void VoxelChunk::channel_dealloc(const int channel_index) { } } -uint8_t *VoxelChunk::channel_get(const int channel_index) { +uint8_t *TerraChunk::channel_get(const int channel_index) { ERR_FAIL_INDEX_V(channel_index, _channels.size(), NULL); return _channels.get(channel_index); } -uint8_t *VoxelChunk::channel_get_valid(const int channel_index, const uint8_t default_value) { +uint8_t *TerraChunk::channel_get_valid(const int channel_index, const uint8_t default_value) { ERR_FAIL_INDEX_V(channel_index, _channels.size(), 0); uint8_t *ch = _channels.get(channel_index); @@ -447,7 +447,7 @@ uint8_t *VoxelChunk::channel_get_valid(const int channel_index, const uint8_t de return ch; } -PoolByteArray VoxelChunk::channel_get_array(const int channel_index) const { +PoolByteArray TerraChunk::channel_get_array(const int channel_index) const { PoolByteArray arr; uint32_t size = _data_size_x * _data_size_y * _data_size_z; @@ -468,7 +468,7 @@ PoolByteArray VoxelChunk::channel_get_array(const int channel_index) const { return arr; } -void VoxelChunk::channel_set_array(const int channel_index, const PoolByteArray &array) { +void TerraChunk::channel_set_array(const int channel_index, const PoolByteArray &array) { if (array.size() == 0) return; @@ -490,7 +490,7 @@ void VoxelChunk::channel_set_array(const int channel_index, const PoolByteArray } } -PoolByteArray VoxelChunk::channel_get_compressed(const int channel_index) const { +PoolByteArray TerraChunk::channel_get_compressed(const int channel_index) const { PoolByteArray arr; int size = _data_size_x * _data_size_y * _data_size_z; @@ -519,7 +519,7 @@ PoolByteArray VoxelChunk::channel_get_compressed(const int channel_index) const return arr; } -void VoxelChunk::channel_set_compressed(const int channel_index, const PoolByteArray &data) { +void TerraChunk::channel_set_compressed(const int channel_index, const PoolByteArray &data) { if (data.size() == 0) return; @@ -555,29 +555,29 @@ void VoxelChunk::channel_set_compressed(const int channel_index, const PoolByteA #endif } -_FORCE_INLINE_ int VoxelChunk::get_index(const int x, const int y, const int z) const { +_FORCE_INLINE_ int TerraChunk::get_index(const int x, const int y, const int z) const { return (y + _margin_start) + _data_size_y * ((x + _margin_start) + _data_size_x * (z + _margin_start)); } -_FORCE_INLINE_ int VoxelChunk::get_data_index(const int x, const int y, const int z) const { +_FORCE_INLINE_ int TerraChunk::get_data_index(const int x, const int y, const int z) const { return y + _data_size_y * (x + _data_size_x * z); } -_FORCE_INLINE_ int VoxelChunk::get_data_size() const { +_FORCE_INLINE_ int TerraChunk::get_data_size() const { return _data_size_x * _data_size_y * _data_size_z; } -//Voxel Structures +//Terra Structures -Ref VoxelChunk::voxel_structure_get(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_structures.size(), Ref()); +Ref TerraChunk::voxel_structure_get(const int index) const { + ERR_FAIL_INDEX_V(index, _voxel_structures.size(), Ref()); return _voxel_structures.get(index); } -void VoxelChunk::voxel_structure_add(const Ref &structure) { +void TerraChunk::voxel_structure_add(const Ref &structure) { _voxel_structures.push_back(structure); } -void VoxelChunk::voxel_structure_remove(const Ref &structure) { +void TerraChunk::voxel_structure_remove(const Ref &structure) { if (!structure.is_valid()) return; @@ -586,18 +586,18 @@ void VoxelChunk::voxel_structure_remove(const Ref &structure) { if (index != -1) _voxel_structures.remove(index); } -void VoxelChunk::voxel_structure_remove_index(const int index) { +void TerraChunk::voxel_structure_remove_index(const int index) { ERR_FAIL_INDEX(index, _voxel_structures.size()); _voxel_structures.remove(index); } -void VoxelChunk::voxel_structure_clear() { +void TerraChunk::voxel_structure_clear() { _voxel_structures.clear(); } -int VoxelChunk::voxel_structure_get_count() const { +int TerraChunk::voxel_structure_get_count() const { return _voxel_structures.size(); } -void VoxelChunk::voxel_structure_add_at_position(Ref structure, const Vector3 &world_position) { +void TerraChunk::voxel_structure_add_at_position(Ref structure, const Vector3 &world_position) { ERR_FAIL_COND(!structure.is_valid()); structure->set_position_x(static_cast(world_position.x / _voxel_scale)); @@ -607,20 +607,20 @@ void VoxelChunk::voxel_structure_add_at_position(Ref structure, voxel_structure_add(structure); } -Vector VoxelChunk::voxel_structures_get() { +Vector TerraChunk::voxel_structures_get() { VARIANT_ARRAY_GET(_voxel_structures); } -void VoxelChunk::voxel_structures_set(const Vector &structures) { +void TerraChunk::voxel_structures_set(const Vector &structures) { voxel_structure_clear(); for (int i = 0; i < structures.size(); ++i) { - Ref structure = Ref(structures[i]); + Ref structure = Ref(structures[i]); voxel_structure_add(structure); } } -void VoxelChunk::build() { +void TerraChunk::build() { ERR_FAIL_COND(!INSTANCE_VALIDATE(get_voxel_world())); ERR_FAIL_COND(!get_voxel_world()->is_inside_tree()); ERR_FAIL_COND(!is_in_tree()); @@ -628,7 +628,7 @@ void VoxelChunk::build() { call("_build"); } -void VoxelChunk::_build() { +void TerraChunk::_build() { if (get_is_generating()) { _queued_generation = true; return; @@ -639,36 +639,36 @@ void VoxelChunk::_build() { job_next(); } -void VoxelChunk::clear() { - ERR_FAIL_COND_MSG(!has_method("_clear"), "VoxelChunk: _clear() is missing! Please implement it!"); +void TerraChunk::clear() { + ERR_FAIL_COND_MSG(!has_method("_clear"), "TerraChunk: _clear() is missing! Please implement it!"); call("_clear"); } -void VoxelChunk::finalize_build() { +void TerraChunk::finalize_build() { if (has_method("_finalize_build")) { call("_finalize_build"); } } -void VoxelChunk::bake_lights() { +void TerraChunk::bake_lights() { if (has_method("_bake_lights")) call("_bake_lights"); } -void VoxelChunk::bake_light(Ref light) { +void TerraChunk::bake_light(Ref light) { if (!light.is_valid()) return; if (has_method("_bake_lights")) call("_bake_light", light); } -void VoxelChunk::clear_baked_lights() { +void TerraChunk::clear_baked_lights() { if (has_method("_clear_baked_lights")) call("_clear_baked_lights"); } #if PROPS_PRESENT -void VoxelChunk::prop_add(const Transform &tarnsform, const Ref &prop) { +void TerraChunk::prop_add(const Transform &tarnsform, const Ref &prop) { ERR_FAIL_COND(!prop.is_valid()); PropDataStore s; @@ -677,31 +677,31 @@ void VoxelChunk::prop_add(const Transform &tarnsform, const Ref &prop) _props.push_back(s); } -Ref VoxelChunk::prop_get(int index) { +Ref TerraChunk::prop_get(int index) { ERR_FAIL_INDEX_V(index, _props.size(), Ref()); return _props.get(index).prop; } -Transform VoxelChunk::prop_get_tarnsform(const int index) { +Transform TerraChunk::prop_get_tarnsform(const int index) { ERR_FAIL_INDEX_V(index, _props.size(), Transform()); return _props.get(index).transform; } -int VoxelChunk::prop_get_count() const { +int TerraChunk::prop_get_count() const { return _props.size(); } -void VoxelChunk::prop_remove(const int index) { +void TerraChunk::prop_remove(const int index) { ERR_FAIL_INDEX(index, _props.size()); _props.remove(index); } -void VoxelChunk::props_clear() { +void TerraChunk::props_clear() { _props.clear(); } #endif #if MESH_DATA_RESOURCE_PRESENT -int VoxelChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { +int TerraChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { ERR_FAIL_COND_V(!mesh.is_valid(), 0); int index = _mesh_data_resources.size(); @@ -741,7 +741,7 @@ int VoxelChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref return index; } -int VoxelChunk::mesh_data_resource_add(const Transform &local_transform, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { +int TerraChunk::mesh_data_resource_add(const Transform &local_transform, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { ERR_FAIL_COND_V(!mesh.is_valid(), 0); int index = _mesh_data_resources.size(); @@ -780,86 +780,86 @@ int VoxelChunk::mesh_data_resource_add(const Transform &local_transform, const R return index; } -Ref VoxelChunk::mesh_data_resource_get(const int index) { +Ref TerraChunk::mesh_data_resource_get(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), Ref()); return _mesh_data_resources[index].mesh; } -void VoxelChunk::mesh_data_resource_set(const int index, const Ref &mesh) { +void TerraChunk::mesh_data_resource_set(const int index, const Ref &mesh) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); } -Ref VoxelChunk::mesh_data_resource_get_texture(const int index) { +Ref TerraChunk::mesh_data_resource_get_texture(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), Ref()); return _mesh_data_resources[index].texture; } -void VoxelChunk::mesh_data_resource_set_texture(const int index, const Ref &texture) { +void TerraChunk::mesh_data_resource_set_texture(const int index, const Ref &texture) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.write[index].texture = texture; } -Color VoxelChunk::mesh_data_resource_get_color(const int index) { +Color TerraChunk::mesh_data_resource_get_color(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), Color()); return _mesh_data_resources[index].color; } -void VoxelChunk::mesh_data_resource_set_color(const int index, const Color &color) { +void TerraChunk::mesh_data_resource_set_color(const int index, const Color &color) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.write[index].color = color; } -Rect2 VoxelChunk::mesh_data_resource_get_uv_rect(const int index) { +Rect2 TerraChunk::mesh_data_resource_get_uv_rect(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), Rect2()); return _mesh_data_resources[index].uv_rect; } -void VoxelChunk::mesh_data_resource_set_uv_rect(const int index, const Rect2 &uv_rect) { +void TerraChunk::mesh_data_resource_set_uv_rect(const int index, const Rect2 &uv_rect) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.write[index].uv_rect = uv_rect; } -Transform VoxelChunk::mesh_data_resource_get_transform(const int index) { +Transform TerraChunk::mesh_data_resource_get_transform(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), Transform()); return _mesh_data_resources.write[index].transform; } -void VoxelChunk::mesh_data_resource_set_transform(const int index, const Transform &transform) { +void TerraChunk::mesh_data_resource_set_transform(const int index, const Transform &transform) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.write[index].transform = transform; } -bool VoxelChunk::mesh_data_resource_get_is_inside(const int index) { +bool TerraChunk::mesh_data_resource_get_is_inside(const int index) { ERR_FAIL_INDEX_V(index, _mesh_data_resources.size(), true); return _mesh_data_resources[index].is_inside; } -void VoxelChunk::mesh_data_resource_set_is_inside(const int index, const bool &inside) { +void TerraChunk::mesh_data_resource_set_is_inside(const int index, const bool &inside) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.write[index].is_inside = inside; } -int VoxelChunk::mesh_data_resource_get_count() const { +int TerraChunk::mesh_data_resource_get_count() const { return _mesh_data_resources.size(); } -void VoxelChunk::mesh_data_resource_remove(const int index) { +void TerraChunk::mesh_data_resource_remove(const int index) { ERR_FAIL_INDEX(index, _mesh_data_resources.size()); _mesh_data_resources.remove(index); } -void VoxelChunk::mesh_data_resource_clear() { +void TerraChunk::mesh_data_resource_clear() { _mesh_data_resources.clear(); } #endif -int VoxelChunk::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body) { +int TerraChunk::collider_add(const Transform &local_transform, const Ref &shape, const RID &shape_rid, const RID &body) { ERR_FAIL_COND_V(!shape.is_valid() && shape_rid == RID(), 0); int index = _colliders.size(); @@ -875,130 +875,130 @@ int VoxelChunk::collider_add(const Transform &local_transform, const Ref return index; } -Transform VoxelChunk::collider_get_transform(const int index) { +Transform TerraChunk::collider_get_transform(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Transform()); return _colliders[index].transform; } -void VoxelChunk::collider_set_transform(const int index, const Transform &transform) { +void TerraChunk::collider_set_transform(const int index, const Transform &transform) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].transform = transform; } -Ref VoxelChunk::collider_get_shape(const int index) { +Ref TerraChunk::collider_get_shape(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), Ref()); return _colliders[index].shape; } -void VoxelChunk::collider_set_shape(const int index, const Ref &shape) { +void TerraChunk::collider_set_shape(const int index, const Ref &shape) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].shape = shape; } -RID VoxelChunk::collider_get_shape_rid(const int index) { +RID TerraChunk::collider_get_shape_rid(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].shape_rid; } -void VoxelChunk::collider_set_shape_rid(const int index, const RID &rid) { +void TerraChunk::collider_set_shape_rid(const int index, const RID &rid) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].shape_rid = rid; } -RID VoxelChunk::collider_get_body(const int index) { +RID TerraChunk::collider_get_body(const int index) { ERR_FAIL_INDEX_V(index, _colliders.size(), RID()); return _colliders[index].body; } -void VoxelChunk::collider_set_body(const int index, const RID &rid) { +void TerraChunk::collider_set_body(const int index, const RID &rid) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.write[index].body = rid; } -int VoxelChunk::collider_get_count() const { +int TerraChunk::collider_get_count() const { return _colliders.size(); } -void VoxelChunk::collider_remove(const int index) { +void TerraChunk::collider_remove(const int index) { ERR_FAIL_INDEX(index, _colliders.size()); _colliders.remove(index); } -void VoxelChunk::colliders_clear() { +void TerraChunk::colliders_clear() { _colliders.clear(); } -void VoxelChunk::enter_tree() { +void TerraChunk::enter_tree() { _is_in_tree = true; if (has_method("_enter_tree")) call("_enter_tree"); } -void VoxelChunk::exit_tree() { +void TerraChunk::exit_tree() { _is_in_tree = false; if (has_method("_exit_tree")) call("_exit_tree"); } -void VoxelChunk::process(const float delta) { +void TerraChunk::process(const float delta) { if (has_method("_process")) call("_process", delta); } -void VoxelChunk::physics_process(const float delta) { +void TerraChunk::physics_process(const float delta) { if (has_method("_physics_process")) call("_physics_process", delta); } -void VoxelChunk::world_transform_changed() { +void TerraChunk::world_transform_changed() { call("_world_transform_changed"); } -void VoxelChunk::visibility_changed(const bool visible) { +void TerraChunk::visibility_changed(const bool visible) { if (has_method("_visibility_changed")) call("_visibility_changed", _is_visible); } -void VoxelChunk::world_light_added(const Ref &light) { +void TerraChunk::world_light_added(const Ref &light) { if (has_method("_world_light_added")) call("_world_light_added", light); } -void VoxelChunk::world_light_removed(const Ref &light) { +void TerraChunk::world_light_removed(const Ref &light) { if (has_method("_world_light_removed")) call("_world_light_removed", light); } -void VoxelChunk::generation_process(const float delta) { +void TerraChunk::generation_process(const float delta) { call("_generation_process", delta); } -void VoxelChunk::generation_physics_process(const float delta) { +void TerraChunk::generation_physics_process(const float delta) { call("_generation_physics_process", delta); } -Transform VoxelChunk::get_transform() const { +Transform TerraChunk::get_transform() const { return _transform; } -void VoxelChunk::set_transform(const Transform &transform) { +void TerraChunk::set_transform(const Transform &transform) { _transform = transform; } -Transform VoxelChunk::get_global_transform() const { +Transform TerraChunk::get_global_transform() const { ERR_FAIL_COND_V(!get_voxel_world(), Transform()); return get_voxel_world()->get_global_transform() * _transform; } -Vector3 VoxelChunk::to_local(Vector3 p_global) const { +Vector3 TerraChunk::to_local(Vector3 p_global) const { return get_global_transform().affine_inverse().xform(p_global); } -Vector3 VoxelChunk::to_global(Vector3 p_local) const { +Vector3 TerraChunk::to_global(Vector3 p_local) const { return get_global_transform().xform(p_local); } -VoxelChunk::VoxelChunk() { +TerraChunk::TerraChunk() { _is_build_threaded = false; _is_processing = false; _is_phisics_processing = false; @@ -1008,7 +1008,7 @@ VoxelChunk::VoxelChunk() { _is_generating = false; _dirty = false; - _state = VOXEL_CHUNK_STATE_OK; + _state = TERRA_CHUNK_STATE_OK; _voxel_scale = 1; @@ -1034,7 +1034,7 @@ VoxelChunk::VoxelChunk() { _queued_generation = false; } -VoxelChunk::~VoxelChunk() { +TerraChunk::~TerraChunk() { if (_library.is_valid()) { _library.unref(); } @@ -1064,21 +1064,21 @@ VoxelChunk::~VoxelChunk() { _jobs.clear(); } -void VoxelChunk::_enter_tree() { +void TerraChunk::_enter_tree() { for (int i = 0; i < _jobs.size(); ++i) { - Ref j = _jobs[i]; + Ref j = _jobs[i]; if (j.is_valid()) { - j->set_chunk(Ref(this)); + j->set_chunk(Ref(this)); } } } -void VoxelChunk::_exit_tree() { +void TerraChunk::_exit_tree() { _abort_build = true; for (int i = 0; i < _jobs.size(); ++i) { - Ref j = _jobs[i]; + Ref j = _jobs[i]; if (j.is_valid()) { j->chunk_exit_tree(); @@ -1086,23 +1086,23 @@ void VoxelChunk::_exit_tree() { } } -void VoxelChunk::_generation_process(const float delta) { +void TerraChunk::_generation_process(const float delta) { _THREAD_SAFE_METHOD_ if (_current_job < 0 || _current_job >= _jobs.size()) return; - Ref job = _jobs[_current_job]; + Ref job = _jobs[_current_job]; ERR_FAIL_COND(!job.is_valid()); - if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_PROCESS) { + if (job->get_build_phase_type() == TerraJob::BUILD_PHASE_TYPE_PROCESS) { if (!_voxel_world->can_chunk_do_build_step()) return; job->process(delta); - if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) { + if (job->get_build_phase_type() == TerraJob::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(job); #else @@ -1111,23 +1111,23 @@ void VoxelChunk::_generation_process(const float delta) { } } } -void VoxelChunk::_generation_physics_process(const float delta) { +void TerraChunk::_generation_physics_process(const float delta) { _THREAD_SAFE_METHOD_ if (_current_job < 0 || _current_job >= _jobs.size()) return; - Ref job = _jobs[_current_job]; + Ref job = _jobs[_current_job]; ERR_FAIL_COND(!job.is_valid()); - if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { + if (job->get_build_phase_type() == TerraJob::BUILD_PHASE_TYPE_PHYSICS_PROCESS) { if (!_voxel_world->can_chunk_do_build_step()) return; job->physics_process(delta); - if (job->get_build_phase_type() == VoxelJob::BUILD_PHASE_TYPE_NORMAL) { + if (job->get_build_phase_type() == TerraJob::BUILD_PHASE_TYPE_NORMAL) { #if THREAD_POOL_PRESENT ThreadPool::get_singleton()->add_job(job); #else @@ -1137,7 +1137,7 @@ void VoxelChunk::_generation_physics_process(const float delta) { } } -void VoxelChunk::_world_transform_changed() { +void TerraChunk::_world_transform_changed() { Transform wt; if (_voxel_world != NULL) { @@ -1148,7 +1148,7 @@ void VoxelChunk::_world_transform_changed() { } /* -bool VoxelChunk::_set(const StringName &p_name, const Variant &p_value) { +bool TerraChunk::_set(const StringName &p_name, const Variant &p_value) { String name = p_name; if (name.begins_with("channels/")) { @@ -1170,7 +1170,7 @@ bool VoxelChunk::_set(const StringName &p_name, const Variant &p_value) { return true; } -bool VoxelChunk::_get(const StringName &p_name, Variant &r_ret) const { +bool TerraChunk::_get(const StringName &p_name, Variant &r_ret) const { String name = p_name; if (name.begins_with("channels/")) { @@ -1185,27 +1185,27 @@ bool VoxelChunk::_get(const StringName &p_name, Variant &r_ret) const { return false; } -void VoxelChunk::_get_property_list(List *p_list) const { +void TerraChunk::_get_property_list(List *p_list) const { for (int i = 0; i < _channels.size(); ++i) { p_list->push_back(PropertyInfo(Variant::POOL_BYTE_ARRAY, "channels/" + String::num(i), PROPERTY_HINT_NONE, "", PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_INTERNAL)); } } */ -void VoxelChunk::_bind_methods() { - ADD_SIGNAL(MethodInfo("mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); +void TerraChunk::_bind_methods() { + ADD_SIGNAL(MethodInfo("mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); BIND_VMETHOD(MethodInfo("_mesh_data_resource_added", PropertyInfo(Variant::INT, "index"))); BIND_VMETHOD(MethodInfo("_channel_setup")); BIND_VMETHOD(MethodInfo("_bake_lights")); - BIND_VMETHOD(MethodInfo("_bake_light", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight"))); + BIND_VMETHOD(MethodInfo("_bake_light", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "TerraLight"))); BIND_VMETHOD(MethodInfo("_clear_baked_lights")); - ClassDB::bind_method(D_METHOD("bake_lights"), &VoxelChunk::bake_lights); - ClassDB::bind_method(D_METHOD("bake_light", "light"), &VoxelChunk::bake_light); - ClassDB::bind_method(D_METHOD("clear_baked_lights"), &VoxelChunk::clear_baked_lights); + ClassDB::bind_method(D_METHOD("bake_lights"), &TerraChunk::bake_lights); + ClassDB::bind_method(D_METHOD("bake_light", "light"), &TerraChunk::bake_light); + ClassDB::bind_method(D_METHOD("clear_baked_lights"), &TerraChunk::clear_baked_lights); BIND_VMETHOD(MethodInfo("_enter_tree")); BIND_VMETHOD(MethodInfo("_exit_tree")); @@ -1213,242 +1213,242 @@ void VoxelChunk::_bind_methods() { BIND_VMETHOD(MethodInfo("_physics_process", PropertyInfo(Variant::REAL, "delta"))); BIND_VMETHOD(MethodInfo("_world_transform_changed")); BIND_VMETHOD(MethodInfo("_visibility_changed", PropertyInfo(Variant::BOOL, "visible"))); - BIND_VMETHOD(MethodInfo("_world_light_added", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight"))); - BIND_VMETHOD(MethodInfo("_world_light_removed", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "VoxelLight"))); + BIND_VMETHOD(MethodInfo("_world_light_added", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "TerraLight"))); + BIND_VMETHOD(MethodInfo("_world_light_removed", PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "TerraLight"))); BIND_VMETHOD(MethodInfo("_generation_process", PropertyInfo(Variant::REAL, "delta"))); BIND_VMETHOD(MethodInfo("_generation_physics_process", PropertyInfo(Variant::REAL, "delta"))); BIND_VMETHOD(MethodInfo("_finalize_build")); - ClassDB::bind_method(D_METHOD("enter_tree"), &VoxelChunk::enter_tree); - ClassDB::bind_method(D_METHOD("exit_tree"), &VoxelChunk::exit_tree); - ClassDB::bind_method(D_METHOD("process", "delta"), &VoxelChunk::process); - ClassDB::bind_method(D_METHOD("physics_process", "delta"), &VoxelChunk::physics_process); - ClassDB::bind_method(D_METHOD("world_transform_changed"), &VoxelChunk::world_transform_changed); - ClassDB::bind_method(D_METHOD("visibility_changed", "visible"), &VoxelChunk::visibility_changed); - ClassDB::bind_method(D_METHOD("world_light_added", "light"), &VoxelChunk::world_light_added); - ClassDB::bind_method(D_METHOD("world_light_removed", "light"), &VoxelChunk::world_light_removed); + ClassDB::bind_method(D_METHOD("enter_tree"), &TerraChunk::enter_tree); + ClassDB::bind_method(D_METHOD("exit_tree"), &TerraChunk::exit_tree); + ClassDB::bind_method(D_METHOD("process", "delta"), &TerraChunk::process); + ClassDB::bind_method(D_METHOD("physics_process", "delta"), &TerraChunk::physics_process); + ClassDB::bind_method(D_METHOD("world_transform_changed"), &TerraChunk::world_transform_changed); + ClassDB::bind_method(D_METHOD("visibility_changed", "visible"), &TerraChunk::visibility_changed); + ClassDB::bind_method(D_METHOD("world_light_added", "light"), &TerraChunk::world_light_added); + ClassDB::bind_method(D_METHOD("world_light_removed", "light"), &TerraChunk::world_light_removed); - ClassDB::bind_method(D_METHOD("generation_process", "delta"), &VoxelChunk::generation_process); - ClassDB::bind_method(D_METHOD("generation_physics_process", "delta"), &VoxelChunk::generation_physics_process); + ClassDB::bind_method(D_METHOD("generation_process", "delta"), &TerraChunk::generation_process); + ClassDB::bind_method(D_METHOD("generation_physics_process", "delta"), &TerraChunk::generation_physics_process); - ClassDB::bind_method(D_METHOD("finalize_build"), &VoxelChunk::finalize_build); + ClassDB::bind_method(D_METHOD("finalize_build"), &TerraChunk::finalize_build); - ClassDB::bind_method(D_METHOD("get_process"), &VoxelChunk::get_process); - ClassDB::bind_method(D_METHOD("set_process", "value"), &VoxelChunk::set_process); + ClassDB::bind_method(D_METHOD("get_process"), &TerraChunk::get_process); + ClassDB::bind_method(D_METHOD("set_process", "value"), &TerraChunk::set_process); - ClassDB::bind_method(D_METHOD("get_physics_process"), &VoxelChunk::get_physics_process); - ClassDB::bind_method(D_METHOD("set_physics_process", "value"), &VoxelChunk::set_physics_process); + ClassDB::bind_method(D_METHOD("get_physics_process"), &TerraChunk::get_physics_process); + ClassDB::bind_method(D_METHOD("set_physics_process", "value"), &TerraChunk::set_physics_process); - ClassDB::bind_method(D_METHOD("is_in_tree"), &VoxelChunk::is_in_tree); + ClassDB::bind_method(D_METHOD("is_in_tree"), &TerraChunk::is_in_tree); - ClassDB::bind_method(D_METHOD("get_is_build_threaded"), &VoxelChunk::get_is_build_threaded); - ClassDB::bind_method(D_METHOD("set_is_build_threaded", "value"), &VoxelChunk::set_is_build_threaded); + ClassDB::bind_method(D_METHOD("get_is_build_threaded"), &TerraChunk::get_is_build_threaded); + ClassDB::bind_method(D_METHOD("set_is_build_threaded", "value"), &TerraChunk::set_is_build_threaded); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_build_threaded", PROPERTY_HINT_NONE, "", 0), "set_is_build_threaded", "get_is_build_threaded"); - ClassDB::bind_method(D_METHOD("get_transform"), &VoxelChunk::get_transform); - ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelChunk::set_transform); + ClassDB::bind_method(D_METHOD("get_transform"), &TerraChunk::get_transform); + ClassDB::bind_method(D_METHOD("set_transform", "value"), &TerraChunk::set_transform); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform"); - ClassDB::bind_method(D_METHOD("get_visible"), &VoxelChunk::get_visible); - ClassDB::bind_method(D_METHOD("set_visible", "value"), &VoxelChunk::set_visible); + ClassDB::bind_method(D_METHOD("get_visible"), &TerraChunk::get_visible); + ClassDB::bind_method(D_METHOD("set_visible", "value"), &TerraChunk::set_visible); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "visible"), "set_visible", "get_visible"); - ClassDB::bind_method(D_METHOD("get_is_generating"), &VoxelChunk::get_is_generating); - ClassDB::bind_method(D_METHOD("set_is_generating", "value"), &VoxelChunk::set_is_generating); + ClassDB::bind_method(D_METHOD("get_is_generating"), &TerraChunk::get_is_generating); + ClassDB::bind_method(D_METHOD("set_is_generating", "value"), &TerraChunk::set_is_generating); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "is_generating", PROPERTY_HINT_NONE, "", 0), "set_is_generating", "get_is_generating"); - ClassDB::bind_method(D_METHOD("get_dirty"), &VoxelChunk::get_dirty); - ClassDB::bind_method(D_METHOD("set_dirty", "value"), &VoxelChunk::set_dirty); + ClassDB::bind_method(D_METHOD("get_dirty"), &TerraChunk::get_dirty); + ClassDB::bind_method(D_METHOD("set_dirty", "value"), &TerraChunk::set_dirty); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "dirty", PROPERTY_HINT_NONE, "", 0), "set_dirty", "get_dirty"); - ClassDB::bind_method(D_METHOD("get_state"), &VoxelChunk::get_state); - ClassDB::bind_method(D_METHOD("set_state", "value"), &VoxelChunk::set_state); + ClassDB::bind_method(D_METHOD("get_state"), &TerraChunk::get_state); + ClassDB::bind_method(D_METHOD("set_state", "value"), &TerraChunk::set_state); ADD_PROPERTY(PropertyInfo(Variant::INT, "state", PROPERTY_HINT_NONE, "", 0), "set_state", "get_state"); - ClassDB::bind_method(D_METHOD("get_position_x"), &VoxelChunk::get_position_x); - ClassDB::bind_method(D_METHOD("set_position_x", "value"), &VoxelChunk::set_position_x); + ClassDB::bind_method(D_METHOD("get_position_x"), &TerraChunk::get_position_x); + ClassDB::bind_method(D_METHOD("set_position_x", "value"), &TerraChunk::set_position_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_x"), "set_position_x", "get_position_x"); - ClassDB::bind_method(D_METHOD("get_position_y"), &VoxelChunk::get_position_y); - ClassDB::bind_method(D_METHOD("set_position_y", "value"), &VoxelChunk::set_position_y); + ClassDB::bind_method(D_METHOD("get_position_y"), &TerraChunk::get_position_y); + ClassDB::bind_method(D_METHOD("set_position_y", "value"), &TerraChunk::set_position_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_y"), "set_position_y", "get_position_y"); - ClassDB::bind_method(D_METHOD("get_position_z"), &VoxelChunk::get_position_z); - ClassDB::bind_method(D_METHOD("set_position_z", "value"), &VoxelChunk::set_position_z); + ClassDB::bind_method(D_METHOD("get_position_z"), &TerraChunk::get_position_z); + ClassDB::bind_method(D_METHOD("set_position_z", "value"), &TerraChunk::set_position_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_z"), "set_position_z", "get_position_z"); - ClassDB::bind_method(D_METHOD("get_size_x"), &VoxelChunk::get_size_x); - ClassDB::bind_method(D_METHOD("set_size_x"), &VoxelChunk::set_size_x); + ClassDB::bind_method(D_METHOD("get_size_x"), &TerraChunk::get_size_x); + ClassDB::bind_method(D_METHOD("set_size_x"), &TerraChunk::set_size_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "size_x"), "set_size_x", "get_size_x"); - ClassDB::bind_method(D_METHOD("get_size_y"), &VoxelChunk::get_size_y); - ClassDB::bind_method(D_METHOD("set_size_y"), &VoxelChunk::set_size_y); + ClassDB::bind_method(D_METHOD("get_size_y"), &TerraChunk::get_size_y); + ClassDB::bind_method(D_METHOD("set_size_y"), &TerraChunk::set_size_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "size_y"), "set_size_y", "get_size_y"); - ClassDB::bind_method(D_METHOD("get_size_z"), &VoxelChunk::get_size_z); - ClassDB::bind_method(D_METHOD("set_size_z"), &VoxelChunk::set_size_z); + ClassDB::bind_method(D_METHOD("get_size_z"), &TerraChunk::get_size_z); + ClassDB::bind_method(D_METHOD("set_size_z"), &TerraChunk::set_size_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "size_z"), "set_size_z", "get_size_z"); - ClassDB::bind_method(D_METHOD("get_data_size_x"), &VoxelChunk::get_data_size_x); - ClassDB::bind_method(D_METHOD("set_data_size_x"), &VoxelChunk::set_data_size_x); + ClassDB::bind_method(D_METHOD("get_data_size_x"), &TerraChunk::get_data_size_x); + ClassDB::bind_method(D_METHOD("set_data_size_x"), &TerraChunk::set_data_size_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_size_x"), "set_data_size_x", "get_data_size_x"); - ClassDB::bind_method(D_METHOD("get_data_size_y"), &VoxelChunk::get_data_size_y); - ClassDB::bind_method(D_METHOD("set_data_size_y"), &VoxelChunk::set_data_size_y); + ClassDB::bind_method(D_METHOD("get_data_size_y"), &TerraChunk::get_data_size_y); + ClassDB::bind_method(D_METHOD("set_data_size_y"), &TerraChunk::set_data_size_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_size_y"), "set_data_size_y", "get_data_size_y"); - ClassDB::bind_method(D_METHOD("get_data_size_z"), &VoxelChunk::get_data_size_z); - ClassDB::bind_method(D_METHOD("set_data_size_z"), &VoxelChunk::set_data_size_z); + ClassDB::bind_method(D_METHOD("get_data_size_z"), &TerraChunk::get_data_size_z); + ClassDB::bind_method(D_METHOD("set_data_size_z"), &TerraChunk::set_data_size_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_size_z"), "set_data_size_z", "get_data_size_z"); - ClassDB::bind_method(D_METHOD("get_position"), &VoxelChunk::get_position); - ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &VoxelChunk::set_position); + ClassDB::bind_method(D_METHOD("get_position"), &TerraChunk::get_position); + ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &TerraChunk::set_position); - ClassDB::bind_method(D_METHOD("get_world_position"), &VoxelChunk::get_world_position); - ClassDB::bind_method(D_METHOD("get_world_size"), &VoxelChunk::get_world_size); - ClassDB::bind_method(D_METHOD("get_world_aabb"), &VoxelChunk::get_world_aabb); + ClassDB::bind_method(D_METHOD("get_world_position"), &TerraChunk::get_world_position); + ClassDB::bind_method(D_METHOD("get_world_size"), &TerraChunk::get_world_size); + ClassDB::bind_method(D_METHOD("get_world_aabb"), &TerraChunk::get_world_aabb); - ClassDB::bind_method(D_METHOD("get_margin_start"), &VoxelChunk::get_margin_start); - ClassDB::bind_method(D_METHOD("set_margin_start"), &VoxelChunk::set_margin_start); + ClassDB::bind_method(D_METHOD("get_margin_start"), &TerraChunk::get_margin_start); + ClassDB::bind_method(D_METHOD("set_margin_start"), &TerraChunk::set_margin_start); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin_start"), "set_margin_start", "get_margin_start"); - ClassDB::bind_method(D_METHOD("get_margin_end"), &VoxelChunk::get_margin_end); - ClassDB::bind_method(D_METHOD("set_margin_end"), &VoxelChunk::set_margin_end); + ClassDB::bind_method(D_METHOD("get_margin_end"), &TerraChunk::get_margin_end); + ClassDB::bind_method(D_METHOD("set_margin_end"), &TerraChunk::set_margin_end); ADD_PROPERTY(PropertyInfo(Variant::INT, "margin_end"), "set_margin_end", "get_margin_end"); - ClassDB::bind_method(D_METHOD("get_library"), &VoxelChunk::get_library); - ClassDB::bind_method(D_METHOD("set_library", "value"), &VoxelChunk::set_library); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"), "set_library", "get_library"); + ClassDB::bind_method(D_METHOD("get_library"), &TerraChunk::get_library); + ClassDB::bind_method(D_METHOD("set_library", "value"), &TerraChunk::set_library); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"), "set_library", "get_library"); - ClassDB::bind_method(D_METHOD("get_voxel_scale"), &VoxelChunk::get_voxel_scale); - ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &VoxelChunk::set_voxel_scale); + ClassDB::bind_method(D_METHOD("get_voxel_scale"), &TerraChunk::get_voxel_scale); + ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &TerraChunk::set_voxel_scale); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); - ClassDB::bind_method(D_METHOD("job_get", "index"), &VoxelChunk::job_get); - ClassDB::bind_method(D_METHOD("job_set", "index", "job"), &VoxelChunk::job_set); - ClassDB::bind_method(D_METHOD("job_remove", "index"), &VoxelChunk::job_remove); - ClassDB::bind_method(D_METHOD("job_add", "job"), &VoxelChunk::job_add); - ClassDB::bind_method(D_METHOD("job_get_count"), &VoxelChunk::job_get_count); + ClassDB::bind_method(D_METHOD("job_get", "index"), &TerraChunk::job_get); + ClassDB::bind_method(D_METHOD("job_set", "index", "job"), &TerraChunk::job_set); + ClassDB::bind_method(D_METHOD("job_remove", "index"), &TerraChunk::job_remove); + ClassDB::bind_method(D_METHOD("job_add", "job"), &TerraChunk::job_add); + ClassDB::bind_method(D_METHOD("job_get_count"), &TerraChunk::job_get_count); - ClassDB::bind_method(D_METHOD("job_get_current_index"), &VoxelChunk::job_get_current_index); - ClassDB::bind_method(D_METHOD("job_next"), &VoxelChunk::job_next); - ClassDB::bind_method(D_METHOD("job_get_current"), &VoxelChunk::job_get_current); + ClassDB::bind_method(D_METHOD("job_get_current_index"), &TerraChunk::job_get_current_index); + ClassDB::bind_method(D_METHOD("job_next"), &TerraChunk::job_next); + ClassDB::bind_method(D_METHOD("job_get_current"), &TerraChunk::job_get_current); - ClassDB::bind_method(D_METHOD("get_voxel_world"), &VoxelChunk::get_voxel_world); - ClassDB::bind_method(D_METHOD("set_voxel_world", "world"), &VoxelChunk::set_voxel_world_bind); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_world", PROPERTY_HINT_RESOURCE_TYPE, "VoxelWorld", 0), "set_voxel_world", "get_voxel_world"); + ClassDB::bind_method(D_METHOD("get_voxel_world"), &TerraChunk::get_voxel_world); + ClassDB::bind_method(D_METHOD("set_voxel_world", "world"), &TerraChunk::set_voxel_world_bind); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "voxel_world", PROPERTY_HINT_RESOURCE_TYPE, "TerraWorld", 0), "set_voxel_world", "get_voxel_world"); - //Voxel Data - ClassDB::bind_method(D_METHOD("channel_setup"), &VoxelChunk::channel_setup); + //Terra Data + ClassDB::bind_method(D_METHOD("channel_setup"), &TerraChunk::channel_setup); - ClassDB::bind_method(D_METHOD("set_size", "size_x", "size_y", "size_z", "margin_start", "margin_end"), &VoxelChunk::set_size, DEFVAL(0), DEFVAL(0)); + ClassDB::bind_method(D_METHOD("set_size", "size_x", "size_y", "size_z", "margin_start", "margin_end"), &TerraChunk::set_size, DEFVAL(0), DEFVAL(0)); - ClassDB::bind_method(D_METHOD("validate_data_position", "x", "y", "z"), &VoxelChunk::validate_data_position); + ClassDB::bind_method(D_METHOD("validate_data_position", "x", "y", "z"), &TerraChunk::validate_data_position); - ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "index"), &VoxelChunk::get_voxel); - ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "index"), &VoxelChunk::set_voxel); + ClassDB::bind_method(D_METHOD("get_voxel", "x", "y", "z", "index"), &TerraChunk::get_voxel); + ClassDB::bind_method(D_METHOD("set_voxel", "value", "x", "y", "z", "index"), &TerraChunk::set_voxel); - ClassDB::bind_method(D_METHOD("channel_get_count"), &VoxelChunk::channel_get_count); - ClassDB::bind_method(D_METHOD("channel_set_count", "count"), &VoxelChunk::channel_set_count); + ClassDB::bind_method(D_METHOD("channel_get_count"), &TerraChunk::channel_get_count); + ClassDB::bind_method(D_METHOD("channel_set_count", "count"), &TerraChunk::channel_set_count); ADD_PROPERTY(PropertyInfo(Variant::INT, "channel_count"), "channel_set_count", "channel_get_count"); - ClassDB::bind_method(D_METHOD("channel_is_allocated", "index"), &VoxelChunk::channel_is_allocated); - ClassDB::bind_method(D_METHOD("channel_ensure_allocated", "index", "default_value"), &VoxelChunk::channel_ensure_allocated); - ClassDB::bind_method(D_METHOD("channel_allocate", "index", "default_value"), &VoxelChunk::channel_allocate); - ClassDB::bind_method(D_METHOD("channel_fill", "value", "index"), &VoxelChunk::channel_fill); - ClassDB::bind_method(D_METHOD("channel_dealloc", "index"), &VoxelChunk::channel_dealloc); + ClassDB::bind_method(D_METHOD("channel_is_allocated", "index"), &TerraChunk::channel_is_allocated); + ClassDB::bind_method(D_METHOD("channel_ensure_allocated", "index", "default_value"), &TerraChunk::channel_ensure_allocated); + ClassDB::bind_method(D_METHOD("channel_allocate", "index", "default_value"), &TerraChunk::channel_allocate); + ClassDB::bind_method(D_METHOD("channel_fill", "value", "index"), &TerraChunk::channel_fill); + ClassDB::bind_method(D_METHOD("channel_dealloc", "index"), &TerraChunk::channel_dealloc); - ClassDB::bind_method(D_METHOD("channel_get_array", "index"), &VoxelChunk::channel_get_array); - ClassDB::bind_method(D_METHOD("channel_set_array", "index", "array"), &VoxelChunk::channel_set_array); + ClassDB::bind_method(D_METHOD("channel_get_array", "index"), &TerraChunk::channel_get_array); + ClassDB::bind_method(D_METHOD("channel_set_array", "index", "array"), &TerraChunk::channel_set_array); - ClassDB::bind_method(D_METHOD("channel_get_compressed", "index"), &VoxelChunk::channel_get_compressed); - ClassDB::bind_method(D_METHOD("channel_set_compressed", "index", "array"), &VoxelChunk::channel_set_compressed); + ClassDB::bind_method(D_METHOD("channel_get_compressed", "index"), &TerraChunk::channel_get_compressed); + ClassDB::bind_method(D_METHOD("channel_set_compressed", "index", "array"), &TerraChunk::channel_set_compressed); - ClassDB::bind_method(D_METHOD("get_index", "x", "y", "z"), &VoxelChunk::get_index); - ClassDB::bind_method(D_METHOD("get_data_index", "x", "y", "z"), &VoxelChunk::get_data_index); - ClassDB::bind_method(D_METHOD("get_data_size"), &VoxelChunk::get_data_size); + ClassDB::bind_method(D_METHOD("get_index", "x", "y", "z"), &TerraChunk::get_index); + ClassDB::bind_method(D_METHOD("get_data_index", "x", "y", "z"), &TerraChunk::get_data_index); + ClassDB::bind_method(D_METHOD("get_data_size"), &TerraChunk::get_data_size); - ClassDB::bind_method(D_METHOD("voxel_structure_get", "index"), &VoxelChunk::voxel_structure_get); - ClassDB::bind_method(D_METHOD("voxel_structure_add", "structure"), &VoxelChunk::voxel_structure_add); - ClassDB::bind_method(D_METHOD("voxel_structure_remove", "structure"), &VoxelChunk::voxel_structure_remove); - ClassDB::bind_method(D_METHOD("voxel_structure_remove_index", "index"), &VoxelChunk::voxel_structure_remove_index); - ClassDB::bind_method(D_METHOD("voxel_structure_clear"), &VoxelChunk::voxel_structure_clear); - ClassDB::bind_method(D_METHOD("voxel_structure_get_count"), &VoxelChunk::voxel_structure_get_count); - ClassDB::bind_method(D_METHOD("voxel_structure_add_at_position", "structure", "world_position"), &VoxelChunk::voxel_structure_add_at_position); + ClassDB::bind_method(D_METHOD("voxel_structure_get", "index"), &TerraChunk::voxel_structure_get); + ClassDB::bind_method(D_METHOD("voxel_structure_add", "structure"), &TerraChunk::voxel_structure_add); + ClassDB::bind_method(D_METHOD("voxel_structure_remove", "structure"), &TerraChunk::voxel_structure_remove); + ClassDB::bind_method(D_METHOD("voxel_structure_remove_index", "index"), &TerraChunk::voxel_structure_remove_index); + ClassDB::bind_method(D_METHOD("voxel_structure_clear"), &TerraChunk::voxel_structure_clear); + ClassDB::bind_method(D_METHOD("voxel_structure_get_count"), &TerraChunk::voxel_structure_get_count); + ClassDB::bind_method(D_METHOD("voxel_structure_add_at_position", "structure", "world_position"), &TerraChunk::voxel_structure_add_at_position); - ClassDB::bind_method(D_METHOD("voxel_structures_get"), &VoxelChunk::voxel_structures_get); - ClassDB::bind_method(D_METHOD("voxel_structures_set"), &VoxelChunk::voxel_structures_set); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:VoxelStructure", PROPERTY_USAGE_DEFAULT, "VoxelStructure"), "voxel_structures_set", "voxel_structures_get"); + ClassDB::bind_method(D_METHOD("voxel_structures_get"), &TerraChunk::voxel_structures_get); + ClassDB::bind_method(D_METHOD("voxel_structures_set"), &TerraChunk::voxel_structures_set); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:TerraStructure", PROPERTY_USAGE_DEFAULT, "TerraStructure"), "voxel_structures_set", "voxel_structures_get"); //Meshes #if PROPS_PRESENT - ClassDB::bind_method(D_METHOD("prop_add", "prop"), &VoxelChunk::prop_add); - ClassDB::bind_method(D_METHOD("prop_get", "index"), &VoxelChunk::prop_get); - ClassDB::bind_method(D_METHOD("prop_get_count"), &VoxelChunk::prop_get_count); - ClassDB::bind_method(D_METHOD("prop_remove", "index"), &VoxelChunk::prop_remove); - ClassDB::bind_method(D_METHOD("props_clear"), &VoxelChunk::props_clear); + ClassDB::bind_method(D_METHOD("prop_add", "prop"), &TerraChunk::prop_add); + ClassDB::bind_method(D_METHOD("prop_get", "index"), &TerraChunk::prop_get); + ClassDB::bind_method(D_METHOD("prop_get_count"), &TerraChunk::prop_get_count); + ClassDB::bind_method(D_METHOD("prop_remove", "index"), &TerraChunk::prop_remove); + ClassDB::bind_method(D_METHOD("props_clear"), &TerraChunk::props_clear); #endif #if MESH_DATA_RESOURCE_PRESENT - ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &VoxelChunk::mesh_data_resource_addv, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &VoxelChunk::mesh_data_resource_add, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &TerraChunk::mesh_data_resource_addv, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); + ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &TerraChunk::mesh_data_resource_add, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get", "index"), &VoxelChunk::mesh_data_resource_get); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set", "index", "mesh"), &VoxelChunk::mesh_data_resource_set); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get", "index"), &TerraChunk::mesh_data_resource_get); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set", "index", "mesh"), &TerraChunk::mesh_data_resource_set); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_texture", "index"), &VoxelChunk::mesh_data_resource_get_texture); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set_texture", "index", "texture"), &VoxelChunk::mesh_data_resource_set_texture); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_texture", "index"), &TerraChunk::mesh_data_resource_get_texture); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set_texture", "index", "texture"), &TerraChunk::mesh_data_resource_set_texture); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_color", "index"), &VoxelChunk::mesh_data_resource_get_color); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set_color", "index", "color"), &VoxelChunk::mesh_data_resource_set_color); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_color", "index"), &TerraChunk::mesh_data_resource_get_color); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set_color", "index", "color"), &TerraChunk::mesh_data_resource_set_color); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_uv_rect", "index"), &VoxelChunk::mesh_data_resource_get_uv_rect); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set_uv_rect", "index", "uv_rect"), &VoxelChunk::mesh_data_resource_set_uv_rect); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_uv_rect", "index"), &TerraChunk::mesh_data_resource_get_uv_rect); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set_uv_rect", "index", "uv_rect"), &TerraChunk::mesh_data_resource_set_uv_rect); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_transform", "index"), &VoxelChunk::mesh_data_resource_get_transform); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set_transform", "index", "transform"), &VoxelChunk::mesh_data_resource_set_transform); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_transform", "index"), &TerraChunk::mesh_data_resource_get_transform); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set_transform", "index", "transform"), &TerraChunk::mesh_data_resource_set_transform); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_is_inside", "index"), &VoxelChunk::mesh_data_resource_get_is_inside); - ClassDB::bind_method(D_METHOD("mesh_data_resource_set_is_inside", "index", "inside"), &VoxelChunk::mesh_data_resource_set_is_inside); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_is_inside", "index"), &TerraChunk::mesh_data_resource_get_is_inside); + ClassDB::bind_method(D_METHOD("mesh_data_resource_set_is_inside", "index", "inside"), &TerraChunk::mesh_data_resource_set_is_inside); - ClassDB::bind_method(D_METHOD("mesh_data_resource_get_count"), &VoxelChunk::mesh_data_resource_get_count); - ClassDB::bind_method(D_METHOD("mesh_data_resource_remove", "index"), &VoxelChunk::mesh_data_resource_remove); - ClassDB::bind_method(D_METHOD("mesh_data_resource_clear"), &VoxelChunk::mesh_data_resource_clear); + ClassDB::bind_method(D_METHOD("mesh_data_resource_get_count"), &TerraChunk::mesh_data_resource_get_count); + ClassDB::bind_method(D_METHOD("mesh_data_resource_remove", "index"), &TerraChunk::mesh_data_resource_remove); + ClassDB::bind_method(D_METHOD("mesh_data_resource_clear"), &TerraChunk::mesh_data_resource_clear); #endif - ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &VoxelChunk::collider_add, DEFVAL(RID()), DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("collider_add", "local_transform", "shape", "shape_rid", "body"), &TerraChunk::collider_add, DEFVAL(RID()), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("collider_get_transform", "index"), &VoxelChunk::collider_get_transform); - ClassDB::bind_method(D_METHOD("collider_set_transform", "index", "transform"), &VoxelChunk::collider_set_transform); + ClassDB::bind_method(D_METHOD("collider_get_transform", "index"), &TerraChunk::collider_get_transform); + ClassDB::bind_method(D_METHOD("collider_set_transform", "index", "transform"), &TerraChunk::collider_set_transform); - ClassDB::bind_method(D_METHOD("collider_get_shape", "index"), &VoxelChunk::collider_get_shape); - ClassDB::bind_method(D_METHOD("collider_set_shape", "index", "shape"), &VoxelChunk::collider_set_shape); + ClassDB::bind_method(D_METHOD("collider_get_shape", "index"), &TerraChunk::collider_get_shape); + ClassDB::bind_method(D_METHOD("collider_set_shape", "index", "shape"), &TerraChunk::collider_set_shape); - ClassDB::bind_method(D_METHOD("collider_get_shape_rid", "index"), &VoxelChunk::collider_get_shape_rid); - ClassDB::bind_method(D_METHOD("collider_set_shape_rid", "index", "rid"), &VoxelChunk::collider_set_shape_rid); + ClassDB::bind_method(D_METHOD("collider_get_shape_rid", "index"), &TerraChunk::collider_get_shape_rid); + ClassDB::bind_method(D_METHOD("collider_set_shape_rid", "index", "rid"), &TerraChunk::collider_set_shape_rid); - ClassDB::bind_method(D_METHOD("collider_get_body", "index"), &VoxelChunk::collider_get_body); - ClassDB::bind_method(D_METHOD("collider_set_body", "index", "rid"), &VoxelChunk::collider_set_body); + ClassDB::bind_method(D_METHOD("collider_get_body", "index"), &TerraChunk::collider_get_body); + ClassDB::bind_method(D_METHOD("collider_set_body", "index", "rid"), &TerraChunk::collider_set_body); - ClassDB::bind_method(D_METHOD("collider_get_count"), &VoxelChunk::collider_get_count); - ClassDB::bind_method(D_METHOD("collider_remove", "index"), &VoxelChunk::collider_remove); - ClassDB::bind_method(D_METHOD("colliders_clear"), &VoxelChunk::colliders_clear); + ClassDB::bind_method(D_METHOD("collider_get_count"), &TerraChunk::collider_get_count); + ClassDB::bind_method(D_METHOD("collider_remove", "index"), &TerraChunk::collider_remove); + ClassDB::bind_method(D_METHOD("colliders_clear"), &TerraChunk::colliders_clear); BIND_VMETHOD(MethodInfo("_build")); - ClassDB::bind_method(D_METHOD("build"), &VoxelChunk::build); - ClassDB::bind_method(D_METHOD("_build"), &VoxelChunk::_build); + ClassDB::bind_method(D_METHOD("build"), &TerraChunk::build); + ClassDB::bind_method(D_METHOD("_build"), &TerraChunk::_build); - ClassDB::bind_method(D_METHOD("get_global_transform"), &VoxelChunk::get_global_transform); - ClassDB::bind_method(D_METHOD("to_local", "global"), &VoxelChunk::to_local); - ClassDB::bind_method(D_METHOD("to_global", "local"), &VoxelChunk::to_global); + ClassDB::bind_method(D_METHOD("get_global_transform"), &TerraChunk::get_global_transform); + ClassDB::bind_method(D_METHOD("to_local", "global"), &TerraChunk::to_local); + ClassDB::bind_method(D_METHOD("to_global", "local"), &TerraChunk::to_global); - ClassDB::bind_method(D_METHOD("_world_transform_changed"), &VoxelChunk::_world_transform_changed); - ClassDB::bind_method(D_METHOD("_enter_tree"), &VoxelChunk::_enter_tree); - ClassDB::bind_method(D_METHOD("_exit_tree"), &VoxelChunk::_exit_tree); + ClassDB::bind_method(D_METHOD("_world_transform_changed"), &TerraChunk::_world_transform_changed); + ClassDB::bind_method(D_METHOD("_enter_tree"), &TerraChunk::_enter_tree); + ClassDB::bind_method(D_METHOD("_exit_tree"), &TerraChunk::_exit_tree); - ClassDB::bind_method(D_METHOD("_generation_process"), &VoxelChunk::_generation_process); - ClassDB::bind_method(D_METHOD("_generation_physics_process"), &VoxelChunk::_generation_physics_process); + ClassDB::bind_method(D_METHOD("_generation_process"), &TerraChunk::_generation_process); + ClassDB::bind_method(D_METHOD("_generation_physics_process"), &TerraChunk::_generation_physics_process); } diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index 024a31b..5403334 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_CHUNK_H -#define VOXEL_CHUNK_H +#ifndef TERRA_CHUNK_H +#define TERRA_CHUNK_H #include "core/version.h" @@ -68,18 +68,18 @@ include_pool_vector #include "../library/voxelman_library.h" ; //hackfix for a clang format issue -class VoxelJob; -class VoxelWorld; -class VoxelStructure; +class TerraJob; +class TerraWorld; +class TerraStructure; -class VoxelChunk : public Resource { - GDCLASS(VoxelChunk, Resource); +class TerraChunk : public Resource { + GDCLASS(TerraChunk, Resource); _THREAD_SAFE_CLASS_ public: enum { - VOXEL_CHUNK_STATE_OK = 0, + TERRA_CHUNK_STATE_OK = 0, }; public: @@ -141,26 +141,26 @@ public: void set_margin_start(const int value); void set_margin_end(const int value); - Ref get_library(); - void set_library(const Ref &value); + Ref get_library(); + void set_library(const Ref &value); float get_voxel_scale() const; void set_voxel_scale(const float value); - VoxelWorld *get_voxel_world() const; - void set_voxel_world(VoxelWorld *world); + TerraWorld *get_voxel_world() const; + void set_voxel_world(TerraWorld *world); void set_voxel_world_bind(Node *world); //Jobs - Ref job_get(const int index) const; - void job_set(const int index, const Ref &job); + Ref job_get(const int index) const; + void job_set(const int index, const Ref &job); void job_remove(const int index); - void job_add(const Ref &job); + void job_add(const Ref &job); int job_get_count() const; int job_get_current_index(); void job_next(); - Ref job_get_current(); + Ref job_get_current(); //Channels void channel_setup(); @@ -194,14 +194,14 @@ public: int get_data_index(const int x, const int y, const int z) const; int get_data_size() const; - //Voxel Structures - Ref voxel_structure_get(const int index) const; - void voxel_structure_add(const Ref &structure); - void voxel_structure_remove(const Ref &structure); + //Terra Structures + Ref voxel_structure_get(const int index) const; + void voxel_structure_add(const Ref &structure); + void voxel_structure_remove(const Ref &structure); void voxel_structure_remove_index(const int index); void voxel_structure_clear(); int voxel_structure_get_count() const; - void voxel_structure_add_at_position(Ref structure, const Vector3 &world_position); + void voxel_structure_add_at_position(Ref structure, const Vector3 &world_position); Vector voxel_structures_get(); void voxel_structures_set(const Vector &structures); @@ -215,7 +215,7 @@ public: //light Baking void bake_lights(); - void bake_light(Ref light); + void bake_light(Ref light); void clear_baked_lights(); #if PROPS_PRESENT @@ -280,8 +280,8 @@ public: void physics_process(const float delta); void world_transform_changed(); void visibility_changed(const bool visible); - void world_light_added(const Ref &light); - void world_light_removed(const Ref &light); + void world_light_added(const Ref &light); + void world_light_removed(const Ref &light); void generation_process(const float delta); void generation_physics_process(const float delta); @@ -292,8 +292,8 @@ public: Vector3 to_local(Vector3 p_global) const; Vector3 to_global(Vector3 p_local) const; - VoxelChunk(); - ~VoxelChunk(); + TerraChunk(); + ~TerraChunk(); protected: virtual void _enter_tree(); @@ -350,7 +350,7 @@ protected: bool _is_in_tree; - VoxelWorld *_voxel_world; + TerraWorld *_voxel_world; int _position_x; int _position_y; @@ -372,11 +372,11 @@ protected: float _voxel_scale; int _current_job; - Vector > _jobs; + Vector > _jobs; - Ref _library; + Ref _library; - Vector > _voxel_structures; + Vector > _voxel_structures; #if PROPS_PRESENT Vector _props; diff --git a/world/voxel_structure.cpp b/world/voxel_structure.cpp index 713c960..41b091e 100644 --- a/world/voxel_structure.cpp +++ b/world/voxel_structure.cpp @@ -22,88 +22,88 @@ SOFTWARE. #include "voxel_structure.h" -bool VoxelStructure::get_use_aabb() const { +bool TerraStructure::get_use_aabb() const { return _use_aabb; } -void VoxelStructure::set_use_aabb(const bool value) { +void TerraStructure::set_use_aabb(const bool value) { _use_aabb = value; } -AABB VoxelStructure::get_chunk_aabb() const { +AABB TerraStructure::get_chunk_aabb() const { return _chunk_aabb; } -void VoxelStructure::set_chunk_aabb(const AABB &value) { +void TerraStructure::set_chunk_aabb(const AABB &value) { _chunk_aabb = value; } -int VoxelStructure::get_position_x() const { +int TerraStructure::get_position_x() const { return _position_x; } -void VoxelStructure::set_position_x(const int value) { +void TerraStructure::set_position_x(const int value) { _position_x = value; } -int VoxelStructure::get_position_y() const { +int TerraStructure::get_position_y() const { return _position_y; } -void VoxelStructure::set_position_y(const int value) { +void TerraStructure::set_position_y(const int value) { _position_y = value; } -int VoxelStructure::get_position_z() const { +int TerraStructure::get_position_z() const { return _position_z; } -void VoxelStructure::set_position_z(const int value) { +void TerraStructure::set_position_z(const int value) { _position_z = value; } -void VoxelStructure::set_position(const int x, const int y, const int z) { +void TerraStructure::set_position(const int x, const int y, const int z) { _position_x = x; _position_y = y; _position_z = z; } -void VoxelStructure::write_to_chunk(Ref chunk) { +void TerraStructure::write_to_chunk(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (has_method("_write_to_chunk")) call("_write_to_chunk", chunk); } -VoxelStructure::VoxelStructure() { +TerraStructure::TerraStructure() { _use_aabb = true; _position_x = 0; _position_y = 0; _position_z = 0; } -VoxelStructure::~VoxelStructure() { +TerraStructure::~TerraStructure() { } -void VoxelStructure::_bind_methods() { - BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); +void TerraStructure::_bind_methods() { + BIND_VMETHOD(MethodInfo("_write_to_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("get_use_aabb"), &VoxelStructure::get_use_aabb); - ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &VoxelStructure::set_use_aabb); + ClassDB::bind_method(D_METHOD("get_use_aabb"), &TerraStructure::get_use_aabb); + ClassDB::bind_method(D_METHOD("set_use_aabb", "value"), &TerraStructure::set_use_aabb); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_aabb"), "set_use_aabb", "get_use_aabb"); - ClassDB::bind_method(D_METHOD("get_chunk_aabb"), &VoxelStructure::get_chunk_aabb); - ClassDB::bind_method(D_METHOD("set_chunk_aabb", "value"), &VoxelStructure::set_chunk_aabb); + ClassDB::bind_method(D_METHOD("get_chunk_aabb"), &TerraStructure::get_chunk_aabb); + ClassDB::bind_method(D_METHOD("set_chunk_aabb", "value"), &TerraStructure::set_chunk_aabb); ADD_PROPERTY(PropertyInfo(Variant::AABB, "chunk_aabb"), "set_chunk_aabb", "get_chunk_aabb"); - ClassDB::bind_method(D_METHOD("get_position_x"), &VoxelStructure::get_position_x); - ClassDB::bind_method(D_METHOD("set_position_x", "value"), &VoxelStructure::set_position_x); + ClassDB::bind_method(D_METHOD("get_position_x"), &TerraStructure::get_position_x); + ClassDB::bind_method(D_METHOD("set_position_x", "value"), &TerraStructure::set_position_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_x"), "set_position_x", "get_position_x"); - ClassDB::bind_method(D_METHOD("get_position_y"), &VoxelStructure::get_position_y); - ClassDB::bind_method(D_METHOD("set_position_y", "value"), &VoxelStructure::set_position_y); + ClassDB::bind_method(D_METHOD("get_position_y"), &TerraStructure::get_position_y); + ClassDB::bind_method(D_METHOD("set_position_y", "value"), &TerraStructure::set_position_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_y"), "set_position_y", "get_position_y"); - ClassDB::bind_method(D_METHOD("get_position_z"), &VoxelStructure::get_position_z); - ClassDB::bind_method(D_METHOD("set_position_z", "value"), &VoxelStructure::set_position_z); + ClassDB::bind_method(D_METHOD("get_position_z"), &TerraStructure::get_position_z); + ClassDB::bind_method(D_METHOD("set_position_z", "value"), &TerraStructure::set_position_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "position_z"), "set_position_z", "get_position_z"); - ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &VoxelStructure::set_position); + ClassDB::bind_method(D_METHOD("set_position", "x", "y", "z"), &TerraStructure::set_position); - ClassDB::bind_method(D_METHOD("write_to_chunk", "chunk"), &VoxelStructure::write_to_chunk); + ClassDB::bind_method(D_METHOD("write_to_chunk", "chunk"), &TerraStructure::write_to_chunk); } diff --git a/world/voxel_structure.h b/world/voxel_structure.h index 446763d..267321a 100644 --- a/world/voxel_structure.h +++ b/world/voxel_structure.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_STRUCTURE_H -#define VOXEL_STRUCTURE_H +#ifndef TERRA_STRUCTURE_H +#define TERRA_STRUCTURE_H #include "core/version.h" @@ -41,8 +41,8 @@ include_pool_vector #include "core/math/aabb.h" #include "voxel_chunk.h" -class VoxelStructure : public Resource { - GDCLASS(VoxelStructure, Resource); +class TerraStructure : public Resource { + GDCLASS(TerraStructure, Resource); public: bool get_use_aabb() const; @@ -62,10 +62,10 @@ public: void set_position(const int x, const int y, const int z); - void write_to_chunk(Ref chunk); + void write_to_chunk(Ref chunk); - VoxelStructure(); - ~VoxelStructure(); + TerraStructure(); + ~TerraStructure(); protected: static void _bind_methods(); diff --git a/world/voxel_world.cpp b/world/voxel_world.cpp index 07c0d9c..234c251 100644 --- a/world/voxel_world.cpp +++ b/world/voxel_world.cpp @@ -41,65 +41,65 @@ SOFTWARE. #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif -const String VoxelWorld::BINDING_STRING_CHANNEL_TYPE_INFO = "Type,Isolevel,Liquid,Liquid Level"; +const String TerraWorld::BINDING_STRING_CHANNEL_TYPE_INFO = "Type,Isolevel,Liquid,Liquid Level"; -bool VoxelWorld::get_editable() const { +bool TerraWorld::get_editable() const { return _editable; } -void VoxelWorld::set_editable(const bool value) { +void TerraWorld::set_editable(const bool value) { _editable = value; } -int VoxelWorld::get_chunk_size_x() const { +int TerraWorld::get_chunk_size_x() const { return _chunk_size_x; } -void VoxelWorld::set_chunk_size_x(const int value) { +void TerraWorld::set_chunk_size_x(const int value) { _chunk_size_x = value; } -int VoxelWorld::get_chunk_size_y() const { +int TerraWorld::get_chunk_size_y() const { return _chunk_size_y; } -void VoxelWorld::set_chunk_size_y(const int value) { +void TerraWorld::set_chunk_size_y(const int value) { _chunk_size_y = value; } -int VoxelWorld::get_chunk_size_z() const { +int TerraWorld::get_chunk_size_z() const { return _chunk_size_z; } -void VoxelWorld::set_chunk_size_z(const int value) { +void TerraWorld::set_chunk_size_z(const int value) { _chunk_size_z = value; } -int VoxelWorld::get_data_margin_start() const { +int TerraWorld::get_data_margin_start() const { return _data_margin_start; } -void VoxelWorld::set_data_margin_start(const int value) { +void TerraWorld::set_data_margin_start(const int value) { _data_margin_start = value; } -int VoxelWorld::get_data_margin_end() const { +int TerraWorld::get_data_margin_end() const { return _data_margin_end; } -void VoxelWorld::set_data_margin_end(const int value) { +void TerraWorld::set_data_margin_end(const int value) { _data_margin_end = value; } -int VoxelWorld::get_current_seed() const { +int TerraWorld::get_current_seed() const { return _current_seed; } -void VoxelWorld::set_current_seed(const int value) { +void TerraWorld::set_current_seed(const int value) { _current_seed = value; } -bool VoxelWorld::get_use_threads() const { +bool TerraWorld::get_use_threads() const { return _use_threads; } -void VoxelWorld::set_use_threads(const bool value) { +void TerraWorld::set_use_threads(const bool value) { _use_threads = OS::get_singleton()->can_use_threads() ? value : false; for (int i = 0; i < chunk_get_count(); ++i) { - Ref c = chunk_get_index(i); + Ref c = chunk_get_index(i); if (!c.is_valid()) continue; @@ -108,28 +108,28 @@ void VoxelWorld::set_use_threads(const bool value) { } } -int VoxelWorld::get_max_concurrent_generations() const { +int TerraWorld::get_max_concurrent_generations() const { return _max_concurrent_generations; } -void VoxelWorld::set_max_concurrent_generations(const int value) { +void TerraWorld::set_max_concurrent_generations(const int value) { _max_concurrent_generations = OS::get_singleton()->can_use_threads() ? value : 1; } -int VoxelWorld::get_max_frame_chunk_build_steps() const { +int TerraWorld::get_max_frame_chunk_build_steps() const { return _max_frame_chunk_build_steps; } -void VoxelWorld::set_max_frame_chunk_build_steps(const int value) { +void TerraWorld::set_max_frame_chunk_build_steps(const int value) { _max_frame_chunk_build_steps = value; } -Ref VoxelWorld::get_library() { +Ref TerraWorld::get_library() { return _library; } -void VoxelWorld::set_library(const Ref &library) { +void TerraWorld::set_library(const Ref &library) { _library = library; for (int i = 0; i < chunk_get_count(); ++i) { - Ref c = chunk_get_index(i); + Ref c = chunk_get_index(i); if (!c.is_valid()) continue; @@ -138,21 +138,21 @@ void VoxelWorld::set_library(const Ref &library) { } } -Ref VoxelWorld::get_level_generator() const { +Ref TerraWorld::get_level_generator() const { return _level_generator; } -void VoxelWorld::set_level_generator(const Ref &level_generator) { +void TerraWorld::set_level_generator(const Ref &level_generator) { _level_generator = level_generator; } -float VoxelWorld::get_voxel_scale() const { +float TerraWorld::get_voxel_scale() const { return _voxel_scale; } -void VoxelWorld::set_voxel_scale(const float value) { +void TerraWorld::set_voxel_scale(const float value) { _voxel_scale = value; for (int i = 0; i < chunk_get_count(); ++i) { - Ref c = chunk_get_index(i); + Ref c = chunk_get_index(i); if (!c.is_valid()) continue; @@ -161,62 +161,62 @@ void VoxelWorld::set_voxel_scale(const float value) { } } -int VoxelWorld::get_chunk_spawn_range() const { +int TerraWorld::get_chunk_spawn_range() const { return _chunk_spawn_range; } -void VoxelWorld::set_chunk_spawn_range(const int value) { +void TerraWorld::set_chunk_spawn_range(const int value) { _chunk_spawn_range = value; } -NodePath VoxelWorld::get_player_path() const { +NodePath TerraWorld::get_player_path() const { return _player_path; } -void VoxelWorld::set_player_path(const NodePath &player_path) { +void TerraWorld::set_player_path(const NodePath &player_path) { _player_path = player_path; } -Spatial *VoxelWorld::get_player() const { +Spatial *TerraWorld::get_player() const { return _player; } -void VoxelWorld::set_player(Spatial *player) { +void TerraWorld::set_player(Spatial *player) { _player = player; } -void VoxelWorld::set_player_bind(Node *player) { +void TerraWorld::set_player_bind(Node *player) { set_player(Object::cast_to(player)); } -Ref VoxelWorld::world_area_get(const int index) const { - ERR_FAIL_INDEX_V(index, _world_areas.size(), Ref()); +Ref TerraWorld::world_area_get(const int index) const { + ERR_FAIL_INDEX_V(index, _world_areas.size(), Ref()); return _world_areas.get(index); } -void VoxelWorld::world_area_add(const Ref &area) { +void TerraWorld::world_area_add(const Ref &area) { _world_areas.push_back(area); } -void VoxelWorld::world_area_remove(const int index) { +void TerraWorld::world_area_remove(const int index) { ERR_FAIL_INDEX(index, _world_areas.size()); _world_areas.remove(index); } -void VoxelWorld::world_areas_clear() { +void TerraWorld::world_areas_clear() { _world_areas.clear(); } -int VoxelWorld::world_area_get_count() const { +int TerraWorld::world_area_get_count() const { return _world_areas.size(); } -//Voxel Structures +//Terra Structures -Ref VoxelWorld::voxel_structure_get(const int index) const { - ERR_FAIL_INDEX_V(index, _voxel_structures.size(), Ref()); +Ref TerraWorld::voxel_structure_get(const int index) const { + ERR_FAIL_INDEX_V(index, _voxel_structures.size(), Ref()); return _voxel_structures.get(index); } -void VoxelWorld::voxel_structure_add(const Ref &structure) { +void TerraWorld::voxel_structure_add(const Ref &structure) { _voxel_structures.push_back(structure); } -void VoxelWorld::voxel_structure_remove(const Ref &structure) { +void TerraWorld::voxel_structure_remove(const Ref &structure) { if (!structure.is_valid()) return; @@ -225,18 +225,18 @@ void VoxelWorld::voxel_structure_remove(const Ref &structure) { if (index != -1) _voxel_structures.remove(index); } -void VoxelWorld::voxel_structure_remove_index(const int index) { +void TerraWorld::voxel_structure_remove_index(const int index) { ERR_FAIL_INDEX(index, _voxel_structures.size()); _voxel_structures.remove(index); } -void VoxelWorld::voxel_structures_clear() { +void TerraWorld::voxel_structures_clear() { _voxel_structures.clear(); } -int VoxelWorld::voxel_structure_get_count() const { +int TerraWorld::voxel_structure_get_count() const { return _voxel_structures.size(); } -void VoxelWorld::voxel_structure_add_at_position(Ref structure, const Vector3 &world_position) { +void TerraWorld::voxel_structure_add_at_position(Ref structure, const Vector3 &world_position) { ERR_FAIL_COND(!structure.is_valid()); structure->set_position_x(static_cast(world_position.x / _voxel_scale)); @@ -246,20 +246,20 @@ void VoxelWorld::voxel_structure_add_at_position(Ref structure, voxel_structure_add(structure); } -Vector VoxelWorld::voxel_structures_get() { +Vector TerraWorld::voxel_structures_get() { VARIANT_ARRAY_GET(_voxel_structures); } -void VoxelWorld::voxel_structures_set(const Vector &structures) { +void TerraWorld::voxel_structures_set(const Vector &structures) { voxel_structures_clear(); for (int i = 0; i < structures.size(); ++i) { - Ref structure = Ref(structures[i]); + Ref structure = Ref(structures[i]); voxel_structure_add(structure); } } -void VoxelWorld::chunk_add(Ref chunk, const int x, const int y, const int z) { +void TerraWorld::chunk_add(Ref chunk, const int x, const int y, const int z) { ERR_FAIL_COND(!chunk.is_valid()); ERR_FAIL_COND_MSG(chunk->get_voxel_world() != NULL && chunk->get_voxel_world() != this, "Chunk is already owned by an another world!"); @@ -283,24 +283,24 @@ void VoxelWorld::chunk_add(Ref chunk, const int x, const int y, cons if (has_method("_chunk_added")) call("_chunk_added", chunk); } -bool VoxelWorld::chunk_has(const int x, const int y, const int z) const { +bool TerraWorld::chunk_has(const int x, const int y, const int z) const { return _chunks.has(IntPos(x, y, z)); } -Ref VoxelWorld::chunk_get(const int x, const int y, const int z) { +Ref TerraWorld::chunk_get(const int x, const int y, const int z) { IntPos pos(x, y, z); if (_chunks.has(pos)) return _chunks.get(pos); - return Ref(); + return Ref(); } -Ref VoxelWorld::chunk_remove(const int x, const int y, const int z) { +Ref TerraWorld::chunk_remove(const int x, const int y, const int z) { IntPos pos(x, y, z); if (!_chunks.has(pos)) return NULL; - Ref chunk = _chunks.get(pos); + Ref chunk = _chunks.get(pos); for (int i = 0; i < _chunks_vector.size(); ++i) { if (_chunks_vector.get(i) == chunk) { @@ -317,10 +317,10 @@ Ref VoxelWorld::chunk_remove(const int x, const int y, const int z) return chunk; } -Ref VoxelWorld::chunk_remove_index(const int index) { +Ref TerraWorld::chunk_remove_index(const int index) { ERR_FAIL_INDEX_V(index, _chunks_vector.size(), NULL); - Ref chunk = _chunks_vector.get(index); + Ref chunk = _chunks_vector.get(index); _chunks_vector.remove(index); _chunks.erase(IntPos(chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z())); chunk->exit_tree(); @@ -328,16 +328,16 @@ Ref VoxelWorld::chunk_remove_index(const int index) { return chunk; } -Ref VoxelWorld::chunk_get_index(const int index) { +Ref TerraWorld::chunk_get_index(const int index) { ERR_FAIL_INDEX_V(index, _chunks_vector.size(), NULL); return _chunks_vector.get(index); } -int VoxelWorld::chunk_get_count() const { +int TerraWorld::chunk_get_count() const { return _chunks_vector.size(); } -void VoxelWorld::chunks_clear() { +void TerraWorld::chunks_clear() { for (int i = 0; i < _chunks_vector.size(); ++i) { _chunks_vector.get(i)->exit_tree(); } @@ -350,8 +350,8 @@ void VoxelWorld::chunks_clear() { _generating.clear(); } -Ref VoxelWorld::chunk_get_or_create(int x, int y, int z) { - Ref chunk = chunk_get(x, y, z); +Ref TerraWorld::chunk_get_or_create(int x, int y, int z) { + Ref chunk = chunk_get(x, y, z); if (!chunk.is_valid()) { chunk = chunk_create(x, y, z); @@ -360,21 +360,21 @@ Ref VoxelWorld::chunk_get_or_create(int x, int y, int z) { return chunk; } -Ref VoxelWorld::chunk_create(const int x, const int y, const int z) { - Ref c = call("_create_chunk", x, y, z, Ref()); +Ref TerraWorld::chunk_create(const int x, const int y, const int z) { + Ref c = call("_create_chunk", x, y, z, Ref()); generation_queue_add_to(c); return c; } -void VoxelWorld::chunk_setup(Ref chunk) { +void TerraWorld::chunk_setup(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); call("_create_chunk", chunk->get_position_x(), chunk->get_position_y(), chunk->get_position_z(), chunk); } -Ref VoxelWorld::_create_chunk(const int x, const int y, const int z, Ref chunk) { +Ref TerraWorld::_create_chunk(const int x, const int y, const int z, Ref chunk) { if (!chunk.is_valid()) { chunk.instance(); } @@ -402,7 +402,7 @@ Ref VoxelWorld::_create_chunk(const int x, const int y, const int z, return chunk; } -void VoxelWorld::chunk_generate(Ref chunk) { +void TerraWorld::chunk_generate(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (has_method("_prepare_chunk_for_generation")) @@ -413,14 +413,14 @@ void VoxelWorld::chunk_generate(Ref chunk) { chunk->build(); } -Vector VoxelWorld::chunks_get() { +Vector TerraWorld::chunks_get() { VARIANT_ARRAY_GET(_chunks_vector); } -void VoxelWorld::chunks_set(const Vector &chunks) { +void TerraWorld::chunks_set(const Vector &chunks) { if (is_inside_tree()) { for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = Ref(_chunks_vector[i]); + Ref chunk = Ref(_chunks_vector[i]); if (chunks.find(chunk) == -1) { chunk_remove_index(i); @@ -432,7 +432,7 @@ void VoxelWorld::chunks_set(const Vector &chunks) { //add the difference for (int i = 0; i < chunks.size(); ++i) { - Ref chunk = Ref(chunks[i]); + Ref chunk = Ref(chunks[i]); if (!chunk.is_valid()) continue; @@ -446,18 +446,18 @@ void VoxelWorld::chunks_set(const Vector &chunks) { _chunks_vector.clear(); for (int i = 0; i < chunks.size(); ++i) { - Ref chunk = Ref(chunks[i]); + Ref chunk = Ref(chunks[i]); _chunks_vector.push_back(chunk); } } } -int VoxelWorld::_get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) { +int TerraWorld::_get_channel_index_info(const TerraWorld::ChannelTypeInfo channel_type) { return -1; } -void VoxelWorld::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { +void TerraWorld::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { Vector3 pos; if (mode_add) { @@ -466,8 +466,8 @@ void VoxelWorld::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_pos pos = (hit_position + (Vector3(0.1, 0.1, 0.1) * -hit_normal * get_voxel_scale())); } - int channel_type = get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_TYPE); - int channel_isolevel = get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_ISOLEVEL); + int channel_type = get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_TYPE); + int channel_isolevel = get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_ISOLEVEL); if (channel_isolevel == -1) { set_voxel_at_world_position(pos, selected_voxel, channel_type); @@ -477,7 +477,7 @@ void VoxelWorld::_set_voxel_with_tool(const bool mode_add, const Vector3 hit_pos } } -bool VoxelWorld::can_chunk_do_build_step() { +bool TerraWorld::can_chunk_do_build_step() { if (_max_frame_chunk_build_steps == 0) { return true; } @@ -485,12 +485,12 @@ bool VoxelWorld::can_chunk_do_build_step() { return _num_frame_chunk_build_steps++ < _max_frame_chunk_build_steps; } -bool VoxelWorld::is_position_walkable(const Vector3 &p_pos) { +bool TerraWorld::is_position_walkable(const Vector3 &p_pos) { int x = static_cast(Math::floor(p_pos.x / (_chunk_size_x * _voxel_scale))); int y = static_cast(Math::floor(p_pos.y / (_chunk_size_y * _voxel_scale))); int z = static_cast(Math::floor(p_pos.z / (_chunk_size_z * _voxel_scale))); - Ref c = chunk_get(x, y, z); + Ref c = chunk_get(x, y, z); if (!c.is_valid()) return false; @@ -498,52 +498,52 @@ bool VoxelWorld::is_position_walkable(const Vector3 &p_pos) { return !c->get_is_generating(); } -void VoxelWorld::on_chunk_mesh_generation_finished(Ref p_chunk) { +void TerraWorld::on_chunk_mesh_generation_finished(Ref p_chunk) { call_deferred("emit_signal", "chunk_mesh_generation_finished", p_chunk); } -void VoxelWorld::generation_queue_add_to(const Ref &chunk) { +void TerraWorld::generation_queue_add_to(const Ref &chunk) { ERR_FAIL_COND(!chunk.is_valid()); set_process_internal(true); _generation_queue.push_back(chunk); } -Ref VoxelWorld::generation_queue_get_index(int index) { +Ref TerraWorld::generation_queue_get_index(int index) { ERR_FAIL_INDEX_V(index, _generation_queue.size(), NULL); return _generation_queue.get(index); } -void VoxelWorld::generation_queue_remove_index(int index) { +void TerraWorld::generation_queue_remove_index(int index) { ERR_FAIL_INDEX(index, _generation_queue.size()); _generation_queue.remove(index); } -int VoxelWorld::generation_queue_get_size() const { +int TerraWorld::generation_queue_get_size() const { return _generation_queue.size(); } -void VoxelWorld::generation_add_to(const Ref &chunk) { +void TerraWorld::generation_add_to(const Ref &chunk) { ERR_FAIL_COND(!chunk.is_valid()); _generating.push_back(chunk); } -Ref VoxelWorld::generation_get_index(const int index) { +Ref TerraWorld::generation_get_index(const int index) { ERR_FAIL_INDEX_V(index, _generating.size(), NULL); return _generating.get(index); } -void VoxelWorld::generation_remove_index(const int index) { +void TerraWorld::generation_remove_index(const int index) { ERR_FAIL_INDEX(index, _generating.size()); _generating.remove(index); } -int VoxelWorld::generation_get_size() const { +int TerraWorld::generation_get_size() const { return _generating.size(); } #if PROPS_PRESENT -void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const bool apply_voxel_scael) { +void TerraWorld::prop_add(Transform tarnsform, const Ref &prop, const bool apply_voxel_scael) { ERR_FAIL_COND(!prop.is_valid()); if (apply_voxel_scael) { @@ -552,7 +552,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const Vector3 wp; wp = tarnsform.xform(wp); - Ref chunk = get_or_create_chunk_at_world_position(wp); + Ref chunk = get_or_create_chunk_at_world_position(wp); chunk->prop_add(tarnsform, prop); @@ -605,7 +605,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const Ref light_data = entry; if (light_data.is_valid()) { - Ref light; + Ref light; light.instance(); light->set_world_position(wp.x / get_voxel_scale(), wp.y / get_voxel_scale(), wp.z / get_voxel_scale()); @@ -636,47 +636,47 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const #endif //Lights -void VoxelWorld::light_add(const Ref &light) { +void TerraWorld::light_add(const Ref &light) { _lights.push_back(light); for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; if (chunk.is_valid()) { chunk->world_light_added(light); } } } -Ref VoxelWorld::light_get(const int index) { - ERR_FAIL_INDEX_V(index, _lights.size(), Ref()); +Ref TerraWorld::light_get(const int index) { + ERR_FAIL_INDEX_V(index, _lights.size(), Ref()); return _lights.get(index); } -void VoxelWorld::light_remove(const int index) { +void TerraWorld::light_remove(const int index) { ERR_FAIL_INDEX(index, _lights.size()); - Ref light = _lights[index]; + Ref light = _lights[index]; for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; if (chunk.is_valid()) { chunk->world_light_removed(light); } } } -int VoxelWorld::light_get_count() const { +int TerraWorld::light_get_count() const { return _lights.size(); } -void VoxelWorld::lights_clear() { +void TerraWorld::lights_clear() { for (int i = 0; i < _lights.size(); ++i) { - Ref light = _lights[i]; + Ref light = _lights[i]; if (!light.is_valid()) continue; for (int j = 0; j < _chunks_vector.size(); ++j) { - Ref chunk = _chunks_vector[j]; + Ref chunk = _chunks_vector[j]; if (chunk.is_valid()) { chunk->world_light_removed(light); @@ -687,20 +687,20 @@ void VoxelWorld::lights_clear() { _lights.clear(); } -Vector VoxelWorld::lights_get() { +Vector TerraWorld::lights_get() { VARIANT_ARRAY_GET(_lights); } -void VoxelWorld::lights_set(const Vector &chunks) { +void TerraWorld::lights_set(const Vector &chunks) { lights_clear(); for (int i = 0; i < chunks.size(); ++i) { - Ref light = Ref(chunks[i]); + Ref light = Ref(chunks[i]); light_add(light); } } -uint8_t VoxelWorld::get_voxel_at_world_position(const Vector3 &world_position, const int channel_index) { +uint8_t TerraWorld::get_voxel_at_world_position(const Vector3 &world_position, const int channel_index) { Vector3 pos = world_position / get_voxel_scale(); //Note: floor is needed to handle negative numbers properly @@ -724,7 +724,7 @@ uint8_t VoxelWorld::get_voxel_at_world_position(const Vector3 &world_position, c bz += get_chunk_size_z(); } - Ref chunk = chunk_get(x, y, z); + Ref chunk = chunk_get(x, y, z); if (chunk.is_valid()) return chunk->get_voxel(bx, by, bz, channel_index); @@ -732,7 +732,7 @@ uint8_t VoxelWorld::get_voxel_at_world_position(const Vector3 &world_position, c return 0; } -void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, const uint8_t data, const int channel_index, const bool rebuild) { +void TerraWorld::set_voxel_at_world_position(const Vector3 &world_position, const uint8_t data, const int channel_index, const bool rebuild) { Vector3 pos = world_position / get_voxel_scale(); //Note: floor is needed to handle negative numbers properly @@ -758,7 +758,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons if (get_data_margin_end() > 0) { if (bx == 0) { - Ref chunk = chunk_get_or_create(x - 1, y, z); + Ref chunk = chunk_get_or_create(x - 1, y, z); chunk->set_voxel(data, get_chunk_size_x(), by, bz, channel_index); if (rebuild) @@ -766,7 +766,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons } if (by == 0) { - Ref chunk = chunk_get_or_create(x, y - 1, z); + Ref chunk = chunk_get_or_create(x, y - 1, z); chunk->set_voxel(data, bx, get_chunk_size_y(), bz, channel_index); if (rebuild) @@ -774,7 +774,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons } if (bz == 0) { - Ref chunk = chunk_get_or_create(x, y, z - 1); + Ref chunk = chunk_get_or_create(x, y, z - 1); chunk->set_voxel(data, bx, by, get_chunk_size_z(), channel_index); if (rebuild) @@ -784,7 +784,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons if (get_data_margin_start() > 0) { if (bx == get_chunk_size_x() - 1) { - Ref chunk = chunk_get_or_create(x + 1, y, z); + Ref chunk = chunk_get_or_create(x + 1, y, z); chunk->set_voxel(data, -1, by, bz, channel_index); if (rebuild) @@ -792,7 +792,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons } if (by == get_chunk_size_y() - 1) { - Ref chunk = chunk_get_or_create(x, y + 1, z); + Ref chunk = chunk_get_or_create(x, y + 1, z); chunk->set_voxel(data, bx, -1, bz, channel_index); if (rebuild) @@ -800,7 +800,7 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons } if (bz == get_chunk_size_z() - 1) { - Ref chunk = chunk_get_or_create(x, y, z + 1); + Ref chunk = chunk_get_or_create(x, y, z + 1); chunk->set_voxel(data, bx, by, -1, channel_index); if (rebuild) @@ -808,14 +808,14 @@ void VoxelWorld::set_voxel_at_world_position(const Vector3 &world_position, cons } } - Ref chunk = chunk_get_or_create(x, y, z); + Ref chunk = chunk_get_or_create(x, y, z); chunk->set_voxel(data, bx, by, bz, channel_index); if (rebuild) chunk->build(); } -Ref VoxelWorld::get_chunk_at_world_position(const Vector3 &world_position) { +Ref TerraWorld::get_chunk_at_world_position(const Vector3 &world_position) { Vector3 pos = world_position / get_voxel_scale(); //Note: floor is needed to handle negative numbers proiberly @@ -825,7 +825,7 @@ Ref VoxelWorld::get_chunk_at_world_position(const Vector3 &world_pos return chunk_get(x, y, z); } -Ref VoxelWorld::get_or_create_chunk_at_world_position(const Vector3 &world_position) { +Ref TerraWorld::get_or_create_chunk_at_world_position(const Vector3 &world_position) { Vector3 pos = world_position / get_voxel_scale(); //Note: floor is needed to handle negative numbers proiberly @@ -836,15 +836,15 @@ Ref VoxelWorld::get_or_create_chunk_at_world_position(const Vector3 return chunk_get_or_create(x, y, z); } -void VoxelWorld::set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { +void TerraWorld::set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel) { call("_set_voxel_with_tool", mode_add, hit_position, hit_normal, selected_voxel, isolevel); } -int VoxelWorld::get_channel_index_info(const VoxelWorld::ChannelTypeInfo channel_type) { +int TerraWorld::get_channel_index_info(const TerraWorld::ChannelTypeInfo channel_type) { return call("_get_channel_index_info", channel_type); } -VoxelWorld::VoxelWorld() { +TerraWorld::TerraWorld() { _editable = false; _is_priority_generation = true; @@ -867,7 +867,7 @@ VoxelWorld::VoxelWorld() { _num_frame_chunk_build_steps = 0; } -VoxelWorld ::~VoxelWorld() { +TerraWorld ::~TerraWorld() { _chunks.clear(); _chunks_vector.clear(); _world_areas.clear(); @@ -884,14 +884,14 @@ VoxelWorld ::~VoxelWorld() { _lights.clear(); } -void VoxelWorld::_generate_chunk(Ref chunk) { +void TerraWorld::_generate_chunk(Ref chunk) { ERR_FAIL_COND(!chunk.is_valid()); if (_level_generator.is_valid()) _level_generator->generate_chunk(chunk); for (int i = 0; i < _voxel_structures.size(); ++i) { - Ref structure = _voxel_structures.get(i); + Ref structure = _voxel_structures.get(i); if (!structure.is_valid()) continue; @@ -905,7 +905,7 @@ void VoxelWorld::_generate_chunk(Ref chunk) { } } -void VoxelWorld::_notification(int p_what) { +void TerraWorld::_notification(int p_what) { switch (p_what) { case NOTIFICATION_ENTER_TREE: { set_player_bind(get_node_or_null(get_player_path())); @@ -918,7 +918,7 @@ void VoxelWorld::_notification(int p_what) { _library->refresh_rects(); for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; if (chunk.is_valid()) { chunk_setup(chunk); @@ -931,7 +931,7 @@ void VoxelWorld::_notification(int p_what) { _num_frame_chunk_build_steps = 0; for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; ERR_CONTINUE(!chunk.is_valid()); @@ -959,7 +959,7 @@ void VoxelWorld::_notification(int p_what) { } for (int i = 0; i < _generating.size(); ++i) { - Ref chunk = _generating.get(i); + Ref chunk = _generating.get(i); if (!chunk.is_valid() || !chunk->get_is_generating()) { _generating.remove(i); @@ -975,7 +975,7 @@ void VoxelWorld::_notification(int p_what) { return; while (_generating.size() < _max_concurrent_generations && _generation_queue.size() != 0) { - Ref chunk = _generation_queue.get(0); + Ref chunk = _generation_queue.get(0); _generation_queue.remove(0); ERR_FAIL_COND(!chunk.is_valid()); @@ -987,7 +987,7 @@ void VoxelWorld::_notification(int p_what) { } break; case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; ERR_CONTINUE(!chunk.is_valid()); @@ -1003,7 +1003,7 @@ void VoxelWorld::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; if (chunk.is_valid()) { if (chunk->get_voxel_world() == this) { @@ -1016,7 +1016,7 @@ void VoxelWorld::_notification(int p_what) { } break; case NOTIFICATION_TRANSFORM_CHANGED: { for (int i = 0; i < _chunks_vector.size(); ++i) { - Ref chunk = _chunks_vector[i]; + Ref chunk = _chunks_vector[i]; if (chunk.is_valid()) { chunk->world_transform_changed(); @@ -1027,159 +1027,159 @@ void VoxelWorld::_notification(int p_what) { } } -void VoxelWorld::_bind_methods() { - ADD_SIGNAL(MethodInfo("chunk_mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); +void TerraWorld::_bind_methods() { + ADD_SIGNAL(MethodInfo("chunk_mesh_generation_finished", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("get_editable"), &VoxelWorld::get_editable); - ClassDB::bind_method(D_METHOD("set_editable", "value"), &VoxelWorld::set_editable); + ClassDB::bind_method(D_METHOD("get_editable"), &TerraWorld::get_editable); + ClassDB::bind_method(D_METHOD("set_editable", "value"), &TerraWorld::set_editable); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "get_editable"); - ClassDB::bind_method(D_METHOD("get_chunk_size_x"), &VoxelWorld::get_chunk_size_x); - ClassDB::bind_method(D_METHOD("set_chunk_size_x", "value"), &VoxelWorld::set_chunk_size_x); + ClassDB::bind_method(D_METHOD("get_chunk_size_x"), &TerraWorld::get_chunk_size_x); + ClassDB::bind_method(D_METHOD("set_chunk_size_x", "value"), &TerraWorld::set_chunk_size_x); ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_x"), "set_chunk_size_x", "get_chunk_size_x"); - ClassDB::bind_method(D_METHOD("get_chunk_size_y"), &VoxelWorld::get_chunk_size_y); - ClassDB::bind_method(D_METHOD("set_chunk_size_y", "value"), &VoxelWorld::set_chunk_size_y); + ClassDB::bind_method(D_METHOD("get_chunk_size_y"), &TerraWorld::get_chunk_size_y); + ClassDB::bind_method(D_METHOD("set_chunk_size_y", "value"), &TerraWorld::set_chunk_size_y); ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_y"), "set_chunk_size_y", "get_chunk_size_y"); - ClassDB::bind_method(D_METHOD("get_chunk_size_z"), &VoxelWorld::get_chunk_size_z); - ClassDB::bind_method(D_METHOD("set_chunk_size_z", "value"), &VoxelWorld::set_chunk_size_z); + ClassDB::bind_method(D_METHOD("get_chunk_size_z"), &TerraWorld::get_chunk_size_z); + ClassDB::bind_method(D_METHOD("set_chunk_size_z", "value"), &TerraWorld::set_chunk_size_z); ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_size_z"), "set_chunk_size_z", "get_chunk_size_z"); - ClassDB::bind_method(D_METHOD("get_data_margin_start"), &VoxelWorld::get_data_margin_start); - ClassDB::bind_method(D_METHOD("set_data_margin_start", "value"), &VoxelWorld::set_data_margin_start); + ClassDB::bind_method(D_METHOD("get_data_margin_start"), &TerraWorld::get_data_margin_start); + ClassDB::bind_method(D_METHOD("set_data_margin_start", "value"), &TerraWorld::set_data_margin_start); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_margin_start"), "set_data_margin_start", "get_data_margin_start"); - ClassDB::bind_method(D_METHOD("get_data_margin_end"), &VoxelWorld::get_data_margin_end); - ClassDB::bind_method(D_METHOD("set_data_margin_end", "value"), &VoxelWorld::set_data_margin_end); + ClassDB::bind_method(D_METHOD("get_data_margin_end"), &TerraWorld::get_data_margin_end); + ClassDB::bind_method(D_METHOD("set_data_margin_end", "value"), &TerraWorld::set_data_margin_end); ADD_PROPERTY(PropertyInfo(Variant::INT, "data_margin_end"), "set_data_margin_end", "get_data_margin_end"); - ClassDB::bind_method(D_METHOD("get_current_seed"), &VoxelWorld::get_current_seed); - ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &VoxelWorld::set_current_seed); + ClassDB::bind_method(D_METHOD("get_current_seed"), &TerraWorld::get_current_seed); + ClassDB::bind_method(D_METHOD("set_current_seed", "value"), &TerraWorld::set_current_seed); ADD_PROPERTY(PropertyInfo(Variant::INT, "current_seed"), "set_current_seed", "get_current_seed"); - ClassDB::bind_method(D_METHOD("get_use_threads"), &VoxelWorld::get_use_threads); - ClassDB::bind_method(D_METHOD("set_use_threads", "value"), &VoxelWorld::set_use_threads); + ClassDB::bind_method(D_METHOD("get_use_threads"), &TerraWorld::get_use_threads); + ClassDB::bind_method(D_METHOD("set_use_threads", "value"), &TerraWorld::set_use_threads); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_threads"), "set_use_threads", "get_use_threads"); - ClassDB::bind_method(D_METHOD("get_max_concurrent_generations"), &VoxelWorld::get_max_concurrent_generations); - ClassDB::bind_method(D_METHOD("set_max_concurrent_generations", "value"), &VoxelWorld::set_max_concurrent_generations); + ClassDB::bind_method(D_METHOD("get_max_concurrent_generations"), &TerraWorld::get_max_concurrent_generations); + ClassDB::bind_method(D_METHOD("set_max_concurrent_generations", "value"), &TerraWorld::set_max_concurrent_generations); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_concurrent_generations"), "set_max_concurrent_generations", "get_max_concurrent_generations"); - ClassDB::bind_method(D_METHOD("get_max_frame_chunk_build_steps"), &VoxelWorld::get_max_frame_chunk_build_steps); - ClassDB::bind_method(D_METHOD("set_max_frame_chunk_build_steps", "value"), &VoxelWorld::set_max_frame_chunk_build_steps); + ClassDB::bind_method(D_METHOD("get_max_frame_chunk_build_steps"), &TerraWorld::get_max_frame_chunk_build_steps); + ClassDB::bind_method(D_METHOD("set_max_frame_chunk_build_steps", "value"), &TerraWorld::set_max_frame_chunk_build_steps); ADD_PROPERTY(PropertyInfo(Variant::INT, "max_frame_chunk_build_steps"), "set_max_frame_chunk_build_steps", "get_max_frame_chunk_build_steps"); - ClassDB::bind_method(D_METHOD("get_library"), &VoxelWorld::get_library); - ClassDB::bind_method(D_METHOD("set_library", "library"), &VoxelWorld::set_library); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLibrary"), "set_library", "get_library"); + ClassDB::bind_method(D_METHOD("get_library"), &TerraWorld::get_library); + ClassDB::bind_method(D_METHOD("set_library", "library"), &TerraWorld::set_library); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLibrary"), "set_library", "get_library"); - ClassDB::bind_method(D_METHOD("get_level_generator"), &VoxelWorld::get_level_generator); - ClassDB::bind_method(D_METHOD("set_level_generator", "level_generator"), &VoxelWorld::set_level_generator); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "level_generator", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanLevelGenerator"), "set_level_generator", "get_level_generator"); + ClassDB::bind_method(D_METHOD("get_level_generator"), &TerraWorld::get_level_generator); + ClassDB::bind_method(D_METHOD("set_level_generator", "level_generator"), &TerraWorld::set_level_generator); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "level_generator", PROPERTY_HINT_RESOURCE_TYPE, "TerramanLevelGenerator"), "set_level_generator", "get_level_generator"); - ClassDB::bind_method(D_METHOD("get_voxel_scale"), &VoxelWorld::get_voxel_scale); - ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &VoxelWorld::set_voxel_scale); + ClassDB::bind_method(D_METHOD("get_voxel_scale"), &TerraWorld::get_voxel_scale); + ClassDB::bind_method(D_METHOD("set_voxel_scale", "value"), &TerraWorld::set_voxel_scale); ADD_PROPERTY(PropertyInfo(Variant::REAL, "voxel_scale"), "set_voxel_scale", "get_voxel_scale"); - ClassDB::bind_method(D_METHOD("get_chunk_spawn_range"), &VoxelWorld::get_chunk_spawn_range); - ClassDB::bind_method(D_METHOD("set_chunk_spawn_range", "value"), &VoxelWorld::set_chunk_spawn_range); + ClassDB::bind_method(D_METHOD("get_chunk_spawn_range"), &TerraWorld::get_chunk_spawn_range); + ClassDB::bind_method(D_METHOD("set_chunk_spawn_range", "value"), &TerraWorld::set_chunk_spawn_range); ADD_PROPERTY(PropertyInfo(Variant::INT, "chunk_spawn_range"), "set_chunk_spawn_range", "get_chunk_spawn_range"); - ClassDB::bind_method(D_METHOD("get_player_path"), &VoxelWorld::get_player_path); - ClassDB::bind_method(D_METHOD("set_player_path", "value"), &VoxelWorld::set_player_path); + ClassDB::bind_method(D_METHOD("get_player_path"), &TerraWorld::get_player_path); + ClassDB::bind_method(D_METHOD("set_player_path", "value"), &TerraWorld::set_player_path); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "player_path"), "set_player_path", "get_player_path"); - ClassDB::bind_method(D_METHOD("get_player"), &VoxelWorld::get_player); - ClassDB::bind_method(D_METHOD("set_player", "player"), &VoxelWorld::set_player_bind); + ClassDB::bind_method(D_METHOD("get_player"), &TerraWorld::get_player); + ClassDB::bind_method(D_METHOD("set_player", "player"), &TerraWorld::set_player_bind); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "player", PROPERTY_HINT_RESOURCE_TYPE, "Spatial", 0), "set_player", "get_player"); - ClassDB::bind_method(D_METHOD("world_area_get", "index"), &VoxelWorld::world_area_get); - ClassDB::bind_method(D_METHOD("world_area_add", "area"), &VoxelWorld::world_area_add); - ClassDB::bind_method(D_METHOD("world_area_remove", "index"), &VoxelWorld::world_area_remove); - ClassDB::bind_method(D_METHOD("world_areas_clear"), &VoxelWorld::world_areas_clear); - ClassDB::bind_method(D_METHOD("world_area_get_count"), &VoxelWorld::world_area_get_count); + ClassDB::bind_method(D_METHOD("world_area_get", "index"), &TerraWorld::world_area_get); + ClassDB::bind_method(D_METHOD("world_area_add", "area"), &TerraWorld::world_area_add); + ClassDB::bind_method(D_METHOD("world_area_remove", "index"), &TerraWorld::world_area_remove); + ClassDB::bind_method(D_METHOD("world_areas_clear"), &TerraWorld::world_areas_clear); + ClassDB::bind_method(D_METHOD("world_area_get_count"), &TerraWorld::world_area_get_count); - ClassDB::bind_method(D_METHOD("voxel_structure_get", "index"), &VoxelWorld::voxel_structure_get); - ClassDB::bind_method(D_METHOD("voxel_structure_add", "structure"), &VoxelWorld::voxel_structure_add); - ClassDB::bind_method(D_METHOD("voxel_structure_remove", "structure"), &VoxelWorld::voxel_structure_remove); - ClassDB::bind_method(D_METHOD("voxel_structure_remove_index", "index"), &VoxelWorld::voxel_structure_remove_index); - ClassDB::bind_method(D_METHOD("voxel_structures_clear"), &VoxelWorld::voxel_structures_clear); - ClassDB::bind_method(D_METHOD("voxel_structure_get_count"), &VoxelWorld::voxel_structure_get_count); - ClassDB::bind_method(D_METHOD("voxel_structure_add_at_position", "structure", "world_position"), &VoxelWorld::voxel_structure_add_at_position); + ClassDB::bind_method(D_METHOD("voxel_structure_get", "index"), &TerraWorld::voxel_structure_get); + ClassDB::bind_method(D_METHOD("voxel_structure_add", "structure"), &TerraWorld::voxel_structure_add); + ClassDB::bind_method(D_METHOD("voxel_structure_remove", "structure"), &TerraWorld::voxel_structure_remove); + ClassDB::bind_method(D_METHOD("voxel_structure_remove_index", "index"), &TerraWorld::voxel_structure_remove_index); + ClassDB::bind_method(D_METHOD("voxel_structures_clear"), &TerraWorld::voxel_structures_clear); + ClassDB::bind_method(D_METHOD("voxel_structure_get_count"), &TerraWorld::voxel_structure_get_count); + ClassDB::bind_method(D_METHOD("voxel_structure_add_at_position", "structure", "world_position"), &TerraWorld::voxel_structure_add_at_position); - ClassDB::bind_method(D_METHOD("voxel_structures_get"), &VoxelWorld::voxel_structures_get); - ClassDB::bind_method(D_METHOD("voxel_structures_set"), &VoxelWorld::voxel_structures_set); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:VoxelStructure", PROPERTY_USAGE_DEFAULT, "VoxelStructure"), "voxel_structures_set", "voxel_structures_get"); + ClassDB::bind_method(D_METHOD("voxel_structures_get"), &TerraWorld::voxel_structures_get); + ClassDB::bind_method(D_METHOD("voxel_structures_set"), &TerraWorld::voxel_structures_set); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "voxel_structures", PROPERTY_HINT_NONE, "17/17:TerraStructure", PROPERTY_USAGE_DEFAULT, "TerraStructure"), "voxel_structures_set", "voxel_structures_get"); - BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + BIND_VMETHOD(MethodInfo("_chunk_added", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y", "z"), &VoxelWorld::chunk_add); - ClassDB::bind_method(D_METHOD("chunk_has", "x", "y", "z"), &VoxelWorld::chunk_has); - ClassDB::bind_method(D_METHOD("chunk_get", "x", "y", "z"), &VoxelWorld::chunk_get); - ClassDB::bind_method(D_METHOD("chunk_remove", "x", "y", "z"), &VoxelWorld::chunk_remove); - ClassDB::bind_method(D_METHOD("chunk_remove_index", "index"), &VoxelWorld::chunk_remove_index); + ClassDB::bind_method(D_METHOD("chunk_add", "chunk", "x", "y", "z"), &TerraWorld::chunk_add); + ClassDB::bind_method(D_METHOD("chunk_has", "x", "y", "z"), &TerraWorld::chunk_has); + ClassDB::bind_method(D_METHOD("chunk_get", "x", "y", "z"), &TerraWorld::chunk_get); + ClassDB::bind_method(D_METHOD("chunk_remove", "x", "y", "z"), &TerraWorld::chunk_remove); + ClassDB::bind_method(D_METHOD("chunk_remove_index", "index"), &TerraWorld::chunk_remove_index); - ClassDB::bind_method(D_METHOD("chunk_get_index", "index"), &VoxelWorld::chunk_get_index); - ClassDB::bind_method(D_METHOD("chunk_get_count"), &VoxelWorld::chunk_get_count); + ClassDB::bind_method(D_METHOD("chunk_get_index", "index"), &TerraWorld::chunk_get_index); + ClassDB::bind_method(D_METHOD("chunk_get_count"), &TerraWorld::chunk_get_count); - ClassDB::bind_method(D_METHOD("chunks_clear"), &VoxelWorld::chunks_clear); + ClassDB::bind_method(D_METHOD("chunks_clear"), &TerraWorld::chunks_clear); - ClassDB::bind_method(D_METHOD("chunks_get"), &VoxelWorld::chunks_get); - ClassDB::bind_method(D_METHOD("chunks_set"), &VoxelWorld::chunks_set); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "chunks", PROPERTY_HINT_NONE, "17/17:VoxelChunk", PROPERTY_USAGE_DEFAULT, "VoxelChunk"), "chunks_set", "chunks_get"); + ClassDB::bind_method(D_METHOD("chunks_get"), &TerraWorld::chunks_get); + ClassDB::bind_method(D_METHOD("chunks_set"), &TerraWorld::chunks_set); + ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "chunks", PROPERTY_HINT_NONE, "17/17:TerraChunk", PROPERTY_USAGE_DEFAULT, "TerraChunk"), "chunks_set", "chunks_get"); - ClassDB::bind_method(D_METHOD("generation_queue_add_to", "chunk"), &VoxelWorld::generation_queue_add_to); - ClassDB::bind_method(D_METHOD("generation_queue_get_index", "index"), &VoxelWorld::generation_queue_get_index); - ClassDB::bind_method(D_METHOD("generation_queue_remove_index", "index"), &VoxelWorld::generation_queue_remove_index); - ClassDB::bind_method(D_METHOD("generation_queue_get_size"), &VoxelWorld::generation_queue_get_size); + ClassDB::bind_method(D_METHOD("generation_queue_add_to", "chunk"), &TerraWorld::generation_queue_add_to); + ClassDB::bind_method(D_METHOD("generation_queue_get_index", "index"), &TerraWorld::generation_queue_get_index); + ClassDB::bind_method(D_METHOD("generation_queue_remove_index", "index"), &TerraWorld::generation_queue_remove_index); + ClassDB::bind_method(D_METHOD("generation_queue_get_size"), &TerraWorld::generation_queue_get_size); - ClassDB::bind_method(D_METHOD("generation_add_to", "chunk"), &VoxelWorld::generation_add_to); - ClassDB::bind_method(D_METHOD("generation_get_index", "index"), &VoxelWorld::generation_get_index); - ClassDB::bind_method(D_METHOD("generation_remove_index", "index"), &VoxelWorld::generation_remove_index); - ClassDB::bind_method(D_METHOD("generation_get_size"), &VoxelWorld::generation_get_size); + ClassDB::bind_method(D_METHOD("generation_add_to", "chunk"), &TerraWorld::generation_add_to); + ClassDB::bind_method(D_METHOD("generation_get_index", "index"), &TerraWorld::generation_get_index); + ClassDB::bind_method(D_METHOD("generation_remove_index", "index"), &TerraWorld::generation_remove_index); + ClassDB::bind_method(D_METHOD("generation_get_size"), &TerraWorld::generation_get_size); ADD_SIGNAL(MethodInfo("generation_finished")); BIND_VMETHOD(MethodInfo("_generation_finished")); - BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); - BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"))); + BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::OBJECT, "ret", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"), "_create_chunk", PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); + BIND_VMETHOD(MethodInfo("_prepare_chunk_for_generation", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); + BIND_VMETHOD(MethodInfo("_generate_chunk", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "TerraChunk"))); - ClassDB::bind_method(D_METHOD("chunk_get_or_create", "x", "y", "z"), &VoxelWorld::chunk_get_or_create); - ClassDB::bind_method(D_METHOD("chunk_create", "x", "y", "z"), &VoxelWorld::chunk_create); - ClassDB::bind_method(D_METHOD("chunk_setup", "chunk"), &VoxelWorld::chunk_setup); + ClassDB::bind_method(D_METHOD("chunk_get_or_create", "x", "y", "z"), &TerraWorld::chunk_get_or_create); + ClassDB::bind_method(D_METHOD("chunk_create", "x", "y", "z"), &TerraWorld::chunk_create); + ClassDB::bind_method(D_METHOD("chunk_setup", "chunk"), &TerraWorld::chunk_setup); - ClassDB::bind_method(D_METHOD("_create_chunk", "x", "y", "z", "chunk"), &VoxelWorld::_create_chunk); - ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &VoxelWorld::_generate_chunk); + ClassDB::bind_method(D_METHOD("_create_chunk", "x", "y", "z", "chunk"), &TerraWorld::_create_chunk); + ClassDB::bind_method(D_METHOD("_generate_chunk", "chunk"), &TerraWorld::_generate_chunk); - ClassDB::bind_method(D_METHOD("can_chunk_do_build_step"), &VoxelWorld::can_chunk_do_build_step); - ClassDB::bind_method(D_METHOD("is_position_walkable", "position"), &VoxelWorld::is_position_walkable); - ClassDB::bind_method(D_METHOD("on_chunk_mesh_generation_finished", "chunk"), &VoxelWorld::on_chunk_mesh_generation_finished); + ClassDB::bind_method(D_METHOD("can_chunk_do_build_step"), &TerraWorld::can_chunk_do_build_step); + ClassDB::bind_method(D_METHOD("is_position_walkable", "position"), &TerraWorld::is_position_walkable); + ClassDB::bind_method(D_METHOD("on_chunk_mesh_generation_finished", "chunk"), &TerraWorld::on_chunk_mesh_generation_finished); #if PROPS_PRESENT - ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "apply_voxel_scael"), &VoxelWorld::prop_add, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "apply_voxel_scael"), &TerraWorld::prop_add, DEFVAL(true)); #endif //Lights - ClassDB::bind_method(D_METHOD("light_add", "light"), &VoxelWorld::light_add); - ClassDB::bind_method(D_METHOD("light_get", "index"), &VoxelWorld::light_get); - ClassDB::bind_method(D_METHOD("light_remove", "index"), &VoxelWorld::light_remove); - ClassDB::bind_method(D_METHOD("light_get_count"), &VoxelWorld::light_get_count); - ClassDB::bind_method(D_METHOD("lights_clear"), &VoxelWorld::lights_clear); + ClassDB::bind_method(D_METHOD("light_add", "light"), &TerraWorld::light_add); + ClassDB::bind_method(D_METHOD("light_get", "index"), &TerraWorld::light_get); + ClassDB::bind_method(D_METHOD("light_remove", "index"), &TerraWorld::light_remove); + ClassDB::bind_method(D_METHOD("light_get_count"), &TerraWorld::light_get_count); + ClassDB::bind_method(D_METHOD("lights_clear"), &TerraWorld::lights_clear); - ClassDB::bind_method(D_METHOD("lights_get"), &VoxelWorld::lights_get); - ClassDB::bind_method(D_METHOD("lights_set", "chunks"), &VoxelWorld::lights_set); + ClassDB::bind_method(D_METHOD("lights_get"), &TerraWorld::lights_get); + ClassDB::bind_method(D_METHOD("lights_set", "chunks"), &TerraWorld::lights_set); - ClassDB::bind_method(D_METHOD("get_voxel_at_world_position", "world_position", "channel_index"), &VoxelWorld::get_voxel_at_world_position); - ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index", "rebuild"), &VoxelWorld::set_voxel_at_world_position, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &VoxelWorld::get_chunk_at_world_position); - ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &VoxelWorld::get_or_create_chunk_at_world_position); + ClassDB::bind_method(D_METHOD("get_voxel_at_world_position", "world_position", "channel_index"), &TerraWorld::get_voxel_at_world_position); + ClassDB::bind_method(D_METHOD("set_voxel_at_world_position", "world_position", "data", "channel_index", "rebuild"), &TerraWorld::set_voxel_at_world_position, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("get_chunk_at_world_position", "world_position"), &TerraWorld::get_chunk_at_world_position); + ClassDB::bind_method(D_METHOD("get_or_create_chunk_at_world_position", "world_position"), &TerraWorld::get_or_create_chunk_at_world_position); BIND_VMETHOD(MethodInfo("_get_channel_index_info", PropertyInfo(Variant::INT, "channel_type", PROPERTY_HINT_ENUM, BINDING_STRING_CHANNEL_TYPE_INFO))); - ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &VoxelWorld::get_channel_index_info); - ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &VoxelWorld::_get_channel_index_info); + ClassDB::bind_method(D_METHOD("get_channel_index_info", "channel_type"), &TerraWorld::get_channel_index_info); + ClassDB::bind_method(D_METHOD("_get_channel_index_info", "channel_type"), &TerraWorld::_get_channel_index_info); BIND_VMETHOD(MethodInfo("_set_voxel_with_tool", PropertyInfo(Variant::BOOL, "mode_add"), @@ -1188,8 +1188,8 @@ void VoxelWorld::_bind_methods() { PropertyInfo(Variant::INT, "selected_voxel"), PropertyInfo(Variant::INT, "isolevel"))); - ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::set_voxel_with_tool); - ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &VoxelWorld::_set_voxel_with_tool); + ClassDB::bind_method(D_METHOD("set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &TerraWorld::set_voxel_with_tool); + ClassDB::bind_method(D_METHOD("_set_voxel_with_tool", "mode_add", "hit_position", "hit_normal", "selected_voxel", "isolevel"), &TerraWorld::_set_voxel_with_tool); BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_TYPE); BIND_ENUM_CONSTANT(CHANNEL_TYPE_INFO_ISOLEVEL); diff --git a/world/voxel_world.h b/world/voxel_world.h index eeb698e..a003fdc 100644 --- a/world/voxel_world.h +++ b/world/voxel_world.h @@ -20,8 +20,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_H -#define VOXEL_WORLD_H +#ifndef TERRA_WORLD_H +#define TERRA_WORLD_H #include "core/version.h" @@ -47,12 +47,12 @@ SOFTWARE. #include "../../props/props/prop_data.h" #endif -class VoxelStructure; -class VoxelChunk; +class TerraStructure; +class TerraChunk; class PropData; -class VoxelWorld : public Navigation { - GDCLASS(VoxelWorld, Navigation); +class TerraWorld : public Navigation { + GDCLASS(TerraWorld, Navigation); public: enum ChannelTypeInfo { @@ -94,11 +94,11 @@ public: int get_max_frame_chunk_build_steps() const; void set_max_frame_chunk_build_steps(const int value); - Ref get_library(); - void set_library(const Ref &library); + Ref get_library(); + void set_library(const Ref &library); - Ref get_level_generator() const; - void set_level_generator(const Ref &level_generator); + Ref get_level_generator() const; + void set_level_generator(const Ref &level_generator); float get_voxel_scale() const; void set_voxel_scale(const float value); @@ -114,41 +114,41 @@ public: void set_player_bind(Node *player); //World Areas - Ref world_area_get(const int index) const; - void world_area_add(const Ref &area); + Ref world_area_get(const int index) const; + void world_area_add(const Ref &area); void world_area_remove(const int index); void world_areas_clear(); int world_area_get_count() const; - //Voxel Structures - Ref voxel_structure_get(const int index) const; - void voxel_structure_add(const Ref &structure); - void voxel_structure_remove(const Ref &structure); + //Terra Structures + Ref voxel_structure_get(const int index) const; + void voxel_structure_add(const Ref &structure); + void voxel_structure_remove(const Ref &structure); void voxel_structure_remove_index(const int index); void voxel_structures_clear(); int voxel_structure_get_count() const; - void voxel_structure_add_at_position(Ref structure, const Vector3 &world_position); + void voxel_structure_add_at_position(Ref structure, const Vector3 &world_position); Vector voxel_structures_get(); void voxel_structures_set(const Vector &structures); //Chunks - void chunk_add(Ref chunk, const int x, const int y, const int z); + void chunk_add(Ref chunk, const int x, const int y, const int z); bool chunk_has(const int x, const int y, const int z) const; - Ref chunk_get(const int x, const int y, const int z); - Ref chunk_remove(const int x, const int y, const int z); - Ref chunk_remove_index(const int index); - Ref chunk_get_index(const int index); + Ref chunk_get(const int x, const int y, const int z); + Ref chunk_remove(const int x, const int y, const int z); + Ref chunk_remove_index(const int index); + Ref chunk_get_index(const int index); int chunk_get_count() const; void chunks_clear(); - Ref chunk_get_or_create(const int x, const int y, const int z); - Ref chunk_create(const int x, const int y, const int z); - void chunk_setup(Ref chunk); + Ref chunk_get_or_create(const int x, const int y, const int z); + Ref chunk_create(const int x, const int y, const int z); + void chunk_setup(Ref chunk); - void chunk_generate(Ref chunk); + void chunk_generate(Ref chunk); Vector chunks_get(); void chunks_set(const Vector &chunks); @@ -156,15 +156,15 @@ public: bool can_chunk_do_build_step(); bool is_position_walkable(const Vector3 &p_pos); - void on_chunk_mesh_generation_finished(Ref p_chunk); + void on_chunk_mesh_generation_finished(Ref p_chunk); - void generation_queue_add_to(const Ref &chunk); - Ref generation_queue_get_index(const int index); + void generation_queue_add_to(const Ref &chunk); + Ref generation_queue_get_index(const int index); void generation_queue_remove_index(const int index); int generation_queue_get_size() const; - void generation_add_to(const Ref &chunk); - Ref generation_get_index(const int index); + void generation_add_to(const Ref &chunk); + Ref generation_get_index(const int index); void generation_remove_index(const int index); int generation_get_size() const; @@ -173,8 +173,8 @@ public: #endif //Lights - void light_add(const Ref &light); - Ref light_get(const int index); + void light_add(const Ref &light); + Ref light_get(const int index); void light_remove(const int index); int light_get_count() const; void lights_clear(); @@ -185,18 +185,18 @@ public: //Helpers uint8_t get_voxel_at_world_position(const Vector3 &world_position, const int channel_index); void set_voxel_at_world_position(const Vector3 &world_position, const uint8_t data, const int channel_index, const bool rebuild = true); - Ref get_chunk_at_world_position(const Vector3 &world_position); - Ref get_or_create_chunk_at_world_position(const Vector3 &world_position); + Ref get_chunk_at_world_position(const Vector3 &world_position); + Ref get_or_create_chunk_at_world_position(const Vector3 &world_position); void set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel); int get_channel_index_info(const ChannelTypeInfo channel_type); - VoxelWorld(); - ~VoxelWorld(); + TerraWorld(); + ~TerraWorld(); protected: - virtual void _generate_chunk(Ref chunk); - virtual Ref _create_chunk(int x, int y, int z, Ref p_chunk); + virtual void _generate_chunk(Ref chunk); + virtual Ref _create_chunk(int x, int y, int z, Ref p_chunk); virtual int _get_channel_index_info(const ChannelTypeInfo channel_type); virtual void _set_voxel_with_tool(const bool mode_add, const Vector3 hit_position, const Vector3 hit_normal, const int selected_voxel, const int isolevel); @@ -248,35 +248,35 @@ private: int _data_margin_start; int _data_margin_end; - Ref _library; - Ref _level_generator; + Ref _library; + Ref _level_generator; float _voxel_scale; int _chunk_spawn_range; - HashMap, IntPosHasher> _chunks; - Vector > _chunks_vector; + HashMap, IntPosHasher> _chunks; + Vector > _chunks_vector; - Vector > _world_areas; + Vector > _world_areas; - Vector > _voxel_structures; + Vector > _voxel_structures; NodePath _player_path; Spatial *_player; bool _use_threads; int _max_concurrent_generations; - Vector > _generation_queue; - Vector > _generating; + Vector > _generation_queue; + Vector > _generating; int _max_frame_chunk_build_steps; int _num_frame_chunk_build_steps; - Vector > _lights; + Vector > _lights; }; -_FORCE_INLINE_ bool operator==(const VoxelWorld::IntPos &a, const VoxelWorld::IntPos &b) { +_FORCE_INLINE_ bool operator==(const TerraWorld::IntPos &a, const TerraWorld::IntPos &b) { return a.x == b.x && a.y == b.y && a.z == b.z; } -VARIANT_ENUM_CAST(VoxelWorld::ChannelTypeInfo); +VARIANT_ENUM_CAST(TerraWorld::ChannelTypeInfo); #endif diff --git a/world/voxel_world_editor.cpp b/world/voxel_world_editor.cpp index 44e20e7..bcf8b12 100644 --- a/world/voxel_world_editor.cpp +++ b/world/voxel_world_editor.cpp @@ -42,7 +42,7 @@ SOFTWARE. #include spatial_editor_plugin_h #include camera_h -bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { +bool TerraWorldEditor::forward_spatial_input_event(Camera *p_camera, const Ref &p_event) { if (!_world || !_world->get_editable()) { return false; } @@ -51,7 +51,7 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Refis_pressed()) { - Ref lib = _world->get_library(); + Ref lib = _world->get_library(); if (!lib.is_valid()) return false; @@ -69,7 +69,7 @@ bool VoxelWorldEditor::forward_spatial_input_event(Camera *p_camera, const Refis_inside_world()) return false; @@ -114,14 +114,14 @@ bool VoxelWorldEditor::do_input_action(Camera *p_camera, const Point2 &p_point, return false; } -void VoxelWorldEditor::edit(VoxelWorld *p_world) { +void TerraWorldEditor::edit(TerraWorld *p_world) { _world = p_world; if (!_world) return; - _channel_type = _world->get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_TYPE); - _channel_isolevel = _world->get_channel_index_info(VoxelWorld::CHANNEL_TYPE_INFO_ISOLEVEL); + _channel_type = _world->get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_TYPE); + _channel_isolevel = _world->get_channel_index_info(TerraWorld::CHANNEL_TYPE_INFO_ISOLEVEL); if (_channel_isolevel == -1) { _isolevel_slider->hide(); @@ -139,7 +139,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) { } } - Ref library = _world->get_library(); + Ref library = _world->get_library(); if (!library.is_valid()) return; @@ -149,7 +149,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) { bool f = false; for (int i = 0; i < library->voxel_surface_get_num(); ++i) { - Ref surface = library->voxel_surface_get(i); + Ref surface = library->voxel_surface_get(i); if (!surface.is_valid()) continue; @@ -164,7 +164,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) { button->set_button_group(_surfaces_button_group); button->set_h_size_flags(SIZE_EXPAND_FILL); - button->CONNECT("button_up", this, VoxelWorldEditor, _on_surface_button_pressed); + button->CONNECT("button_up", this, TerraWorldEditor, _on_surface_button_pressed); _surfaces_vbox_container->add_child(button); @@ -175,7 +175,7 @@ void VoxelWorldEditor::edit(VoxelWorld *p_world) { } } -VoxelWorldEditor::VoxelWorldEditor() { +TerraWorldEditor::TerraWorldEditor() { _world = NULL; _selected_type = 0; _channel_type = -1; @@ -184,7 +184,7 @@ VoxelWorldEditor::VoxelWorldEditor() { _editor = NULL; _tool_mode = TOOL_MODE_ADD; } -VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { +TerraWorldEditor::TerraWorldEditor(EditorNode *p_editor) { _world = NULL; _selected_type = 0; _channel_type = -1; @@ -208,7 +208,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { add_button->set_button_group(_tool_button_group); add_button->set_meta("tool_mode", TOOL_MODE_ADD); - add_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed); + add_button->CONNECT("button_up", this, TerraWorldEditor, _on_tool_button_pressed); add_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/add_mode", "Add Mode", KEY_A)); spatial_editor_hb->add_child(add_button); @@ -219,7 +219,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { remove_button->set_button_group(_tool_button_group); remove_button->set_meta("tool_mode", TOOL_MODE_REMOVE); - remove_button->CONNECT("button_up", this, VoxelWorldEditor, _on_tool_button_pressed); + remove_button->CONNECT("button_up", this, TerraWorldEditor, _on_tool_button_pressed); remove_button->set_shortcut(ED_SHORTCUT("voxelman_world_editor/remove_mode", "Remove Mode", KEY_S)); spatial_editor_hb->add_child(remove_button); @@ -227,7 +227,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { ToolButton *insert_buton = memnew(ToolButton); insert_buton->set_text("Insert"); - insert_buton->CONNECT("button_up", this, VoxelWorldEditor, _on_insert_block_at_camera_button_pressed); + insert_buton->CONNECT("button_up", this, TerraWorldEditor, _on_insert_block_at_camera_button_pressed); insert_buton->set_shortcut(ED_SHORTCUT("voxelman_world_editor/instert_block_at_camera", "Insert at camera", KEY_B)); spatial_editor_hb->add_child(insert_buton); @@ -242,7 +242,7 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { _isolevel_slider->set_v_size_flags(SIZE_EXPAND_FILL); spatial_editor_hb->add_child(_isolevel_slider); - _isolevel_slider->CONNECT("value_changed", this, VoxelWorldEditor, _on_isolevel_slider_value_changed); + _isolevel_slider->CONNECT("value_changed", this, TerraWorldEditor, _on_isolevel_slider_value_changed); _isolevel_slider->hide(); @@ -258,18 +258,18 @@ VoxelWorldEditor::VoxelWorldEditor(EditorNode *p_editor) { _surfaces_button_group.instance(); } -VoxelWorldEditor::~VoxelWorldEditor() { +TerraWorldEditor::~TerraWorldEditor() { _world = NULL; _surfaces_button_group.unref(); } -void VoxelWorldEditor::_node_removed(Node *p_node) { +void TerraWorldEditor::_node_removed(Node *p_node) { if (p_node == _world) _world = NULL; } -void VoxelWorldEditor::_on_surface_button_pressed() { +void TerraWorldEditor::_on_surface_button_pressed() { BaseButton *button = _surfaces_button_group->get_pressed_button(); if (button) { @@ -277,15 +277,15 @@ void VoxelWorldEditor::_on_surface_button_pressed() { } } -void VoxelWorldEditor::_on_tool_button_pressed() { +void TerraWorldEditor::_on_tool_button_pressed() { BaseButton *button = _tool_button_group->get_pressed_button(); if (button) { - _tool_mode = static_cast(static_cast(button->get_meta("tool_mode"))); + _tool_mode = static_cast(static_cast(button->get_meta("tool_mode"))); } } -void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() { +void TerraWorldEditor::_on_insert_block_at_camera_button_pressed() { int selected_voxel = 0; int channel = 0; @@ -315,19 +315,19 @@ void VoxelWorldEditor::_on_insert_block_at_camera_button_pressed() { } } -void VoxelWorldEditor::_on_isolevel_slider_value_changed(float value) { +void TerraWorldEditor::_on_isolevel_slider_value_changed(float value) { _current_isolevel = value; } -void VoxelWorldEditor::_bind_methods() { - ClassDB::bind_method("_node_removed", &VoxelWorldEditor::_node_removed); - ClassDB::bind_method("_on_surface_button_pressed", &VoxelWorldEditor::_on_surface_button_pressed); - ClassDB::bind_method("_on_tool_button_pressed", &VoxelWorldEditor::_on_tool_button_pressed); - ClassDB::bind_method("_on_insert_block_at_camera_button_pressed", &VoxelWorldEditor::_on_insert_block_at_camera_button_pressed); - ClassDB::bind_method("_on_isolevel_slider_value_changed", &VoxelWorldEditor::_on_isolevel_slider_value_changed); +void TerraWorldEditor::_bind_methods() { + ClassDB::bind_method("_node_removed", &TerraWorldEditor::_node_removed); + ClassDB::bind_method("_on_surface_button_pressed", &TerraWorldEditor::_on_surface_button_pressed); + ClassDB::bind_method("_on_tool_button_pressed", &TerraWorldEditor::_on_tool_button_pressed); + ClassDB::bind_method("_on_insert_block_at_camera_button_pressed", &TerraWorldEditor::_on_insert_block_at_camera_button_pressed); + ClassDB::bind_method("_on_isolevel_slider_value_changed", &TerraWorldEditor::_on_isolevel_slider_value_changed); } -void VoxelWorldEditorPlugin::_notification(int p_what) { +void TerraWorldEditorPlugin::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { switch ((int)EditorSettings::get_singleton()->get("editors/voxelman/editor_side")) { case 0: { // Left. @@ -340,20 +340,20 @@ void VoxelWorldEditorPlugin::_notification(int p_what) { } } -void VoxelWorldEditorPlugin::edit(Object *p_object) { - voxel_world_editor->edit(Object::cast_to(p_object)); +void TerraWorldEditorPlugin::edit(Object *p_object) { + voxel_world_editor->edit(Object::cast_to(p_object)); } -bool VoxelWorldEditorPlugin::handles(Object *p_object) const { - if (!p_object->is_class("VoxelWorld")) +bool TerraWorldEditorPlugin::handles(Object *p_object) const { + if (!p_object->is_class("TerraWorld")) return false; - VoxelWorld *w = Object::cast_to(p_object); + TerraWorld *w = Object::cast_to(p_object); return w->get_editable(); } -void VoxelWorldEditorPlugin::make_visible(bool p_visible) { +void TerraWorldEditorPlugin::make_visible(bool p_visible) { if (p_visible) { voxel_world_editor->show(); voxel_world_editor->spatial_editor_hb->show(); @@ -366,13 +366,13 @@ void VoxelWorldEditorPlugin::make_visible(bool p_visible) { } } -VoxelWorldEditorPlugin::VoxelWorldEditorPlugin(EditorNode *p_node) { +TerraWorldEditorPlugin::TerraWorldEditorPlugin(EditorNode *p_node) { editor = p_node; EDITOR_DEF("editors/voxelman/editor_side", 1); EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::INT, "editors/voxelman/editor_side", PROPERTY_HINT_ENUM, "Left,Right")); - voxel_world_editor = memnew(VoxelWorldEditor(editor)); + voxel_world_editor = memnew(TerraWorldEditor(editor)); switch ((int)EditorSettings::get_singleton()->get("editors/voxelman/editor_side")) { case 0: { // Left. add_control_to_container(CONTAINER_SPATIAL_EDITOR_SIDE_LEFT, voxel_world_editor); @@ -384,5 +384,5 @@ VoxelWorldEditorPlugin::VoxelWorldEditorPlugin(EditorNode *p_node) { voxel_world_editor->hide(); } -VoxelWorldEditorPlugin::~VoxelWorldEditorPlugin() { +TerraWorldEditorPlugin::~TerraWorldEditorPlugin() { } diff --git a/world/voxel_world_editor.h b/world/voxel_world_editor.h index 7195940..daa9225 100644 --- a/world/voxel_world_editor.h +++ b/world/voxel_world_editor.h @@ -20,22 +20,22 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef VOXEL_WORLD_EDITOR_PLUGIN_H -#define VOXEL_WORLD_EDITOR_PLUGIN_H +#ifndef TERRA_WORLD_EDITOR_PLUGIN_H +#define TERRA_WORLD_EDITOR_PLUGIN_H #include "editor/editor_node.h" #include "editor/editor_plugin.h" #include "../defines.h" -class VoxelWorld; +class TerraWorld; class SpatialEditorPlugin; -class VoxelWorldEditor : public PanelContainer { - GDCLASS(VoxelWorldEditor, PanelContainer); +class TerraWorldEditor : public PanelContainer { + GDCLASS(TerraWorldEditor, PanelContainer); public: - enum VoxelWorldEditorToolMode { + enum TerraWorldEditorToolMode { TOOL_MODE_ADD = 0, TOOL_MODE_REMOVE, }; @@ -43,12 +43,12 @@ public: public: bool forward_spatial_input_event(Camera *p_camera, const Ref &p_event); - void edit(VoxelWorld *p_world); + void edit(TerraWorld *p_world); bool do_input_action(Camera *p_camera, const Point2 &p_point, bool p_click); - VoxelWorldEditor(); - VoxelWorldEditor(EditorNode *p_editor); - ~VoxelWorldEditor(); + TerraWorldEditor(); + TerraWorldEditor(EditorNode *p_editor); + ~TerraWorldEditor(); HBoxContainer *spatial_editor_hb; @@ -66,8 +66,8 @@ private: Ref _tool_button_group; - VoxelWorldEditorToolMode _tool_mode; - VoxelWorld *_world; + TerraWorldEditorToolMode _tool_mode; + TerraWorld *_world; HSlider *_isolevel_slider; @@ -81,10 +81,10 @@ private: int _channel_isolevel; }; -class VoxelWorldEditorPlugin : public EditorPlugin { - GDCLASS(VoxelWorldEditorPlugin, EditorPlugin); +class TerraWorldEditorPlugin : public EditorPlugin { + GDCLASS(TerraWorldEditorPlugin, EditorPlugin); - VoxelWorldEditor *voxel_world_editor; + TerraWorldEditor *voxel_world_editor; EditorNode *editor; protected: @@ -92,14 +92,14 @@ protected: public: virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref &p_event) { return voxel_world_editor->forward_spatial_input_event(p_camera, p_event); } - virtual String get_name() const { return "VoxelWorldEditor"; } + virtual String get_name() const { return "TerraWorldEditor"; } bool has_main_screen() const { return false; } virtual void edit(Object *p_object); virtual bool handles(Object *p_object) const; virtual void make_visible(bool p_visible); - VoxelWorldEditorPlugin(EditorNode *p_node); - ~VoxelWorldEditorPlugin(); + TerraWorldEditorPlugin(EditorNode *p_node); + ~TerraWorldEditorPlugin(); }; #endif