From 919080a1b5b6a6d7b0013c777b1ee7e41e206683 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sun, 16 Feb 2020 02:54:17 +0100 Subject: [PATCH] Added props top the merger library, also it will now merge together all added prop textures. Also api cleanups. --- library/voxelman_library.cpp | 50 +++++++-- library/voxelman_library.h | 26 +++-- library/voxelman_library_merger.cpp | 165 ++++++++++++++++++++++++++-- library/voxelman_library_merger.h | 35 ++++-- library/voxelman_library_simple.cpp | 18 +-- library/voxelman_library_simple.h | 18 +-- props/prop_data.cpp | 8 ++ props/prop_data.h | 4 + 8 files changed, 266 insertions(+), 58 deletions(-) diff --git a/library/voxelman_library.cpp b/library/voxelman_library.cpp index 628d5b2..ce91c4c 100644 --- a/library/voxelman_library.cpp +++ b/library/voxelman_library.cpp @@ -22,6 +22,8 @@ SOFTWARE. #include "voxelman_library.h" +#include "../props/prop_data.h" + Ref VoxelmanLibrary::get_material() const { return _material; } @@ -51,37 +53,52 @@ void VoxelmanLibrary::set_clutter_material(Ref mat) { } //Surfaces -Ref VoxelmanLibrary::get_voxel_surface(int index) const { +Ref VoxelmanLibrary::get_voxel_surface(const int index) { return Ref(); } void VoxelmanLibrary::add_voxel_surface(Ref value) { } -void VoxelmanLibrary::set_voxel_surface(int index, Ref value) { +void VoxelmanLibrary::set_voxel_surface(const int index, Ref value) { } -void VoxelmanLibrary::remove_surface(int index) { +void VoxelmanLibrary::remove_surface(const int index) { } -int VoxelmanLibrary::get_num_surfaces() { +int VoxelmanLibrary::get_num_surfaces() const { return 0; } void VoxelmanLibrary::clear_surfaces() { } //Liquids -Ref VoxelmanLibrary::get_liquid_voxel_surface(int index) const { +Ref VoxelmanLibrary::get_liquid_surface(const int index) { return Ref(); } -void VoxelmanLibrary::add_liquid_voxel_surface(Ref value) { +void VoxelmanLibrary::add_liquid_surface(Ref value) { } -void VoxelmanLibrary::set_liquid_voxel_surface(int index, Ref value) { +void VoxelmanLibrary::set_liquid_surface(const int index, Ref value) { } -void VoxelmanLibrary::remove_liquid_surface(int index) { +void VoxelmanLibrary::remove_liquid_surface(const int index) { } -int VoxelmanLibrary::get_liquid_num_surfaces() { +int VoxelmanLibrary::get_num_liquid_surfaces() const { return 0; } void VoxelmanLibrary::clear_liquid_surfaces() { } +Ref VoxelmanLibrary::get_prop(const int id) { + return Ref(); +} +void VoxelmanLibrary::add_prop(Ref value) { +} +void VoxelmanLibrary::set_prop(const int id, Ref value) { +} +void VoxelmanLibrary::remove_prop(const int id) { +} +int VoxelmanLibrary::get_num_props() const { + return 0; +} +void VoxelmanLibrary::clear_props() { +} + //Rects void VoxelmanLibrary::refresh_rects() { } @@ -121,17 +138,26 @@ void VoxelmanLibrary::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "clutter_material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_clutter_material", "get_clutter_material"); ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &VoxelmanLibrary::get_voxel_surface); + ClassDB::bind_method(D_METHOD("add_voxel_surface", "value"), &VoxelmanLibrary::add_voxel_surface); ClassDB::bind_method(D_METHOD("set_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_voxel_surface); ClassDB::bind_method(D_METHOD("remove_surface", "index"), &VoxelmanLibrary::remove_surface); ClassDB::bind_method(D_METHOD("get_num_surfaces"), &VoxelmanLibrary::get_num_surfaces); ClassDB::bind_method(D_METHOD("clear_surfaces"), &VoxelmanLibrary::clear_surfaces); - ClassDB::bind_method(D_METHOD("get_liquid_voxel_surface", "index"), &VoxelmanLibrary::get_liquid_voxel_surface); - ClassDB::bind_method(D_METHOD("set_liquid_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_liquid_voxel_surface); + ClassDB::bind_method(D_METHOD("get_liquid_surface", "index"), &VoxelmanLibrary::get_liquid_surface); + ClassDB::bind_method(D_METHOD("add_liquid_surface", "value"), &VoxelmanLibrary::add_liquid_surface); + ClassDB::bind_method(D_METHOD("set_liquid_surface", "index", "surface"), &VoxelmanLibrary::set_liquid_surface); ClassDB::bind_method(D_METHOD("remove_liquid_surface", "index"), &VoxelmanLibrary::remove_liquid_surface); - ClassDB::bind_method(D_METHOD("get_liquid_num_surfaces"), &VoxelmanLibrary::get_liquid_num_surfaces); + ClassDB::bind_method(D_METHOD("get_num_liquid_surfaces"), &VoxelmanLibrary::get_num_liquid_surfaces); ClassDB::bind_method(D_METHOD("clear_liquid_surfaces"), &VoxelmanLibrary::clear_liquid_surfaces); + ClassDB::bind_method(D_METHOD("get_prop", "id"), &VoxelmanLibrary::get_prop); + ClassDB::bind_method(D_METHOD("add_prop", "value"), &VoxelmanLibrary::add_prop); + ClassDB::bind_method(D_METHOD("set_prop", "id", "surface"), &VoxelmanLibrary::set_prop); + ClassDB::bind_method(D_METHOD("remove_prop", "id"), &VoxelmanLibrary::remove_prop); + ClassDB::bind_method(D_METHOD("get_num_props"), &VoxelmanLibrary::get_num_props); + ClassDB::bind_method(D_METHOD("clear_props"), &VoxelmanLibrary::clear_props); + ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelmanLibrary::refresh_rects); ClassDB::bind_method(D_METHOD("setup_material_albedo", "material_index", "texture"), &VoxelmanLibrary::setup_material_albedo); diff --git a/library/voxelman_library.h b/library/voxelman_library.h index deaa8c9..e057e9a 100644 --- a/library/voxelman_library.h +++ b/library/voxelman_library.h @@ -31,6 +31,7 @@ SOFTWARE. class VoxelSurface; class VoxelMesher; +class PropData; class VoxelmanLibrary : public Resource { GDCLASS(VoxelmanLibrary, Resource) @@ -56,20 +57,27 @@ public: Ref get_clutter_material() const; void set_clutter_material(Ref mat); - virtual Ref get_voxel_surface(int index) const; + virtual Ref get_voxel_surface(const int index); virtual void add_voxel_surface(Ref value); - virtual void set_voxel_surface(int index, Ref value); - virtual void remove_surface(int index); - virtual int get_num_surfaces(); + virtual void set_voxel_surface(const int index, Ref value); + virtual void remove_surface(const int index); + virtual int get_num_surfaces() const; virtual void clear_surfaces(); - virtual Ref get_liquid_voxel_surface(int index) const; - virtual void add_liquid_voxel_surface(Ref value); - virtual void set_liquid_voxel_surface(int index, Ref value); - virtual void remove_liquid_surface(int index); - virtual int get_liquid_num_surfaces(); + virtual Ref get_liquid_surface(const int index); + virtual void add_liquid_surface(Ref value); + virtual void set_liquid_surface(const int index, Ref value); + virtual void remove_liquid_surface(const int index); + virtual int get_num_liquid_surfaces() const; virtual void clear_liquid_surfaces(); + virtual Ref get_prop(const int id); + virtual void add_prop(Ref value); + virtual void set_prop(const int id, Ref value); + virtual void remove_prop(const int id); + virtual int get_num_props() const; + virtual void clear_props(); + virtual void refresh_rects(); void setup_material_albedo(int material_index, Ref texture); diff --git a/library/voxelman_library_merger.cpp b/library/voxelman_library_merger.cpp index 44fc815..12fbe76 100644 --- a/library/voxelman_library_merger.cpp +++ b/library/voxelman_library_merger.cpp @@ -22,11 +22,18 @@ SOFTWARE. #include "voxelman_library_merger.h" +#include "scene/resources/texture.h" + +#include "../props/prop_data.h" +#include "../props/prop_data_mesh.h" +#include "../props/prop_data_prop.h" + int VoxelmanLibraryMerger::get_texture_flags() const { return _packer->get_texture_flags(); } void VoxelmanLibraryMerger::set_texture_flags(const int flags) { _packer->set_texture_flags(flags); + _prop_packer->set_texture_flags(flags); } int VoxelmanLibraryMerger::get_max_atlas_size() const { @@ -34,6 +41,7 @@ int VoxelmanLibraryMerger::get_max_atlas_size() const { } void VoxelmanLibraryMerger::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 { @@ -41,6 +49,7 @@ bool VoxelmanLibraryMerger::get_keep_original_atlases() const { } void VoxelmanLibraryMerger::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 { @@ -48,6 +57,7 @@ Color VoxelmanLibraryMerger::get_background_color() const { } void VoxelmanLibraryMerger::set_background_color(const Color color) { _packer->set_background_color(color); + _prop_packer->set_background_color(color); } int VoxelmanLibraryMerger::get_margin() const { @@ -55,10 +65,11 @@ int VoxelmanLibraryMerger::get_margin() const { } void VoxelmanLibraryMerger::set_margin(const int margin) { _packer->set_margin(margin); + _prop_packer->set_margin(margin); } //Surfaces -Ref VoxelmanLibraryMerger::get_voxel_surface(int index) const { +Ref VoxelmanLibraryMerger::get_voxel_surface(const int index) { ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); return _voxel_surfaces[index]; @@ -73,7 +84,7 @@ void VoxelmanLibraryMerger::add_voxel_surface(Ref value) { _voxel_surfaces.push_back(value); } -void VoxelmanLibraryMerger::set_voxel_surface(int index, Ref value) { +void VoxelmanLibraryMerger::set_voxel_surface(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_voxel_surfaces.size() < index) { @@ -91,11 +102,11 @@ void VoxelmanLibraryMerger::set_voxel_surface(int index, Ref value } } -void VoxelmanLibraryMerger::remove_surface(int index) { +void VoxelmanLibraryMerger::remove_surface(const int index) { _voxel_surfaces.remove(index); } -int VoxelmanLibraryMerger::get_num_surfaces() { +int VoxelmanLibraryMerger::get_num_surfaces() const { return _voxel_surfaces.size(); } @@ -146,13 +157,13 @@ void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector &surfaces) } //Liquids -Ref VoxelmanLibraryMerger::get_liquid_voxel_surface(int index) const { +Ref VoxelmanLibraryMerger::get_liquid_voxel_surface(const int index) { ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref(NULL)); return _liquid_surfaces[index]; } -void VoxelmanLibraryMerger::add_liquid_voxel_surface(Ref value) { +void VoxelmanLibraryMerger::add_liquid_surface(Ref value) { ERR_FAIL_COND(!value.is_valid()); value->set_library(Ref(this)); @@ -161,7 +172,7 @@ void VoxelmanLibraryMerger::add_liquid_voxel_surface(Ref value) { _liquid_surfaces.push_back(value); } -void VoxelmanLibraryMerger::set_liquid_voxel_surface(int index, Ref value) { +void VoxelmanLibraryMerger::set_liquid_voxel_surface(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_liquid_surfaces.size() < index) { @@ -179,11 +190,11 @@ void VoxelmanLibraryMerger::set_liquid_voxel_surface(int index, Ref &sur } } +Ref VoxelmanLibraryMerger::get_prop(const int id) { + if (_props.has(id)) + return _props[id]; + + return Ref(); +} +void VoxelmanLibraryMerger::add_prop(Ref value) { + if (!value.is_valid() || _props.has(value->get_id())) + return; + + _props[value->get_id()] = value; +} +void VoxelmanLibraryMerger::set_prop(const int id, Ref value) { + _props[value->get_id()] = value; +} +void VoxelmanLibraryMerger::remove_prop(const int id) { + if (_props.has(id)) + _props.erase(id); +} +int VoxelmanLibraryMerger::get_num_props() const { + return _props.size(); +} +void VoxelmanLibraryMerger::clear_props() { + _props.clear(); +} + +/* +Vector VoxelmanLibraryMerger::get_props() { + Vector r; + + for (Map >::Element *I = _props.front(); I; I = I->next()) { + r.push_back(I->value().get_ref_ptr()); + } + + return r; +} + +void VoxelmanLibraryMerger::set_props(const Vector &props) { + _liquid_surfaces.clear(); + + for (int i = 0; i < props.size(); i++) { + Ref surface = Ref(props[i]); + + if (surface.is_valid()) { + surface->set_library(this); + } + + _liquid_surfaces.push_back(surface); + } +} +*/ + void VoxelmanLibraryMerger::refresh_rects() { bool texture_added = false; for (int i = 0; i < _voxel_surfaces.size(); i++) { @@ -281,6 +344,26 @@ void VoxelmanLibraryMerger::refresh_rects() { setup_material_albedo(MATERIAL_INDEX_VOXELS, tex); } + texture_added = false; + for (Map >::Element *I = _props.front(); I; I = I->next()) { + Ref prop = Ref(I->value()); + + if (prop.is_valid()) { + if (process_prop_textures(prop)) + texture_added = true; + } + } + + if (texture_added) { + _prop_packer->merge(); + + ERR_FAIL_COND(_prop_packer->get_texture_count() == 0); + + Ref tex = _prop_packer->get_generated_texture(0); + + setup_material_albedo(MATERIAL_INDEX_PROP, tex); + } + for (int i = 0; i < _voxel_surfaces.size(); i++) { Ref surface = _voxel_surfaces[i]; @@ -320,9 +403,25 @@ void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Refset_texture(SpatialMaterial::TEXTURE_ALBEDO, texture); + return; } - Ref shmat = get_material(); + Ref shmat; + + switch (material_index) { + case MATERIAL_INDEX_VOXELS: + shmat = get_material(); + break; + case MATERIAL_INDEX_PROP: + shmat = get_prop_material(); + break; + case MATERIAL_INDEX_LIQUID: + shmat = get_liquid_material(); + break; + case MATERIAL_INDEX_CLUTTER: + shmat = get_clutter_material(); + break; + } if (shmat.is_valid()) { shmat->set_shader_param("texture_albedo", texture); @@ -335,6 +434,12 @@ VoxelmanLibraryMerger::VoxelmanLibraryMerger() { _packer->set_max_atlas_size(1024); _packer->set_keep_original_atlases(false); _packer->set_margin(0); + + _prop_packer.instance(); + _prop_packer->set_texture_flags(Texture::FLAG_MIPMAPS | Texture::FLAG_FILTER); + _prop_packer->set_max_atlas_size(1024); + _prop_packer->set_keep_original_atlases(false); + _prop_packer->set_margin(0); } VoxelmanLibraryMerger::~VoxelmanLibraryMerger() { @@ -358,10 +463,46 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() { _liquid_surfaces.clear(); + _prop_packer->clear(); + _prop_packer.unref(); + _packer->clear(); _packer.unref(); } +bool VoxelmanLibraryMerger::process_prop_textures(Ref prop) { + if (!prop.is_valid()) { + return false; + } + + bool texture_added = false; + + for (int i = 0; i < prop->get_prop_count(); ++i) { + Ref pdm = prop->get_prop(i); + + if (pdm.is_valid()) { + Ref tex = pdm->get_texture(); + + if (!tex.is_valid()) + continue; + + if (!_prop_packer->contains_texture(tex)) { + _prop_packer->add_texture(tex); + texture_added = true; + } + } + + Ref pdp = prop->get_prop(i); + + if (pdp.is_valid()) { + if (process_prop_textures(pdp)) + texture_added = true; + } + } + + return texture_added; +} + 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); @@ -391,5 +532,9 @@ void VoxelmanLibraryMerger::_bind_methods() { ClassDB::bind_method(D_METHOD("set_liquid_voxel_surfaces"), &VoxelmanLibraryMerger::set_liquid_voxel_surfaces); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_voxel_surfaces", PROPERTY_HINT_NONE, "17/17:VoxelSurfaceMerger", PROPERTY_USAGE_DEFAULT, "VoxelSurfaceMerger"), "set_liquid_voxel_surfaces", "get_liquid_voxel_surfaces"); + //ClassDB::bind_method(D_METHOD("get_props"), &VoxelmanLibraryMerger::get_props); + //ClassDB::bind_method(D_METHOD("set_props"), &VoxelmanLibraryMerger::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("_setup_material_albedo", "material_index", "texture"), &VoxelmanLibraryMerger::_setup_material_albedo); } diff --git a/library/voxelman_library_merger.h b/library/voxelman_library_merger.h index 5879869..e4c8463 100644 --- a/library/voxelman_library_merger.h +++ b/library/voxelman_library_merger.h @@ -25,6 +25,7 @@ SOFTWARE. #include "voxelman_library.h" +#include "core/map.h" #include "core/resource.h" #include "scene/resources/material.h" @@ -33,6 +34,7 @@ SOFTWARE. class VoxelSurfaceSimple; class VoxelMesher; +class PropData; class VoxelmanLibraryMerger : public VoxelmanLibrary { GDCLASS(VoxelmanLibraryMerger, VoxelmanLibrary) @@ -53,26 +55,36 @@ public: int get_margin() const; void set_margin(const int margin); - Ref get_voxel_surface(int index) const; + Ref get_voxel_surface(const int index); void add_voxel_surface(Ref value); - void set_voxel_surface(int index, Ref value); - void remove_surface(int index); - int get_num_surfaces(); + void set_voxel_surface(const int index, Ref value); + void remove_surface(const int index); + int get_num_surfaces() const; void clear_surfaces(); Vector get_voxel_surfaces(); void set_voxel_surfaces(const Vector &surfaces); - Ref get_liquid_voxel_surface(int index) const; - void add_liquid_voxel_surface(Ref value); - void set_liquid_voxel_surface(int index, Ref value); - void remove_liquid_surface(int index); - int get_liquid_num_surfaces(); + Ref get_liquid_voxel_surface(const int index); + void add_liquid_surface(Ref value); + void set_liquid_voxel_surface(const int index, Ref value); + void remove_liquid_surface(const int index); + int get_num_liquid_surfaces() const; void clear_liquid_surfaces(); Vector get_liquid_voxel_surfaces(); void set_liquid_voxel_surfaces(const Vector &surfaces); + Ref get_prop(const int id); + void add_prop(Ref value); + void set_prop(const int id, Ref value); + void remove_prop(const int id); + int get_num_props() const; + void clear_props(); + + //Vector get_props(); + //void set_props(const Vector &props); + void refresh_rects(); void _setup_material_albedo(int material_index, Ref texture); @@ -81,13 +93,18 @@ public: ~VoxelmanLibraryMerger(); protected: + bool process_prop_textures(Ref prop); + static void _bind_methods(); private: Vector > _voxel_surfaces; Vector > _liquid_surfaces; + //Vector > _prop_vector; + Map > _props; Ref _packer; + Ref _prop_packer; }; #endif diff --git a/library/voxelman_library_simple.cpp b/library/voxelman_library_simple.cpp index b7d9d51..e2bf9e2 100644 --- a/library/voxelman_library_simple.cpp +++ b/library/voxelman_library_simple.cpp @@ -41,7 +41,7 @@ void VoxelmanLibrarySimple::set_atlas_rows(int s) { } //Surfaces -Ref VoxelmanLibrarySimple::get_voxel_surface(int index) const { +Ref VoxelmanLibrarySimple::get_voxel_surface(const int index) { ERR_FAIL_INDEX_V(index, _voxel_surfaces.size(), Ref(NULL)); return _voxel_surfaces[index]; @@ -56,7 +56,7 @@ void VoxelmanLibrarySimple::add_voxel_surface(Ref value) { _voxel_surfaces.push_back(value); } -void VoxelmanLibrarySimple::set_voxel_surface(int index, Ref value) { +void VoxelmanLibrarySimple::set_voxel_surface(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_voxel_surfaces.size() < index) { @@ -74,11 +74,11 @@ void VoxelmanLibrarySimple::set_voxel_surface(int index, Ref value } } -void VoxelmanLibrarySimple::remove_surface(int index) { +void VoxelmanLibrarySimple::remove_surface(const int index) { _voxel_surfaces.remove(index); } -int VoxelmanLibrarySimple::get_num_surfaces() { +int VoxelmanLibrarySimple::get_num_surfaces() const { return _voxel_surfaces.size(); } @@ -110,13 +110,13 @@ void VoxelmanLibrarySimple::set_voxel_surfaces(const Vector &surfaces) } //Liquids -Ref VoxelmanLibrarySimple::get_liquid_voxel_surface(int index) const { +Ref VoxelmanLibrarySimple::get_liquid_surface(const int index) { ERR_FAIL_INDEX_V(index, _liquid_surfaces.size(), Ref(NULL)); return _liquid_surfaces[index]; } -void VoxelmanLibrarySimple::add_liquid_voxel_surface(Ref value) { +void VoxelmanLibrarySimple::add_liquid_surface(Ref value) { ERR_FAIL_COND(!value.is_valid()); value->set_library(Ref(this)); @@ -125,7 +125,7 @@ void VoxelmanLibrarySimple::add_liquid_voxel_surface(Ref value) { _liquid_surfaces.push_back(value); } -void VoxelmanLibrarySimple::set_liquid_voxel_surface(int index, Ref value) { +void VoxelmanLibrarySimple::set_liquid_surface(const int index, Ref value) { ERR_FAIL_COND(index < 0); if (_liquid_surfaces.size() < index) { @@ -143,11 +143,11 @@ void VoxelmanLibrarySimple::set_liquid_voxel_surface(int index, Ref get_voxel_surface(int index) const; + Ref get_voxel_surface(const int index); void add_voxel_surface(Ref value); - void set_voxel_surface(int index, Ref value); - void remove_surface(int index); - int get_num_surfaces(); + void set_voxel_surface(const int index, Ref value); + void remove_surface(const int index); + int get_num_surfaces() const; void clear_surfaces(); Vector get_voxel_surfaces(); void set_voxel_surfaces(const Vector &surfaces); - Ref get_liquid_voxel_surface(int index) const; - void add_liquid_voxel_surface(Ref value); - void set_liquid_voxel_surface(int index, Ref value); - void remove_liquid_surface(int index); - int get_liquid_num_surfaces(); + Ref get_liquid_surface(const int index); + void add_liquid_surface(Ref value); + void set_liquid_surface(const int index, Ref value); + void remove_liquid_surface(const int index); + int get_num_liquid_surfaces() const; void clear_liquid_surfaces(); Vector get_liquid_voxel_surfaces(); diff --git a/props/prop_data.cpp b/props/prop_data.cpp index a8083f1..c4253e5 100644 --- a/props/prop_data.cpp +++ b/props/prop_data.cpp @@ -25,6 +25,13 @@ SOFTWARE. #include "../world/voxel_chunk.h" #include "prop_data_prop.h" +int PropData::get_id() { + return _id; +} +void PropData::set_id(int value) { + _id = value; +} + bool PropData::get_snap_to_mesh() { return _snap_to_mesh; } @@ -227,6 +234,7 @@ Transform PropData::get_next_snapped_prop_transform_bind(Node *spatial, Transfor } PropData::PropData() { + _id = 0; _snap_to_mesh = false; _snap_axis = Vector3(0, -1, 0); } diff --git a/props/prop_data.h b/props/prop_data.h index 75e562b..52b97ec 100644 --- a/props/prop_data.h +++ b/props/prop_data.h @@ -46,6 +46,9 @@ class PropData : public Resource { GDCLASS(PropData, Resource); public: + int get_id(); + void set_id(int value); + bool get_snap_to_mesh(); void set_snap_to_mesh(bool value); @@ -78,6 +81,7 @@ protected: static void _bind_methods(); private: + int _id; bool _snap_to_mesh; Vector3 _snap_axis;