Make sure the dependencies are actually optional.

This commit is contained in:
Relintai 2020-04-06 22:53:09 +02:00
parent e1f43af571
commit 152be1328b
3 changed files with 29 additions and 2 deletions

6
SCsub
View File

@ -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",

View File

@ -22,6 +22,7 @@ SOFTWARE.
#include "ground_clutter.h"
#ifdef VOXELMAN_PRESENT
#include "../../voxelman/world/voxel_chunk.h"
bool GroundClutter::should_spawn(Ref<VoxelChunk> chunk, int x, int y, int z) {
@ -35,11 +36,14 @@ void GroundClutter::add_meshes_to(Ref<VoxelMesher> mesher, Ref<VoxelChunk> 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<TexturePacker> 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
}

View File

@ -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<VoxelChunk> chunk, int x, int y, int z);
void add_meshes_to(Ref<VoxelMesher> mesher, Ref<VoxelChunk> chunk, int x, int y, int z);
#endif
#ifdef TEXTURE_PACKER_PRESENT
void add_textures_to(Ref<TexturePacker> packer);
#endif
GroundClutter();
~GroundClutter();