From 152be1328bcf7953de5139f44a26bda0b13afef4 Mon Sep 17 00:00:00 2001 From: Relintai Date: Mon, 6 Apr 2020 22:53:09 +0200 Subject: [PATCH] Make sure the dependencies are actually optional. --- SCsub | 6 ++++++ clutter/ground_clutter.cpp | 15 +++++++++++++-- clutter/ground_clutter.h | 10 ++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/SCsub b/SCsub index 229359d..ee0f665 100644 --- a/SCsub +++ b/SCsub @@ -7,6 +7,12 @@ module_env = env.Clone() if os.path.isdir('../mesh_data_resource'): module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) +if os.path.isdir('../texture_packer'): + module_env.Append(CPPDEFINES=['TEXTURE_PACKER_PRESENT']) + +if os.path.isdir('../voxelman'): + module_env.Append(CPPDEFINES=['VOXELMAN_PRESENT']) + sources = [ "register_types.cpp", diff --git a/clutter/ground_clutter.cpp b/clutter/ground_clutter.cpp index 3bec974..cf349a5 100644 --- a/clutter/ground_clutter.cpp +++ b/clutter/ground_clutter.cpp @@ -22,6 +22,7 @@ SOFTWARE. #include "ground_clutter.h" +#ifdef VOXELMAN_PRESENT #include "../../voxelman/world/voxel_chunk.h" bool GroundClutter::should_spawn(Ref chunk, int x, int y, int z) { @@ -35,11 +36,14 @@ void GroundClutter::add_meshes_to(Ref mesher, Ref chunk if (has_method("_add_meshes_to")) call("_add_meshes_to", mesher, chunk, x, y, z); } +#endif +#ifdef TEXTURE_PACKER_PRESENT void GroundClutter::add_textures_to(Ref packer) { if (has_method("_add_textures_to")) call("_add_textures_to", packer); } +#endif GroundClutter::GroundClutter() { } @@ -48,11 +52,18 @@ GroundClutter::~GroundClutter() { } void GroundClutter::_bind_methods() { + +#ifdef TEXTURE_PACKER_PRESENT + BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); + + ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter::add_textures_to); +#endif + +#ifdef VOXELMAN_PRESENT BIND_VMETHOD(MethodInfo(PropertyInfo(Variant::BOOL, "should"), "_should_spawn", PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); BIND_VMETHOD(MethodInfo("_add_meshes_to", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"), PropertyInfo(Variant::OBJECT, "chunk", PROPERTY_HINT_RESOURCE_TYPE, "VoxelChunk"), PropertyInfo(Variant::INT, "x"), PropertyInfo(Variant::INT, "y"), PropertyInfo(Variant::INT, "z"))); - BIND_VMETHOD(MethodInfo("_add_textures_to", PropertyInfo(Variant::OBJECT, "packer", PROPERTY_HINT_RESOURCE_TYPE, "TexturePacker"))); ClassDB::bind_method(D_METHOD("should_spawn", "chunk", "x", "y", "z"), &GroundClutter::should_spawn); ClassDB::bind_method(D_METHOD("add_meshes_to", "mesher", "chunk", "x", "y", "z"), &GroundClutter::add_meshes_to); - ClassDB::bind_method(D_METHOD("add_textures_to", "packer"), &GroundClutter::add_textures_to); +#endif } diff --git a/clutter/ground_clutter.h b/clutter/ground_clutter.h index 694baf8..4f97610 100644 --- a/clutter/ground_clutter.h +++ b/clutter/ground_clutter.h @@ -25,8 +25,13 @@ SOFTWARE. #include "core/resource.h" +#ifdef TEXTURE_PACKER_PRESENT #include "../../texture_packer/texture_packer.h" +#endif + +#ifdef VOXELMAN_PRESENT #include "../../voxelman/meshers/voxel_mesher.h" +#endif class VoxelChunk; class VoxelMesher; @@ -35,10 +40,15 @@ class GroundClutter : public Resource { GDCLASS(GroundClutter, Resource); public: +#ifdef VOXELMAN_PRESENT bool should_spawn(Ref chunk, int x, int y, int z); void add_meshes_to(Ref mesher, Ref chunk, int x, int y, int z); +#endif + +#ifdef TEXTURE_PACKER_PRESENT void add_textures_to(Ref packer); +#endif GroundClutter(); ~GroundClutter();