From be4876c2f101b0546bfb1e79c1f023a1b9992f03 Mon Sep 17 00:00:00 2001 From: Relintai Date: Sat, 27 Jun 2020 18:25:23 +0200 Subject: [PATCH] Fix compile if the props module isn't present. --- library/voxelman_library.cpp | 7 +++++++ library/voxelman_library.h | 4 ++++ library/voxelman_library_merger.cpp | 10 ++++++++++ library/voxelman_library_merger.h | 6 ++++++ world/voxel_chunk_prop_data.cpp | 6 ++++++ world/voxel_chunk_prop_data.h | 9 +++++++++ 6 files changed, 42 insertions(+) diff --git a/library/voxelman_library.cpp b/library/voxelman_library.cpp index d10210f..311d646 100644 --- a/library/voxelman_library.cpp +++ b/library/voxelman_library.cpp @@ -22,7 +22,10 @@ SOFTWARE. #include "voxelman_library.h" +#ifdef PROPS_PRESENT #include "../../props/props/prop_data.h" +#endif + #include "scene/resources/packed_scene.h" #include "../defines.h" @@ -204,6 +207,7 @@ int VoxelmanLibrary::get_num_scenes() const { void VoxelmanLibrary::clear_scenes() { } +#ifdef PROPS_PRESENT Ref VoxelmanLibrary::get_prop(const int id) { return Ref(); } @@ -218,6 +222,7 @@ int VoxelmanLibrary::get_num_props() const { } void VoxelmanLibrary::clear_props() { } +#endif //Rects void VoxelmanLibrary::refresh_rects() { @@ -286,12 +291,14 @@ void VoxelmanLibrary::_bind_methods() { ClassDB::bind_method(D_METHOD("get_num_surfaces"), &VoxelmanLibrary::get_num_surfaces); ClassDB::bind_method(D_METHOD("clear_surfaces"), &VoxelmanLibrary::clear_surfaces); +#ifdef PROPS_PRESENT 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); +#endif ClassDB::bind_method(D_METHOD("refresh_rects"), &VoxelmanLibrary::refresh_rects); diff --git a/library/voxelman_library.h b/library/voxelman_library.h index dd736cb..b50842a 100644 --- a/library/voxelman_library.h +++ b/library/voxelman_library.h @@ -32,7 +32,9 @@ SOFTWARE. class VoxelSurface; class VoxelMesher; class PackedScene; +#ifdef PROPS_PRESENT class PropData; +#endif class VoxelmanLibrary : public Resource { GDCLASS(VoxelmanLibrary, Resource) @@ -92,12 +94,14 @@ public: virtual int get_num_scenes() const; virtual void clear_scenes(); +#ifdef PROPS_PRESENT 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(); +#endif virtual void refresh_rects(); diff --git a/library/voxelman_library_merger.cpp b/library/voxelman_library_merger.cpp index d7e49c3..7a81361 100644 --- a/library/voxelman_library_merger.cpp +++ b/library/voxelman_library_merger.cpp @@ -25,9 +25,11 @@ SOFTWARE. #include "scene/resources/packed_scene.h" #include "scene/resources/texture.h" +#ifdef PROPS_PRESENT #include "../../props/props/prop_data.h" #include "../../props/props/prop_data_mesh.h" #include "../../props/props/prop_data_prop.h" +#endif #include "../defines.h" @@ -145,6 +147,7 @@ void VoxelmanLibraryMerger::set_voxel_surfaces(const Vector &surfaces) } } +#ifdef PROPS_PRESENT Ref VoxelmanLibraryMerger::get_prop(const int index) { ERR_FAIL_INDEX_V(index, _props.size(), Ref()); @@ -177,6 +180,7 @@ Vector VoxelmanLibraryMerger::get_props() { void VoxelmanLibraryMerger::set_props(const Vector &props) { VARIANT_ARRAY_SET(props, _props, PropData); } +#endif void VoxelmanLibraryMerger::refresh_rects() { bool texture_added = false; @@ -211,6 +215,7 @@ void VoxelmanLibraryMerger::refresh_rects() { setup_material_albedo(MATERIAL_INDEX_LIQUID, tex); } +#ifdef PROPS_PRESENT texture_added = false; for (int i = 0; i < _props.size(); i++) { Ref prop = _props.get(i); @@ -230,6 +235,7 @@ void VoxelmanLibraryMerger::refresh_rects() { setup_material_albedo(MATERIAL_INDEX_PROP, tex); } +#endif for (int i = 0; i < _voxel_surfaces.size(); i++) { Ref surface = _voxel_surfaces[i]; @@ -341,6 +347,7 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() { _prop_packer.unref(); } +#ifdef PROPS_PRESENT bool VoxelmanLibraryMerger::process_prop_textures(Ref prop) { if (!prop.is_valid()) { return false; @@ -373,6 +380,7 @@ bool VoxelmanLibraryMerger::process_prop_textures(Ref prop) { return texture_added; } +#endif void VoxelmanLibraryMerger::_bind_methods() { ClassDB::bind_method(D_METHOD("get_texture_flags"), &VoxelmanLibraryMerger::get_texture_flags); @@ -399,9 +407,11 @@ void VoxelmanLibraryMerger::_bind_methods() { 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"); +#ifdef PROPS_PRESENT 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"); +#endif 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 913604c..493bb22 100644 --- a/library/voxelman_library_merger.h +++ b/library/voxelman_library_merger.h @@ -65,6 +65,7 @@ public: Vector get_voxel_surfaces(); void set_voxel_surfaces(const Vector &surfaces); +#ifdef PROPS_PRESENT Ref get_prop(const int index); void add_prop(Ref value); void set_prop(const int index, const Ref &value); @@ -74,6 +75,7 @@ public: Vector get_props(); void set_props(const Vector &props); +#endif void refresh_rects(); @@ -83,13 +85,17 @@ public: ~VoxelmanLibraryMerger(); protected: +#ifdef PROPS_PRESENT bool process_prop_textures(Ref prop); +#endif static void _bind_methods(); private: Vector > _voxel_surfaces; +#ifdef PROPS_PRESENT Vector > _props; +#endif Ref _packer; Ref _prop_packer; diff --git a/world/voxel_chunk_prop_data.cpp b/world/voxel_chunk_prop_data.cpp index 19139df..d9a048c 100644 --- a/world/voxel_chunk_prop_data.cpp +++ b/world/voxel_chunk_prop_data.cpp @@ -115,6 +115,7 @@ void VoxelChunkPropData::set_mesh_texture(const Ref &value) { _texture = value; } +#ifdef PROPS_PRESENT Ref VoxelChunkPropData::get_light() { return _light; } @@ -128,6 +129,7 @@ Ref VoxelChunkPropData::get_prop() { void VoxelChunkPropData::set_prop(const Ref &value) { _prop = value; } +#endif Node *VoxelChunkPropData::get_spawned_prop() const { return _spawned_prop; @@ -159,8 +161,10 @@ VoxelChunkPropData::VoxelChunkPropData() { VoxelChunkPropData::~VoxelChunkPropData() { _mesh.unref(); _texture.unref(); +#ifdef PROPS_PRESENT _light.unref(); _prop.unref(); +#endif _scene.unref(); _owner.unref(); @@ -224,6 +228,7 @@ void VoxelChunkPropData::_bind_methods() { 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"); +#ifdef PROPS_PRESENT 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"); @@ -231,6 +236,7 @@ void VoxelChunkPropData::_bind_methods() { 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"); +#endif ClassDB::bind_method(D_METHOD("get_scene"), &VoxelChunkPropData::get_scene); ClassDB::bind_method(D_METHOD("set_scene", "value"), &VoxelChunkPropData::set_scene); diff --git a/world/voxel_chunk_prop_data.h b/world/voxel_chunk_prop_data.h index ae5bfcb..1e323d3 100644 --- a/world/voxel_chunk_prop_data.h +++ b/world/voxel_chunk_prop_data.h @@ -29,8 +29,12 @@ SOFTWARE. #include "scene/resources/packed_scene.h" #include "../../mesh_data_resource/mesh_data_resource.h" + +#ifdef PROPS_PRESENT #include "../../props/props/prop_data.h" #include "../../props/props/prop_data_light.h" +#endif + #include "scene/resources/texture.h" class VoxelChunk; @@ -66,11 +70,13 @@ public: Ref get_mesh_texture(); void set_mesh_texture(const Ref &value); +#ifdef PROPS_PRESENT Ref get_light(); void set_light(const Ref &value); Ref get_prop(); void set_prop(const Ref &value); +#endif Ref get_scene(); void set_scene(const Ref &value); @@ -118,8 +124,11 @@ private: Ref _mesh; Ref _texture; + +#ifdef PROPS_PRESENT Ref _light; Ref _prop; +#endif }; #endif