From 460f38090b2f5b0de5f5943fa23dc92390a95932 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 2 Aug 2021 19:03:56 +0200 Subject: [PATCH] Added a new TerraMaterialCachePCM class to be used with the material cache pcm. Skeleton for now. --- SCsub | 1 + config.py | 1 + library/terra_material_cache_pcm.cpp | 63 ++++++++++++++++++++++++ library/terra_material_cache_pcm.h | 69 +++++++++++++++++++++++++++ library/terraman_library_merger_pcm.h | 2 +- register_types.cpp | 9 ++-- 6 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 library/terra_material_cache_pcm.cpp create mode 100644 library/terra_material_cache_pcm.h diff --git a/SCsub b/SCsub index 7eb2c13..de808a7 100644 --- a/SCsub +++ b/SCsub @@ -74,6 +74,7 @@ if has_texture_packer: sources.append("library/terraman_library_merger.cpp") sources.append("library/terraman_library_merger_pcm.cpp") sources.append("library/terra_surface_merger.cpp") + sources.append("library/terra_material_cache_pcm.cpp") if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation diff --git a/config.py b/config.py index 58f8405..c9be95a 100644 --- a/config.py +++ b/config.py @@ -27,6 +27,7 @@ def get_doc_classes(): "TerramanLibraryMergerPCM", "TerraMaterialCache", + "TerraMaterialCachePCM", "TerraCubePoints", "TerraMesherCubic", diff --git a/library/terra_material_cache_pcm.cpp b/library/terra_material_cache_pcm.cpp new file mode 100644 index 0000000..591a16c --- /dev/null +++ b/library/terra_material_cache_pcm.cpp @@ -0,0 +1,63 @@ +/* +Copyright (c) 2019-2021 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#include "terra_material_cache_pcm.h" + +#include "terra_surface.h" + +//Surfaces +Ref TerraMaterialCachePCM::voxel_surface_get(const int index) { + return Ref(); +} +void TerraMaterialCachePCM::voxel_surface_add(Ref value) { +} +void TerraMaterialCachePCM::voxel_surface_set(int index, Ref value) { +} +void TerraMaterialCachePCM::voxel_surface_remove(const int index) { +} +int TerraMaterialCachePCM::voxel_surface_get_num() const { + return 0; +} +void TerraMaterialCachePCM::voxel_surfaces_clear() { +} + +void TerraMaterialCachePCM::refresh_rects() { +} + +TerraMaterialCachePCM::TerraMaterialCachePCM() { +} + +TerraMaterialCachePCM::~TerraMaterialCachePCM() { +} + +void TerraMaterialCachePCM::_bind_methods() { + BIND_VMETHOD(MethodInfo("_setup_material_albedo", PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"))); + + ClassDB::bind_method(D_METHOD("voxel_surface_get", "index"), &TerraMaterialCachePCM::voxel_surface_get); + ClassDB::bind_method(D_METHOD("voxel_surface_add", "value"), &TerraMaterialCachePCM::voxel_surface_add); + ClassDB::bind_method(D_METHOD("voxel_surface_set", "index", "surface"), &TerraMaterialCachePCM::voxel_surface_set); + ClassDB::bind_method(D_METHOD("voxel_surface_remove", "index"), &TerraMaterialCachePCM::voxel_surface_remove); + ClassDB::bind_method(D_METHOD("voxel_surface_get_num"), &TerraMaterialCachePCM::voxel_surface_get_num); + ClassDB::bind_method(D_METHOD("voxel_surfaces_clear"), &TerraMaterialCachePCM::voxel_surfaces_clear); + + ClassDB::bind_method(D_METHOD("refresh_rects"), &TerraMaterialCachePCM::refresh_rects); +} diff --git a/library/terra_material_cache_pcm.h b/library/terra_material_cache_pcm.h new file mode 100644 index 0000000..393e577 --- /dev/null +++ b/library/terra_material_cache_pcm.h @@ -0,0 +1,69 @@ +/* +Copyright (c) 2019-2021 Péter Magyar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +#ifndef TERRA_MATERIAL_CACHE_PCM_H +#define TERRA_MATERIAL_CACHE_PCM_H + +#include "terra_material_cache.h" + +#include "core/version.h" + +#if VERSION_MAJOR > 3 +#include "core/io/resource.h" +#include "core/math/color.h" +#include "core/templates/vector.h" +#else +#include "core/color.h" +#include "core/resource.h" +#include "core/vector.h" +#endif + +#include "core/math/rect2.h" +#include "scene/resources/material.h" + +#include "../defines.h" + +class TerraSurface; + +class TerraMaterialCachePCM : public TerraMaterialCache { + GDCLASS(TerraMaterialCachePCM, TerraMaterialCache); + +public: + 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(); + + void refresh_rects(); + + TerraMaterialCachePCM(); + ~TerraMaterialCachePCM(); + +protected: + static void _bind_methods(); + + //Ref merger; +}; + +#endif diff --git a/library/terraman_library_merger_pcm.h b/library/terraman_library_merger_pcm.h index cde23a4..1f9b0e6 100644 --- a/library/terraman_library_merger_pcm.h +++ b/library/terraman_library_merger_pcm.h @@ -38,7 +38,7 @@ SOFTWARE. //pcm = per chunk material class TerramanLibraryMergerPCM : public TerramanLibraryMerger { //inherit it from the normal library? - GDCLASS(TerramanLibraryMergerPCM, TerramanLibraryMerger) + GDCLASS(TerramanLibraryMergerPCM, TerramanLibraryMerger); public: bool _supports_caching(); diff --git a/register_types.cpp b/register_types.cpp index 6f70816..7757215 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -22,26 +22,26 @@ SOFTWARE. #include "register_types.h" - #include "library/terra_surface.h" #include "library/terra_surface_simple.h" +#include "library/terra_material_cache.h" #include "library/terraman_library.h" #include "library/terraman_library_simple.h" -#include "library/terra_material_cache.h" #ifdef TEXTURE_PACKER_PRESENT #include "library/terra_surface_merger.h" #include "library/terraman_library_merger.h" #include "library/terraman_library_merger_pcm.h" +#include "library/terra_material_cache_pcm.h" #endif #include "data/terra_light.h" #include "meshers/terra_mesher.h" #include "world/block_terra_structure.h" -#include "world/terra_environment_data.h" #include "world/terra_chunk.h" +#include "world/terra_environment_data.h" #include "world/terra_structure.h" #include "world/terra_world.h" @@ -65,9 +65,9 @@ SOFTWARE. #include "world/jobs/terra_job.h" #include "world/jobs/terra_light_job.h" +#include "world/jobs/terra_mesher_job_step.h" #include "world/jobs/terra_prop_job.h" #include "world/jobs/terra_terrarin_job.h" -#include "world/jobs/terra_mesher_job_step.h" void register_terraman_types() { ClassDB::register_class(); @@ -85,6 +85,7 @@ void register_terraman_types() { ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + ClassDB::register_class(); #endif ClassDB::register_class();