diff --git a/SCsub b/SCsub index 2d7a0a7..2cb8905 100644 --- a/SCsub +++ b/SCsub @@ -4,20 +4,27 @@ Import('env') module_env = env.Clone() +has_texture_packer = False +if os.path.isdir('../texture_packer'): + module_env.Append(CPPDEFINES=['TEXTURE_PACKER_PRESENT']) + has_texture_packer = True + if os.path.isdir('../mesh_data_resource'): module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) +if os.path.isdir('../props'): + module_env.Append(CPPDEFINES=['PROPS_PRESENT']) + sources = [ "register_types.cpp", "library/voxelman_library.cpp", "library/voxelman_library_simple.cpp", - "library/voxelman_library_merger.cpp", + "library/voxel_surface.cpp", "library/voxel_surface_simple.cpp", - "library/voxel_surface_merger.cpp", "data/voxel_light.cpp", @@ -46,7 +53,6 @@ sources = [ "meshers/cubic_mesher/voxel_mesher_cubic.cpp", "meshers/cubic_mesher/voxel_cube_points.cpp", - "level_generator/voxelman_level_generator.cpp", "areas/world_area.cpp", @@ -56,6 +62,11 @@ sources = [ "thirdparty/lz4/lz4.c" ] +if has_texture_packer: + sources.append("library/voxelman_library_merger.cpp") + sources.append("library/voxel_surface_merger.cpp") + + if ARGUMENTS.get('custom_modules_shared', 'no') == 'yes': # Shared lib compilation module_env.Append(CCFLAGS=['-fPIC']) diff --git a/library/voxel_surface.cpp b/library/voxel_surface.cpp index 26d5c15..0d8ce37 100644 --- a/library/voxel_surface.cpp +++ b/library/voxel_surface.cpp @@ -50,13 +50,6 @@ void VoxelSurface::set_rect(const VoxelSurfaceSides side, const Rect2 rect) { _rects[side] = rect; } -Ref VoxelSurface::get_clutter() { - return _clutter; -} -void VoxelSurface::set_clutter(Ref clutter) { - _clutter = clutter; -} - Ref VoxelSurface::get_library() const { return Ref(_library); } @@ -124,10 +117,6 @@ void VoxelSurface::_bind_methods() { ClassDB::bind_method(D_METHOD("is_transparent"), &VoxelSurface::is_transparent); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "transparent"), "set_transparent", "is_transparent"); - ClassDB::bind_method(D_METHOD("get_clutter"), &VoxelSurface::get_clutter); - ClassDB::bind_method(D_METHOD("set_clutter"), &VoxelSurface::set_clutter); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "clutter", PROPERTY_HINT_RESOURCE_TYPE, "GroundClutter"), "set_clutter", "get_clutter"); - ClassDB::bind_method(D_METHOD("get_rect", "side"), &VoxelSurface::get_rect); ClassDB::bind_method(D_METHOD("set_rect", "side", "rect"), &VoxelSurface::set_rect); diff --git a/library/voxel_surface.h b/library/voxel_surface.h index 36aedef..fad4629 100644 --- a/library/voxel_surface.h +++ b/library/voxel_surface.h @@ -30,11 +30,9 @@ SOFTWARE. #include "core/vector.h" #include "scene/resources/material.h" -#include "../../props/clutter/ground_clutter.h" #include "voxelman_library.h" class VoxelmanLibrary; -class GroundClutter; class VoxelSurface : public Resource { GDCLASS(VoxelSurface, Resource) @@ -78,9 +76,6 @@ public: Rect2 get_rect(const VoxelSurfaceSides side) const; void set_rect(const VoxelSurfaceSides side, const Rect2 rect); - Ref get_clutter(); - void set_clutter(Ref clutter); - Ref get_library() const; void set_library(Ref library); @@ -101,7 +96,6 @@ protected: int _mesher_index; bool _is_transparent; Rect2 _rects[VOXEL_SIDES_COUNT]; - Ref _clutter; }; VARIANT_ENUM_CAST(VoxelSurface::VoxelSurfaceSides); diff --git a/meshers/voxel_mesher.cpp b/meshers/voxel_mesher.cpp index 8759304..c39b044 100644 --- a/meshers/voxel_mesher.cpp +++ b/meshers/voxel_mesher.cpp @@ -408,6 +408,7 @@ void VoxelMesher::add_chunk_liquid(Ref chunk) { call("_add_chunk_liquid", chunk); } +#ifdef MESH_DATA_RESOURCE_PRESENT void VoxelMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { Transform transform = Transform(Basis(rotation).scaled(scale), position); @@ -536,6 +537,7 @@ void VoxelMesher::add_mesh_data_resource_transform(Ref mesh, c add_indices(ic + index); } } +#endif void VoxelMesher::add_mesher(const Ref &mesher) { call("_add_mesher", mesher); @@ -964,8 +966,10 @@ void VoxelMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &VoxelMesher::add_chunk); ClassDB::bind_method(D_METHOD("add_chunk_liquid", "chunk"), &VoxelMesher::add_chunk_liquid); +#ifdef MESH_DATA_RESOURCE_PRESENT ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &VoxelMesher::add_mesh_data_resource, DEFVAL(Rect2(0, 0, 1, 1)), DEFVAL(Vector3(1.0, 1.0, 1.0)), DEFVAL(Vector3()), DEFVAL(Vector3())); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform", "mesh", "transform", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); +#endif BIND_VMETHOD(MethodInfo("_add_mesher", PropertyInfo(Variant::OBJECT, "mesher", PROPERTY_HINT_RESOURCE_TYPE, "VoxelMesher"))); ClassDB::bind_method(D_METHOD("add_mesher", "mesher"), &VoxelMesher::add_mesher); diff --git a/meshers/voxel_mesher.h b/meshers/voxel_mesher.h index 4971de1..7e70d62 100644 --- a/meshers/voxel_mesher.h +++ b/meshers/voxel_mesher.h @@ -38,7 +38,10 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" +#ifdef MESH_DATA_RESOURCE_PRESENT #include "../../mesh_data_resource/mesh_data_resource.h" +#endif + #include "../library/voxelman_library.h" const double PI_2 = 3.141592653589793238463 / 2; @@ -114,8 +117,10 @@ public: void add_chunk_liquid(Ref chunk); +#ifdef MESH_DATA_RESOURCE_PRESENT void add_mesh_data_resource(Ref mesh, const Vector3 position = Vector3(0, 0, 0), const Vector3 rotation = Vector3(0, 0, 0), const Vector3 scale = Vector3(1.0, 1.0, 1.0), const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_transform(Ref mesh, const Transform transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); +#endif void add_mesher(const Ref &mesher); void _add_mesher(const Ref &mesher); diff --git a/register_types.cpp b/register_types.cpp index c2a1f48..93e98b0 100644 --- a/register_types.cpp +++ b/register_types.cpp @@ -23,13 +23,16 @@ SOFTWARE. #include "register_types.h" #include "library/voxel_surface.h" -#include "library/voxel_surface_merger.h" #include "library/voxel_surface_simple.h" #include "library/voxelman_library.h" -#include "library/voxelman_library_merger.h" #include "library/voxelman_library_simple.h" +#ifdef TEXTURE_PACKER_PRESENT +#include "library/voxel_surface_merger.h" +#include "library/voxelman_library_merger.h" +#endif + #include "data/voxel_light.h" #include "meshers/transvoxel_uv_mesher/transvoxel_cell_data.h" #include "meshers/transvoxel_uv_mesher/voxel_mesher_uv_transvoxel.h" @@ -65,11 +68,14 @@ void register_voxelman_types() { ClassDB::register_class(); ClassDB::register_class(); - ClassDB::register_class(); ClassDB::register_class(); ClassDB::register_class(); + +#ifdef TEXTURE_PACKER_PRESENT + ClassDB::register_class(); ClassDB::register_class(); +#endif ClassDB::register_class(); diff --git a/world/default/voxel_chunk_default.h b/world/default/voxel_chunk_default.h index 6c93cb2..99341dc 100644 --- a/world/default/voxel_chunk_default.h +++ b/world/default/voxel_chunk_default.h @@ -52,7 +52,6 @@ SOFTWARE. #include "../../library/voxel_surface.h" #include "../../library/voxelman_library.h" -#include "../../../mesh_data_resource/mesh_data_resource.h" #include "../voxel_chunk_prop_data.h" class VoxelWorld; diff --git a/world/voxel_chunk.h b/world/voxel_chunk.h index 26b5e3f..34dbecf 100644 --- a/world/voxel_chunk.h +++ b/world/voxel_chunk.h @@ -50,8 +50,6 @@ SOFTWARE. #include "../library/voxel_surface.h" #include "../library/voxelman_library.h" -#include "../../mesh_data_resource/mesh_data_resource.h" - #include "voxel_chunk_prop_data.h" class VoxelWorld;