Fix compile if the props module isn't present.

This commit is contained in:
Relintai 2020-06-27 18:25:23 +02:00
parent 02b434a2a2
commit be4876c2f1
6 changed files with 42 additions and 0 deletions

View File

@ -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<PropData> VoxelmanLibrary::get_prop(const int id) {
return Ref<PropData>();
}
@ -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);

View File

@ -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<PropData> get_prop(const int id);
virtual void add_prop(Ref<PropData> value);
virtual void set_prop(const int id, Ref<PropData> value);
virtual void remove_prop(const int id);
virtual int get_num_props() const;
virtual void clear_props();
#endif
virtual void refresh_rects();

View File

@ -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<Variant> &surfaces)
}
}
#ifdef PROPS_PRESENT
Ref<PropData> VoxelmanLibraryMerger::get_prop(const int index) {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<PropData>());
@ -177,6 +180,7 @@ Vector<Variant> VoxelmanLibraryMerger::get_props() {
void VoxelmanLibraryMerger::set_props(const Vector<Variant> &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<PropData> 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<VoxelSurfaceMerger> surface = _voxel_surfaces[i];
@ -341,6 +347,7 @@ VoxelmanLibraryMerger::~VoxelmanLibraryMerger() {
_prop_packer.unref();
}
#ifdef PROPS_PRESENT
bool VoxelmanLibraryMerger::process_prop_textures(Ref<PropData> prop) {
if (!prop.is_valid()) {
return false;
@ -373,6 +380,7 @@ bool VoxelmanLibraryMerger::process_prop_textures(Ref<PropData> 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);
}

View File

@ -65,6 +65,7 @@ public:
Vector<Variant> get_voxel_surfaces();
void set_voxel_surfaces(const Vector<Variant> &surfaces);
#ifdef PROPS_PRESENT
Ref<PropData> get_prop(const int index);
void add_prop(Ref<PropData> value);
void set_prop(const int index, const Ref<PropData> &value);
@ -74,6 +75,7 @@ public:
Vector<Variant> get_props();
void set_props(const Vector<Variant> &props);
#endif
void refresh_rects();
@ -83,13 +85,17 @@ public:
~VoxelmanLibraryMerger();
protected:
#ifdef PROPS_PRESENT
bool process_prop_textures(Ref<PropData> prop);
#endif
static void _bind_methods();
private:
Vector<Ref<VoxelSurfaceMerger> > _voxel_surfaces;
#ifdef PROPS_PRESENT
Vector<Ref<PropData> > _props;
#endif
Ref<TexturePacker> _packer;
Ref<TexturePacker> _prop_packer;

View File

@ -115,6 +115,7 @@ void VoxelChunkPropData::set_mesh_texture(const Ref<Texture> &value) {
_texture = value;
}
#ifdef PROPS_PRESENT
Ref<PropDataLight> VoxelChunkPropData::get_light() {
return _light;
}
@ -128,6 +129,7 @@ Ref<PropData> VoxelChunkPropData::get_prop() {
void VoxelChunkPropData::set_prop(const Ref<PropData> &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);

View File

@ -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<Texture> get_mesh_texture();
void set_mesh_texture(const Ref<Texture> &value);
#ifdef PROPS_PRESENT
Ref<PropDataLight> get_light();
void set_light(const Ref<PropDataLight> &value);
Ref<PropData> get_prop();
void set_prop(const Ref<PropData> &value);
#endif
Ref<PackedScene> get_scene();
void set_scene(const Ref<PackedScene> &value);
@ -118,8 +124,11 @@ private:
Ref<MeshDataResource> _mesh;
Ref<Texture> _texture;
#ifdef PROPS_PRESENT
Ref<PropDataLight> _light;
Ref<PropData> _prop;
#endif
};
#endif