Started reworking the way props are handled. Removed every old PropData related classes. Props are now just normal PackedScenes. Spawning conveniences/network synchronization will come later.

This commit is contained in:
Relintai 2020-04-04 17:22:07 +02:00
parent 04b68ff62d
commit 2d2b7c8c3e
9 changed files with 99 additions and 591 deletions

View File

@ -22,7 +22,7 @@ SOFTWARE.
#include "voxelman_library.h" #include "voxelman_library.h"
#include "../../props/props/prop_data.h" #include "scene/resources/packed_scene.h"
//Materials //Materials
Ref<Material> VoxelmanLibrary::get_material(const int index) { Ref<Material> VoxelmanLibrary::get_material(const int index) {
@ -73,55 +73,6 @@ void VoxelmanLibrary::set_materials(const Vector<Variant> &materials) {
} }
} }
//Prop Materials
Ref<Material> VoxelmanLibrary::get_prop_material(const int index) {
ERR_FAIL_INDEX_V(index, _prop_materials.size(), Ref<VoxelSurface>(NULL));
return _prop_materials[index];
}
void VoxelmanLibrary::add_prop_material(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_prop_materials.push_back(value);
}
void VoxelmanLibrary::set_prop_material(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _prop_materials.size());
_prop_materials.set(index, value);
}
void VoxelmanLibrary::remove_prop_material(const int index) {
_prop_materials.remove(index);
}
int VoxelmanLibrary::get_num_prop_materials() const {
return _prop_materials.size();
}
void VoxelmanLibrary::clear_prop_materials() {
_prop_materials.clear();
}
Vector<Variant> VoxelmanLibrary::get_prop_materials() {
Vector<Variant> r;
for (int i = 0; i < _prop_materials.size(); i++) {
r.push_back(_prop_materials[i].get_ref_ptr());
}
return r;
}
void VoxelmanLibrary::set_prop_materials(const Vector<Variant> &materials) {
_prop_materials.clear();
for (int i = 0; i < materials.size(); i++) {
Ref<Material> material = Ref<Material>(materials[i]);
_prop_materials.push_back(material);
}
}
//Liquid Materials //Liquid Materials
Ref<Material> VoxelmanLibrary::get_liquid_material(const int index) { Ref<Material> VoxelmanLibrary::get_liquid_material(const int index) {
ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref<VoxelSurface>(NULL)); ERR_FAIL_INDEX_V(index, _liquid_materials.size(), Ref<VoxelSurface>(NULL));
@ -171,55 +122,6 @@ void VoxelmanLibrary::set_liquid_materials(const Vector<Variant> &materials) {
} }
} }
//Clutter Materials
Ref<Material> VoxelmanLibrary::get_clutter_material(const int index) {
ERR_FAIL_INDEX_V(index, _clutter_materials.size(), Ref<VoxelSurface>(NULL));
return _clutter_materials[index];
}
void VoxelmanLibrary::add_clutter_material(const Ref<Material> &value) {
ERR_FAIL_COND(!value.is_valid());
_clutter_materials.push_back(value);
}
void VoxelmanLibrary::set_clutter_material(const int index, const Ref<Material> &value) {
ERR_FAIL_INDEX(index, _clutter_materials.size());
_clutter_materials.set(index, value);
}
void VoxelmanLibrary::remove_clutter_material(const int index) {
_clutter_materials.remove(index);
}
int VoxelmanLibrary::get_num_clutter_materials() const {
return _clutter_materials.size();
}
void VoxelmanLibrary::clear_clutter_materials() {
_clutter_materials.clear();
}
Vector<Variant> VoxelmanLibrary::get_clutter_materials() {
Vector<Variant> r;
for (int i = 0; i < _clutter_materials.size(); i++) {
r.push_back(_clutter_materials[i].get_ref_ptr());
}
return r;
}
void VoxelmanLibrary::set_clutter_materials(const Vector<Variant> &materials) {
_clutter_materials.clear();
for (int i = 0; i < materials.size(); i++) {
Ref<Material> material = Ref<Material>(materials[i]);
_clutter_materials.push_back(material);
}
}
//Surfaces //Surfaces
Ref<VoxelSurface> VoxelmanLibrary::get_voxel_surface(const int index) { Ref<VoxelSurface> VoxelmanLibrary::get_voxel_surface(const int index) {
return Ref<VoxelSurface>(); return Ref<VoxelSurface>();
@ -252,12 +154,12 @@ int VoxelmanLibrary::get_num_liquid_surfaces() const {
void VoxelmanLibrary::clear_liquid_surfaces() { void VoxelmanLibrary::clear_liquid_surfaces() {
} }
Ref<PropData> VoxelmanLibrary::get_prop(const int id) { Ref<PackedScene> VoxelmanLibrary::get_prop(const int id) {
return Ref<PropData>(); return Ref<PackedScene>();
} }
void VoxelmanLibrary::add_prop(Ref<PropData> value) { void VoxelmanLibrary::add_prop(Ref<PackedScene> value) {
} }
void VoxelmanLibrary::set_prop(int id, Ref<PropData> value) { void VoxelmanLibrary::set_prop(int id, Ref<PackedScene> value) {
} }
void VoxelmanLibrary::remove_prop(const int id) { void VoxelmanLibrary::remove_prop(const int id) {
} }
@ -281,7 +183,6 @@ VoxelmanLibrary::VoxelmanLibrary() {
VoxelmanLibrary::~VoxelmanLibrary() { VoxelmanLibrary::~VoxelmanLibrary() {
_materials.clear(); _materials.clear();
_prop_materials.clear();
_liquid_materials.clear(); _liquid_materials.clear();
_clutter_materials.clear(); _clutter_materials.clear();
} }
@ -300,17 +201,6 @@ void VoxelmanLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_materials"), &VoxelmanLibrary::set_materials); ClassDB::bind_method(D_METHOD("set_materials"), &VoxelmanLibrary::set_materials);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_materials", "get_materials"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_materials", "get_materials");
ClassDB::bind_method(D_METHOD("get_prop_material", "index"), &VoxelmanLibrary::get_prop_material);
ClassDB::bind_method(D_METHOD("add_prop_material", "value"), &VoxelmanLibrary::add_prop_material);
ClassDB::bind_method(D_METHOD("set_prop_material", "index", "value"), &VoxelmanLibrary::set_prop_material);
ClassDB::bind_method(D_METHOD("remove_prop_material", "index"), &VoxelmanLibrary::remove_prop_material);
ClassDB::bind_method(D_METHOD("get_num_prop_materials"), &VoxelmanLibrary::get_num_prop_materials);
ClassDB::bind_method(D_METHOD("clear_prop_materials"), &VoxelmanLibrary::clear_prop_materials);
ClassDB::bind_method(D_METHOD("get_prop_materials"), &VoxelmanLibrary::get_prop_materials);
ClassDB::bind_method(D_METHOD("set_prop_materials"), &VoxelmanLibrary::set_prop_materials);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "prop_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_prop_materials", "get_prop_materials");
ClassDB::bind_method(D_METHOD("get_liquid_material", "index"), &VoxelmanLibrary::get_liquid_material); ClassDB::bind_method(D_METHOD("get_liquid_material", "index"), &VoxelmanLibrary::get_liquid_material);
ClassDB::bind_method(D_METHOD("add_liquid_material", "value"), &VoxelmanLibrary::add_liquid_material); ClassDB::bind_method(D_METHOD("add_liquid_material", "value"), &VoxelmanLibrary::add_liquid_material);
ClassDB::bind_method(D_METHOD("set_liquid_material", "index", "value"), &VoxelmanLibrary::set_liquid_material); ClassDB::bind_method(D_METHOD("set_liquid_material", "index", "value"), &VoxelmanLibrary::set_liquid_material);
@ -322,17 +212,6 @@ void VoxelmanLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_liquid_materials"), &VoxelmanLibrary::set_liquid_materials); ClassDB::bind_method(D_METHOD("set_liquid_materials"), &VoxelmanLibrary::set_liquid_materials);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_liquid_materials", "get_liquid_materials"); ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "liquid_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_liquid_materials", "get_liquid_materials");
ClassDB::bind_method(D_METHOD("get_clutter_material", "index"), &VoxelmanLibrary::get_clutter_material);
ClassDB::bind_method(D_METHOD("add_clutter_material", "value"), &VoxelmanLibrary::add_clutter_material);
ClassDB::bind_method(D_METHOD("set_clutter_material", "index", "value"), &VoxelmanLibrary::set_clutter_material);
ClassDB::bind_method(D_METHOD("remove_clutter_material", "index"), &VoxelmanLibrary::remove_clutter_material);
ClassDB::bind_method(D_METHOD("get_num_clutter_materials"), &VoxelmanLibrary::get_num_clutter_materials);
ClassDB::bind_method(D_METHOD("clear_clutter_materials"), &VoxelmanLibrary::clear_clutter_materials);
ClassDB::bind_method(D_METHOD("get_clutter_materials"), &VoxelmanLibrary::get_clutter_materials);
ClassDB::bind_method(D_METHOD("set_clutter_materials"), &VoxelmanLibrary::set_clutter_materials);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "clutter_materials", PROPERTY_HINT_NONE, "17/17:Material", PROPERTY_USAGE_DEFAULT, "Material"), "set_clutter_materials", "get_clutter_materials");
ClassDB::bind_method(D_METHOD("get_voxel_surface", "index"), &VoxelmanLibrary::get_voxel_surface); 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("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("set_voxel_surface", "index", "surface"), &VoxelmanLibrary::set_voxel_surface);
@ -359,7 +238,5 @@ void VoxelmanLibrary::_bind_methods() {
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"), &VoxelmanLibrary::setup_material_albedo);
BIND_CONSTANT(MATERIAL_INDEX_VOXELS); BIND_CONSTANT(MATERIAL_INDEX_VOXELS);
BIND_CONSTANT(MATERIAL_INDEX_PROP);
BIND_CONSTANT(MATERIAL_INDEX_LIQUID); BIND_CONSTANT(MATERIAL_INDEX_LIQUID);
BIND_CONSTANT(MATERIAL_INDEX_CLUTTER);
} }

View File

@ -31,7 +31,7 @@ SOFTWARE.
class VoxelSurface; class VoxelSurface;
class VoxelMesher; class VoxelMesher;
class PropData; class PackedScene;
class VoxelmanLibrary : public Resource { class VoxelmanLibrary : public Resource {
GDCLASS(VoxelmanLibrary, Resource) GDCLASS(VoxelmanLibrary, Resource)
@ -39,9 +39,7 @@ class VoxelmanLibrary : public Resource {
public: public:
enum { enum {
MATERIAL_INDEX_VOXELS = 0, MATERIAL_INDEX_VOXELS = 0,
MATERIAL_INDEX_PROP = 1, MATERIAL_INDEX_LIQUID = 1,
MATERIAL_INDEX_LIQUID = 2,
MATERIAL_INDEX_CLUTTER = 3,
}; };
public: public:
@ -55,16 +53,6 @@ public:
Vector<Variant> get_materials(); Vector<Variant> get_materials();
void set_materials(const Vector<Variant> &materials); void set_materials(const Vector<Variant> &materials);
Ref<Material> get_prop_material(const int index);
void add_prop_material(const Ref<Material> &value);
void set_prop_material(const int index, const Ref<Material> &value);
void remove_prop_material(const int index);
int get_num_prop_materials() const;
void clear_prop_materials();
Vector<Variant> get_prop_materials();
void set_prop_materials(const Vector<Variant> &materials);
Ref<Material> get_liquid_material(const int index); Ref<Material> get_liquid_material(const int index);
void add_liquid_material(const Ref<Material> &value); void add_liquid_material(const Ref<Material> &value);
void set_liquid_material(const int index, const Ref<Material> &value); void set_liquid_material(const int index, const Ref<Material> &value);
@ -75,16 +63,6 @@ public:
Vector<Variant> get_liquid_materials(); Vector<Variant> get_liquid_materials();
void set_liquid_materials(const Vector<Variant> &materials); void set_liquid_materials(const Vector<Variant> &materials);
Ref<Material> get_clutter_material(const int index);
void add_clutter_material(const Ref<Material> &value);
void set_clutter_material(const int index, const Ref<Material> &value);
void remove_clutter_material(const int index);
int get_num_clutter_materials() const;
void clear_clutter_materials();
Vector<Variant> get_clutter_materials();
void set_clutter_materials(const Vector<Variant> &materials);
virtual Ref<VoxelSurface> get_voxel_surface(const int index); virtual Ref<VoxelSurface> get_voxel_surface(const int index);
virtual void add_voxel_surface(Ref<VoxelSurface> value); virtual void add_voxel_surface(Ref<VoxelSurface> value);
virtual void set_voxel_surface(const int index, Ref<VoxelSurface> value); virtual void set_voxel_surface(const int index, Ref<VoxelSurface> value);
@ -99,9 +77,9 @@ public:
virtual int get_num_liquid_surfaces() const; virtual int get_num_liquid_surfaces() const;
virtual void clear_liquid_surfaces(); virtual void clear_liquid_surfaces();
virtual Ref<PropData> get_prop(const int id); virtual Ref<PackedScene> get_prop(const int id);
virtual void add_prop(Ref<PropData> value); virtual void add_prop(Ref<PackedScene> value);
virtual void set_prop(const int id, Ref<PropData> value); virtual void set_prop(const int id, Ref<PackedScene> value);
virtual void remove_prop(const int id); virtual void remove_prop(const int id);
virtual int get_num_props() const; virtual int get_num_props() const;
virtual void clear_props(); virtual void clear_props();
@ -118,7 +96,6 @@ protected:
private: private:
Vector<Ref<Material> > _materials; Vector<Ref<Material> > _materials;
Vector<Ref<Material> > _prop_materials;
Vector<Ref<Material> > _liquid_materials; Vector<Ref<Material> > _liquid_materials;
Vector<Ref<Material> > _clutter_materials; Vector<Ref<Material> > _clutter_materials;
}; };

View File

@ -22,18 +22,15 @@ SOFTWARE.
#include "voxelman_library_merger.h" #include "voxelman_library_merger.h"
#include "scene/resources/texture.h" #include "scene/resources/packed_scene.h"
#include "../../props/props/prop_data.h" #include "scene/resources/texture.h"
#include "../../props/props/prop_data_mesh.h"
#include "../../props/props/prop_data_prop.h"
int VoxelmanLibraryMerger::get_texture_flags() const { int VoxelmanLibraryMerger::get_texture_flags() const {
return _packer->get_texture_flags(); return _packer->get_texture_flags();
} }
void VoxelmanLibraryMerger::set_texture_flags(const int flags) { void VoxelmanLibraryMerger::set_texture_flags(const int flags) {
_packer->set_texture_flags(flags); _packer->set_texture_flags(flags);
_prop_packer->set_texture_flags(flags);
} }
int VoxelmanLibraryMerger::get_max_atlas_size() const { int VoxelmanLibraryMerger::get_max_atlas_size() const {
@ -41,7 +38,6 @@ int VoxelmanLibraryMerger::get_max_atlas_size() const {
} }
void VoxelmanLibraryMerger::set_max_atlas_size(const int size) { void VoxelmanLibraryMerger::set_max_atlas_size(const int size) {
_packer->set_max_atlas_size(size); _packer->set_max_atlas_size(size);
_prop_packer->set_max_atlas_size(size);
} }
bool VoxelmanLibraryMerger::get_keep_original_atlases() const { bool VoxelmanLibraryMerger::get_keep_original_atlases() const {
@ -49,7 +45,6 @@ bool VoxelmanLibraryMerger::get_keep_original_atlases() const {
} }
void VoxelmanLibraryMerger::set_keep_original_atlases(const bool value) { void VoxelmanLibraryMerger::set_keep_original_atlases(const bool value) {
_packer->set_keep_original_atlases(value); _packer->set_keep_original_atlases(value);
_prop_packer->set_keep_original_atlases(value);
} }
Color VoxelmanLibraryMerger::get_background_color() const { Color VoxelmanLibraryMerger::get_background_color() const {
@ -57,7 +52,6 @@ Color VoxelmanLibraryMerger::get_background_color() const {
} }
void VoxelmanLibraryMerger::set_background_color(const Color color) { void VoxelmanLibraryMerger::set_background_color(const Color color) {
_packer->set_background_color(color); _packer->set_background_color(color);
_prop_packer->set_background_color(color);
} }
int VoxelmanLibraryMerger::get_margin() const { int VoxelmanLibraryMerger::get_margin() const {
@ -65,7 +59,6 @@ int VoxelmanLibraryMerger::get_margin() const {
} }
void VoxelmanLibraryMerger::set_margin(const int margin) { void VoxelmanLibraryMerger::set_margin(const int margin) {
_packer->set_margin(margin); _packer->set_margin(margin);
_prop_packer->set_margin(margin);
} }
//Surfaces //Surfaces
@ -234,58 +227,32 @@ void VoxelmanLibraryMerger::set_liquid_voxel_surfaces(const Vector<Variant> &sur
} }
} }
Ref<PropData> VoxelmanLibraryMerger::get_prop(const int id) { Ref<PackedScene> VoxelmanLibraryMerger::get_prop(const int id) {
if (_props.has(id)) //if (_props.has(id))
return _props[id]; // return _props[id];
return Ref<PropData>(); return Ref<PackedScene>();
} }
void VoxelmanLibraryMerger::add_prop(Ref<PropData> value) { void VoxelmanLibraryMerger::add_prop(Ref<PackedScene> value) {
if (!value.is_valid() || _props.has(value->get_id())) //if (!value.is_valid() || _props.has(value->get_id()))
return; // return;
_props[value->get_id()] = value; ////_props[value->get_id()] = value;
} }
void VoxelmanLibraryMerger::set_prop(const int id, Ref<PropData> value) { void VoxelmanLibraryMerger::set_prop(const int id, Ref<PackedScene> value) {
_props[value->get_id()] = value; //_props[value->get_id()] = value;
} }
void VoxelmanLibraryMerger::remove_prop(const int id) { void VoxelmanLibraryMerger::remove_prop(const int id) {
if (_props.has(id)) //if (_props.has(id))
_props.erase(id); // _props.erase(id);
} }
int VoxelmanLibraryMerger::get_num_props() const { int VoxelmanLibraryMerger::get_num_props() const {
return _props.size(); return _props.size();
} }
void VoxelmanLibraryMerger::clear_props() { void VoxelmanLibraryMerger::clear_props() {
_props.clear(); //_props.clear();
} }
/*
Vector<Variant> VoxelmanLibraryMerger::get_props() {
Vector<Variant> r;
for (Map<int, Ref<PropData> >::Element *I = _props.front(); I; I = I->next()) {
r.push_back(I->value().get_ref_ptr());
}
return r;
}
void VoxelmanLibraryMerger::set_props(const Vector<Variant> &props) {
_liquid_surfaces.clear();
for (int i = 0; i < props.size(); i++) {
Ref<VoxelSurfaceMerger> surface = Ref<VoxelSurfaceMerger>(props[i]);
if (surface.is_valid()) {
surface->set_library(this);
}
_liquid_surfaces.push_back(surface);
}
}
*/
void VoxelmanLibraryMerger::refresh_rects() { void VoxelmanLibraryMerger::refresh_rects() {
bool texture_added = false; bool texture_added = false;
for (int i = 0; i < _voxel_surfaces.size(); i++) { for (int i = 0; i < _voxel_surfaces.size(); i++) {
@ -344,26 +311,6 @@ void VoxelmanLibraryMerger::refresh_rects() {
setup_material_albedo(MATERIAL_INDEX_VOXELS, tex); setup_material_albedo(MATERIAL_INDEX_VOXELS, tex);
} }
texture_added = false;
for (Map<int, Ref<PropData> >::Element *I = _props.front(); I; I = I->next()) {
Ref<PropData> prop = Ref<PropData>(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<Texture> tex = _prop_packer->get_generated_texture(0);
setup_material_albedo(MATERIAL_INDEX_PROP, tex);
}
for (int i = 0; i < _voxel_surfaces.size(); i++) { for (int i = 0; i < _voxel_surfaces.size(); i++) {
Ref<VoxelSurfaceMerger> surface = _voxel_surfaces[i]; Ref<VoxelSurfaceMerger> surface = _voxel_surfaces[i];
@ -390,15 +337,9 @@ void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Ref<Textu
case MATERIAL_INDEX_VOXELS: case MATERIAL_INDEX_VOXELS:
count = get_num_materials(); count = get_num_materials();
break; break;
case MATERIAL_INDEX_PROP:
count = get_num_prop_materials();
break;
case MATERIAL_INDEX_LIQUID: case MATERIAL_INDEX_LIQUID:
count = get_num_liquid_materials(); count = get_num_liquid_materials();
break; break;
case MATERIAL_INDEX_CLUTTER:
count = get_num_clutter_materials();
break;
} }
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
@ -407,15 +348,9 @@ void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Ref<Textu
case MATERIAL_INDEX_VOXELS: case MATERIAL_INDEX_VOXELS:
mat = get_material(i); mat = get_material(i);
break; break;
case MATERIAL_INDEX_PROP:
mat = get_prop_material(i);
break;
case MATERIAL_INDEX_LIQUID: case MATERIAL_INDEX_LIQUID:
mat = get_liquid_material(i); mat = get_liquid_material(i);
break; break;
case MATERIAL_INDEX_CLUTTER:
mat = get_clutter_material(i);
break;
} }
Ref<SpatialMaterial> spmat; Ref<SpatialMaterial> spmat;
@ -431,15 +366,9 @@ void VoxelmanLibraryMerger::_setup_material_albedo(int material_index, Ref<Textu
case MATERIAL_INDEX_VOXELS: case MATERIAL_INDEX_VOXELS:
shmat = get_material(i); shmat = get_material(i);
break; break;
case MATERIAL_INDEX_PROP:
shmat = get_prop_material(i);
break;
case MATERIAL_INDEX_LIQUID: case MATERIAL_INDEX_LIQUID:
shmat = get_liquid_material(i); shmat = get_liquid_material(i);
break; break;
case MATERIAL_INDEX_CLUTTER:
shmat = get_clutter_material(i);
break;
} }
if (shmat.is_valid()) { if (shmat.is_valid()) {
@ -454,12 +383,6 @@ VoxelmanLibraryMerger::VoxelmanLibraryMerger() {
_packer->set_max_atlas_size(1024); _packer->set_max_atlas_size(1024);
_packer->set_keep_original_atlases(false); _packer->set_keep_original_atlases(false);
_packer->set_margin(0); _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() { VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
@ -483,46 +406,10 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
_liquid_surfaces.clear(); _liquid_surfaces.clear();
_prop_packer->clear();
_prop_packer.unref();
_packer->clear(); _packer->clear();
_packer.unref(); _packer.unref();
} }
bool VoxelmanLibraryMerger::process_prop_textures(Ref<PropData> prop) {
if (!prop.is_valid()) {
return false;
}
bool texture_added = false;
for (int i = 0; i < prop->get_prop_count(); ++i) {
Ref<PropDataMesh> pdm = prop->get_prop(i);
if (pdm.is_valid()) {
Ref<Texture> tex = pdm->get_texture();
if (!tex.is_valid())
continue;
if (!_prop_packer->contains_texture(tex)) {
_prop_packer->add_texture(tex);
texture_added = true;
}
}
Ref<PropDataProp> pdp = prop->get_prop(i);
if (pdp.is_valid()) {
if (process_prop_textures(pdp))
texture_added = true;
}
}
return texture_added;
}
void VoxelmanLibraryMerger::_bind_methods() { void VoxelmanLibraryMerger::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_flags"), &VoxelmanLibraryMerger::get_texture_flags); 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); ClassDB::bind_method(D_METHOD("set_texture_flags", "flags"), &VoxelmanLibraryMerger::set_texture_flags);
@ -554,7 +441,7 @@ void VoxelmanLibraryMerger::_bind_methods() {
//ClassDB::bind_method(D_METHOD("get_props"), &VoxelmanLibraryMerger::get_props); //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("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"); //ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "17/17:PackedScene", PROPERTY_USAGE_DEFAULT, "PackedScene"), "set_props", "get_props");
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"), &VoxelmanLibraryMerger::_setup_material_albedo);
} }

View File

@ -34,7 +34,7 @@ SOFTWARE.
class VoxelSurfaceSimple; class VoxelSurfaceSimple;
class VoxelMesher; class VoxelMesher;
class PropData; class PackedScene;
class VoxelmanLibraryMerger : public VoxelmanLibrary { class VoxelmanLibraryMerger : public VoxelmanLibrary {
GDCLASS(VoxelmanLibraryMerger, VoxelmanLibrary) GDCLASS(VoxelmanLibraryMerger, VoxelmanLibrary)
@ -75,9 +75,9 @@ public:
Vector<Variant> get_liquid_voxel_surfaces(); Vector<Variant> get_liquid_voxel_surfaces();
void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces); void set_liquid_voxel_surfaces(const Vector<Variant> &surfaces);
Ref<PropData> get_prop(const int id); Ref<PackedScene> get_prop(const int id);
void add_prop(Ref<PropData> value); void add_prop(Ref<PackedScene> value);
void set_prop(const int id, Ref<PropData> value); void set_prop(const int id, Ref<PackedScene> value);
void remove_prop(const int id); void remove_prop(const int id);
int get_num_props() const; int get_num_props() const;
void clear_props(); void clear_props();
@ -93,18 +93,14 @@ public:
~VoxelmanLibraryMerger(); ~VoxelmanLibraryMerger();
protected: protected:
bool process_prop_textures(Ref<PropData> prop);
static void _bind_methods(); static void _bind_methods();
private: private:
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces; Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
Vector<Ref<VoxelSurfaceMerger> > _liquid_surfaces; Vector<Ref<VoxelSurfaceMerger> > _liquid_surfaces;
//Vector<Ref<PropData> > _prop_vector; Map<int, Ref<PackedScene> > _props;
Map<int, Ref<PropData> > _props;
Ref<TexturePacker> _packer; Ref<TexturePacker> _packer;
Ref<TexturePacker> _prop_packer;
}; };
#endif #endif

View File

@ -52,11 +52,6 @@ SOFTWARE.
#include "../../mesh_data_resource/mesh_data_resource.h" #include "../../mesh_data_resource/mesh_data_resource.h"
#include "../../props/props/prop_data.h"
#include "../../props/props/prop_data_entry.h"
#include "../../props/props/prop_data_light.h"
#include "../../props/props/prop_data_mesh.h"
#include "../../props/props/prop_data_scene.h"
#include "voxel_chunk_prop_data.h" #include "voxel_chunk_prop_data.h"
class VoxelWorld; class VoxelWorld;

View File

@ -1141,105 +1141,11 @@ void VoxelChunkDefault::_build_phase(int phase) {
return; return;
} }
case BUILD_PHASE_PROP_MESH: {
for (int i = 0; i < _meshers.size(); ++i) {
Ref<VoxelMesher> mesher = _meshers.get(i);
ERR_CONTINUE(!mesher.is_valid());
mesher->reset();
}
if (_props.size() > 0) {
if (!has_meshes(MESH_INDEX_PROP, MESH_TYPE_INDEX_MESH)) {
create_meshes(MESH_INDEX_PROP, 1); //TODO LOD
}
for (int i = 0; i < _meshers.size(); ++i) {
Ref<VoxelMesher> mesher = _meshers.get(i);
ERR_CONTINUE(!mesher.is_valid());
mesher->bake_colors(this);
mesher->set_material(get_library()->get_material(0));
RID prop_mesh_rid = get_mesh_rid_index(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_MESH, 0);
ERR_FAIL_COND(prop_mesh_rid == RID());
VS::get_singleton()->mesh_clear(prop_mesh_rid);
if (mesher->get_vertex_count() == 0) {
next_phase();
return;
}
Array arr = mesher->build_mesh();
VS::get_singleton()->mesh_add_surface_from_arrays(prop_mesh_rid, VisualServer::PRIMITIVE_TRIANGLES, arr);
if (_library->get_material(0).is_valid())
VS::get_singleton()->mesh_surface_set_material(prop_mesh_rid, 0, _library->get_material(0)->get_rid());
}
}
next_phase();
return;
}
case BUILD_PHASE_PROP_COLLIDER: {
if (!get_create_collider()) {
next_phase();
return;
}
for (int i = 0; i < _meshers.size(); ++i) {
Ref<VoxelMesher> mesher = _meshers.get(i);
ERR_CONTINUE(!mesher.is_valid());
temp_arr_collider.append_array(mesher->build_collider());
}
for (int i = 0; i < _meshers.size(); ++i) {
Ref<VoxelMesher> mesher = _meshers.get(i);
ERR_CONTINUE(!mesher.is_valid());
mesher->reset();
}
if (temp_arr_collider.size() == 0) {
next_phase();
return;
}
if (_is_build_threaded) {
set_active_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS);
return;
}
if (!has_meshes(MESH_INDEX_PROP, MESH_TYPE_INDEX_SHAPE)) {
create_colliders(MESH_INDEX_PROP);
}
PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_PROP, MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
//temp_arr_collider.resize(0);
next_phase();
return;
}
/* /*
case BUILD_PHASE_LIQUID: { case BUILD_PHASE_LIQUID: {
next_phase(); next_phase();
return; return;
} }
case BUILD_PHASE_CLUTTER: {
next_phase();
return;
}
*/ */
case BUILD_PHASE_FINALIZE: { case BUILD_PHASE_FINALIZE: {
update_transforms(); update_transforms();
@ -1264,18 +1170,6 @@ void VoxelChunkDefault::_build_phase_physics_process(int phase) {
PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_SHAPE), temp_arr_collider); PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_TERRARIN, MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
//temp_arr_collider.resize(0); //temp_arr_collider.resize(0);
set_active_build_phase_type(BUILD_PHASE_TYPE_NORMAL);
next_phase();
} else if (phase == BUILD_PHASE_PROP_COLLIDER) {
if (!has_meshes(MESH_INDEX_PROP, MESH_TYPE_INDEX_SHAPE)) {
create_colliders(MESH_INDEX_PROP);
}
PhysicsServer::get_singleton()->shape_set_data(get_mesh_rid(MESH_INDEX_PROP, MESH_TYPE_INDEX_SHAPE), temp_arr_collider);
//temp_arr_collider.resize(0);
set_active_build_phase_type(BUILD_PHASE_TYPE_NORMAL); set_active_build_phase_type(BUILD_PHASE_TYPE_NORMAL);
next_phase(); next_phase();
} }
@ -1495,8 +1389,6 @@ void VoxelChunkDefault::_bind_methods() {
BIND_CONSTANT(BUILD_PHASE_TERRARIN_MESH_COLLIDER); BIND_CONSTANT(BUILD_PHASE_TERRARIN_MESH_COLLIDER);
BIND_CONSTANT(BUILD_PHASE_TERRARIN_MESH); BIND_CONSTANT(BUILD_PHASE_TERRARIN_MESH);
BIND_CONSTANT(BUILD_PHASE_LIGHTS); BIND_CONSTANT(BUILD_PHASE_LIGHTS);
BIND_CONSTANT(BUILD_PHASE_PROP_MESH);
BIND_CONSTANT(BUILD_PHASE_PROP_COLLIDER);
BIND_CONSTANT(BUILD_PHASE_FINALIZE); BIND_CONSTANT(BUILD_PHASE_FINALIZE);
BIND_CONSTANT(BUILD_PHASE_MAX); BIND_CONSTANT(BUILD_PHASE_MAX);

View File

@ -53,11 +53,6 @@ SOFTWARE.
#include "../library/voxelman_library.h" #include "../library/voxelman_library.h"
#include "../../mesh_data_resource/mesh_data_resource.h" #include "../../mesh_data_resource/mesh_data_resource.h"
#include "../../props/props/prop_data.h"
#include "../../props/props/prop_data_entry.h"
#include "../../props/props/prop_data_light.h"
#include "../../props/props/prop_data_mesh.h"
#include "../../props/props/prop_data_scene.h"
#include "voxel_chunk_prop_data.h" #include "voxel_chunk_prop_data.h"
class VoxelWorld; class VoxelWorld;
@ -85,10 +80,7 @@ public:
BUILD_PHASE_TERRARIN_MESH_COLLIDER, BUILD_PHASE_TERRARIN_MESH_COLLIDER,
BUILD_PHASE_LIGHTS, BUILD_PHASE_LIGHTS,
BUILD_PHASE_TERRARIN_MESH, BUILD_PHASE_TERRARIN_MESH,
BUILD_PHASE_PROP_MESH,
BUILD_PHASE_PROP_COLLIDER,
//BUILD_PHASE_LIQUID, //BUILD_PHASE_LIQUID,
//BUILD_PHASE_CLUTTER,
BUILD_PHASE_FINALIZE, BUILD_PHASE_FINALIZE,
BUILD_PHASE_MAX BUILD_PHASE_MAX
}; };

View File

@ -22,152 +22,72 @@ SOFTWARE.
#include "voxel_chunk_prop_data.h" #include "voxel_chunk_prop_data.h"
int VoxelChunkPropData::get_x() { #include "voxel_chunk.h"
return _x;
int VoxelChunkPropData::get_scene_id() const {
return _scene_id;
} }
void VoxelChunkPropData::set_x(int value) { void VoxelChunkPropData::set_scene_id(const int id) {
_x = value; _scene_id = id;
} }
int VoxelChunkPropData::get_y() { Transform VoxelChunkPropData::get_transform() const {
return _y; return _transform;
} }
void VoxelChunkPropData::set_y(int value) { void VoxelChunkPropData::set_transform(const Transform &value) {
_y = value; _transform = value;
} }
int VoxelChunkPropData::get_z() { Ref<PackedScene> VoxelChunkPropData::get_scene() {
return _z;
}
void VoxelChunkPropData::set_z(int value) {
_z = value;
}
Vector3 VoxelChunkPropData::get_rotation() {
return _rotation;
}
void VoxelChunkPropData::set_rotation(Vector3 value) {
_rotation = value;
}
Vector3 VoxelChunkPropData::get_scale() {
return _scale;
}
void VoxelChunkPropData::set_scale(Vector3 value) {
_scale = value;
}
bool VoxelChunkPropData::get_snap_to_mesh() {
return _snap_to_mesh;
}
void VoxelChunkPropData::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 VoxelChunkPropData::get_snap_axis() {
return _snap_axis;
}
void VoxelChunkPropData::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
Ref<MeshDataResource> VoxelChunkPropData::get_mesh() const {
return _mesh;
}
void VoxelChunkPropData::set_mesh(const Ref<MeshDataResource> value) {
_mesh = value;
}
Ref<Texture> VoxelChunkPropData::get_mesh_texture() const {
return _texture;
}
void VoxelChunkPropData::set_mesh_texture(const Ref<Texture> value) {
_texture = value;
}
Ref<PropDataLight> VoxelChunkPropData::get_light() const {
return _light;
}
void VoxelChunkPropData::set_light(const Ref<PropDataLight> value) {
_light = value;
}
Ref<PropData> VoxelChunkPropData::get_prop() const {
return _prop;
}
void VoxelChunkPropData::set_prop(const Ref<PropData> value) {
_prop = value;
}
Ref<PackedScene> VoxelChunkPropData::get_scene() const {
return _scene; return _scene;
} }
void VoxelChunkPropData::set_scene(const Ref<PackedScene> value) { void VoxelChunkPropData::set_scene(const Ref<PackedScene> &value) {
_scene = value; _scene = value;
} }
Node *VoxelChunkPropData::get_spawned_prop() const {
return _spawned_prop;
}
void VoxelChunkPropData::set_spawned_prop(Node *value) {
_spawned_prop = value;
}
Node *VoxelChunkPropData::spawn_prop(Node *parent) {
return NULL;
}
void VoxelChunkPropData::free_prop() {
}
void VoxelChunkPropData::set_translation_for_chunk(const Ref<VoxelChunk> &chunk, const int local_x, const int local_y, const int local_z) {
}
VoxelChunkPropData::VoxelChunkPropData() { VoxelChunkPropData::VoxelChunkPropData() {
_x = 0; _spawned_prop = NULL;
_y = 0; _scene_id = 0;
_z = 0;
_scale = Vector3(1, 1, 1);
_snap_to_mesh = false;
_snap_axis = Vector3(0, -1, 0);
} }
VoxelChunkPropData::~VoxelChunkPropData() { VoxelChunkPropData::~VoxelChunkPropData() {
_mesh.unref();
_texture.unref();
_light.unref();
_prop.unref();
_scene.unref(); _scene.unref();
} }
void VoxelChunkPropData::_bind_methods() { void VoxelChunkPropData::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_x"), &VoxelChunkPropData::get_x); ClassDB::bind_method(D_METHOD("get_scene_id"), &VoxelChunkPropData::get_scene_id);
ClassDB::bind_method(D_METHOD("set_x", "value"), &VoxelChunkPropData::set_x); ClassDB::bind_method(D_METHOD("set_scene_id", "value"), &VoxelChunkPropData::set_scene_id);
ADD_PROPERTY(PropertyInfo(Variant::INT, "x"), "set_x", "get_x"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scene_id"), "set_scene_id", "get_scene_id");
ClassDB::bind_method(D_METHOD("get_y"), &VoxelChunkPropData::get_y); ClassDB::bind_method(D_METHOD("get_transform"), &VoxelChunkPropData::get_transform);
ClassDB::bind_method(D_METHOD("set_y", "value"), &VoxelChunkPropData::set_y); ClassDB::bind_method(D_METHOD("set_transform", "value"), &VoxelChunkPropData::set_transform);
ADD_PROPERTY(PropertyInfo(Variant::INT, "y"), "set_y", "get_y"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "transform"), "set_transform", "get_transform");
ClassDB::bind_method(D_METHOD("get_z"), &VoxelChunkPropData::get_z);
ClassDB::bind_method(D_METHOD("set_z", "value"), &VoxelChunkPropData::set_z);
ADD_PROPERTY(PropertyInfo(Variant::INT, "z"), "set_z", "get_z");
ClassDB::bind_method(D_METHOD("get_rotation"), &VoxelChunkPropData::get_rotation);
ClassDB::bind_method(D_METHOD("set_rotation", "value"), &VoxelChunkPropData::set_rotation);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation"), "set_rotation", "get_rotation");
ClassDB::bind_method(D_METHOD("get_scale"), &VoxelChunkPropData::get_scale);
ClassDB::bind_method(D_METHOD("set_scale", "value"), &VoxelChunkPropData::set_scale);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale"), "set_scale", "get_scale");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &VoxelChunkPropData::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &VoxelChunkPropData::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &VoxelChunkPropData::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &VoxelChunkPropData::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
ClassDB::bind_method(D_METHOD("get_mesh"), &VoxelChunkPropData::get_mesh);
ClassDB::bind_method(D_METHOD("set_mesh", "value"), &VoxelChunkPropData::set_mesh);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource"), "set_mesh", "get_mesh");
ClassDB::bind_method(D_METHOD("get_mesh_texture"), &VoxelChunkPropData::get_mesh_texture);
ClassDB::bind_method(D_METHOD("set_mesh_texture", "value"), &VoxelChunkPropData::set_mesh_texture);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_mesh_texture", "get_mesh_texture");
ClassDB::bind_method(D_METHOD("get_light"), &VoxelChunkPropData::get_light);
ClassDB::bind_method(D_METHOD("set_light", "value"), &VoxelChunkPropData::set_light);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "light", PROPERTY_HINT_RESOURCE_TYPE, "PropDataLight"), "set_light", "get_light");
ClassDB::bind_method(D_METHOD("get_prop"), &VoxelChunkPropData::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "value"), &VoxelChunkPropData::set_prop);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "PropData"), "set_prop", "get_prop");
ClassDB::bind_method(D_METHOD("get_scene"), &VoxelChunkPropData::get_scene); ClassDB::bind_method(D_METHOD("get_scene"), &VoxelChunkPropData::get_scene);
ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelChunkPropData::set_scene); ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelChunkPropData::set_scene);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "scene", PROPERTY_HINT_RESOURCE_TYPE, "PackedScene"), "set_scene", "get_scene");
ClassDB::bind_method(D_METHOD("get_spawned_prop"), &VoxelChunkPropData::get_spawned_prop);
ClassDB::bind_method(D_METHOD("set_spawned_prop", "value"), &VoxelChunkPropData::set_spawned_prop);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "spawned_prop", PROPERTY_HINT_RESOURCE_TYPE, "Node"), "set_spawned_prop", "get_spawned_prop");
ClassDB::bind_method(D_METHOD("spawn_prop", "parent"), &VoxelChunkPropData::spawn_prop);
ClassDB::bind_method(D_METHOD("free_prop"), &VoxelChunkPropData::free_prop);
ClassDB::bind_method(D_METHOD("set_translation_for_chunk", "chunk", "local_x", "local_y", "local_z"), &VoxelChunkPropData::set_translation_for_chunk);
} }

View File

@ -23,54 +23,36 @@ SOFTWARE.
#ifndef VOXEL_CHUNK_PROP_DATA_H #ifndef VOXEL_CHUNK_PROP_DATA_H
#define VOXEL_CHUNK_PROP_DATA_H #define VOXEL_CHUNK_PROP_DATA_H
#include "core/math/vector3.h" #include "core/resource.h"
#include "core/reference.h"
#include "core/math/transform.h"
#include "scene/main/node.h"
#include "../../mesh_data_resource/mesh_data_resource.h"
#include "../../props/props/prop_data.h"
#include "../../props/props/prop_data_light.h"
#include "scene/resources/packed_scene.h" #include "scene/resources/packed_scene.h"
#include "scene/resources/texture.h"
class VoxelChunkPropData : public Reference { class VoxelChunk;
GDCLASS(VoxelChunkPropData, Reference);
class VoxelChunkPropData : public Resource {
GDCLASS(VoxelChunkPropData, Resource);
public: public:
int get_x(); int get_scene_id() const;
void set_x(int value); void set_scene_id(const int id);
int get_y(); Transform get_transform() const;
void set_y(int value); void set_transform(const Transform &value);
int get_z(); Ref<PackedScene> get_scene();
void set_z(int value); void set_scene(const Ref<PackedScene> &value);
Vector3 get_rotation(); Node *get_spawned_prop() const;
void set_rotation(Vector3 value); void set_spawned_prop(Node *value);
Vector3 get_scale(); Node *spawn_prop(Node *parent);
void set_scale(Vector3 value); void free_prop();
bool get_snap_to_mesh(); void set_translation_for_chunk(const Ref<VoxelChunk> &chunk, const int local_x, const int local_y, const int local_z);
void set_snap_to_mesh(bool value);
Vector3 get_snap_axis();
void set_snap_axis(Vector3 value);
Ref<MeshDataResource> get_mesh() const;
void set_mesh(const Ref<MeshDataResource> value);
Ref<Texture> get_mesh_texture() const;
void set_mesh_texture(const Ref<Texture> value);
Ref<PropDataLight> get_light() const;
void set_light(const Ref<PropDataLight> value);
Ref<PropData> get_prop() const;
void set_prop(const Ref<PropData> value);
Ref<PackedScene> get_scene() const;
void set_scene(const Ref<PackedScene> value);
VoxelChunkPropData(); VoxelChunkPropData();
~VoxelChunkPropData(); ~VoxelChunkPropData();
@ -79,19 +61,9 @@ protected:
static void _bind_methods(); static void _bind_methods();
private: private:
int _x; int _scene_id;
int _y; Transform _transform;
int _z; Node *_spawned_prop;
Vector3 _rotation;
Vector3 _scale;
bool _snap_to_mesh;
Vector3 _snap_axis;
Ref<MeshDataResource> _mesh;
Ref<Texture> _texture;
Ref<PropDataLight> _light;
Ref<PropData> _prop;
Ref<PackedScene> _scene; Ref<PackedScene> _scene;
}; };