diff --git a/modules/entity_spell_system/SCsub b/modules/entity_spell_system/SCsub index 94974ecad..c2c09abda 100644 --- a/modules/entity_spell_system/SCsub +++ b/modules/entity_spell_system/SCsub @@ -4,9 +4,6 @@ Import('env') module_env = env.Clone() -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - sources = [ "register_types.cpp", diff --git a/modules/entity_spell_system/data/items/model_visual_entry.cpp b/modules/entity_spell_system/data/items/model_visual_entry.cpp index 49f6dd50d..5a373428a 100644 --- a/modules/entity_spell_system/data/items/model_visual_entry.cpp +++ b/modules/entity_spell_system/data/items/model_visual_entry.cpp @@ -24,6 +24,8 @@ SOFTWARE. #include "../../singletons/ess.h" +#include "modules/modules_enabled.gen.h" + const String ModelVisualEntry::BINDING_STRING_MODEL_VISUAL_ENTRY_TYPES = "Bone,Attachment"; ModelVisualEntry::ModenVisualEntryType ModelVisualEntry::get_type() const { @@ -61,7 +63,7 @@ void ModelVisualEntry::set_group(const int value) { _group = value; } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref ModelVisualEntry::get_mesh(const int index) { ERR_FAIL_INDEX_V(index, _entries.size(), Ref()); @@ -155,7 +157,7 @@ bool ModelVisualEntry::_set(const StringName &p_name, const Variant &p_value) { _entries.write[index].texture = p_value; return true; -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED } else if (p == "mesh") { _entries.write[index].mesh = p_value; @@ -194,7 +196,7 @@ bool ModelVisualEntry::_get(const StringName &p_name, Variant &r_ret) const { r_ret = _entries[index].texture; return true; -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED } else if (p == "mesh") { r_ret = _entries[index].mesh; @@ -220,7 +222,7 @@ bool ModelVisualEntry::_get(const StringName &p_name, Variant &r_ret) const { void ModelVisualEntry::_get_property_list(List *p_list) const { for (int i = 0; i < _entries.size(); ++i) { if (_type == ModelVisualEntry::MODEL_VISUAL_ENTRY_TYPE_BONE) { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED p_list->push_back(PropertyInfo(Variant::OBJECT, "entry_" + itos(i) + "/mesh", PROPERTY_HINT_RESOURCE_TYPE, "MeshDataResource", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL)); #endif p_list->push_back(PropertyInfo(Variant::OBJECT, "entry_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL)); @@ -282,7 +284,7 @@ void ModelVisualEntry::_bind_methods() { ClassDB::bind_method(D_METHOD("set_group", "value"), &ModelVisualEntry::set_group); ADD_PROPERTY(PropertyInfo(Variant::INT, "group", PROPERTY_HINT_ENUM), "set_group", "get_group"); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("get_mesh", "index"), &ModelVisualEntry::get_mesh); ClassDB::bind_method(D_METHOD("set_mesh", "index", "value"), &ModelVisualEntry::set_mesh); #endif diff --git a/modules/entity_spell_system/data/items/model_visual_entry.h b/modules/entity_spell_system/data/items/model_visual_entry.h index ccbd55aad..8682bb60e 100644 --- a/modules/entity_spell_system/data/items/model_visual_entry.h +++ b/modules/entity_spell_system/data/items/model_visual_entry.h @@ -34,7 +34,9 @@ SOFTWARE. #include "scene/resources/mesh.h" #include "scene/resources/packed_scene.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../../mesh_data_resource/mesh_data_resource.h" #endif @@ -65,7 +67,7 @@ public: int get_group() const; void set_group(const int value); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref get_mesh(const int index); void set_mesh(const int index, const Ref &mesh); #endif @@ -90,7 +92,7 @@ public: protected: struct MVEE { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref mesh; #endif Ref texture; @@ -104,7 +106,7 @@ protected: } ~MVEE() { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED mesh.unref(); #endif texture.unref(); diff --git a/modules/entity_spell_system/material_cache/ess_material_cache.cpp b/modules/entity_spell_system/material_cache/ess_material_cache.cpp index 95fbd83ea..ae8ff74ab 100644 --- a/modules/entity_spell_system/material_cache/ess_material_cache.cpp +++ b/modules/entity_spell_system/material_cache/ess_material_cache.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "../../props/props/prop_data_tiled_wall.h" #include "../../props/tiled_wall/tiled_wall_data.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -180,7 +180,7 @@ void ESSMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -221,7 +221,7 @@ void ESSMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/mesh_utils/SCsub b/modules/mesh_utils/SCsub index 2b2dfff46..c1eb6dc32 100644 --- a/modules/mesh_utils/SCsub +++ b/modules/mesh_utils/SCsub @@ -5,9 +5,6 @@ Import('env') module_env = env.Clone() -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - sources = [ "register_types.cpp", "mesh_utils.cpp", diff --git a/modules/mesh_utils/mesh_merger.cpp b/modules/mesh_utils/mesh_merger.cpp index c1e4a5b3b..765c8fb18 100644 --- a/modules/mesh_utils/mesh_merger.cpp +++ b/modules/mesh_utils/mesh_merger.cpp @@ -26,6 +26,8 @@ SOFTWARE. #include "scene/3d/mesh_instance.h" +#include "modules/modules_enabled.gen.h" + bool MeshMerger::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -432,7 +434,7 @@ void MeshMerger::reset() { _last_tangent = Plane(); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void MeshMerger::add_mesh_data_resource(Ref mesh, const Transform transform, Rect2 uv_rect) { ERR_FAIL_COND(mesh->get_array().size() == 0); @@ -933,7 +935,7 @@ void MeshMerger::_bind_methods() { ClassDB::bind_method(D_METHOD("set_uv_margin", "value"), &MeshMerger::set_uv_margin); ADD_PROPERTY(PropertyInfo(Variant::RECT2, "uv_margin"), "set_uv_margin", "get_uv_margin"); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "transform", "uv_rect"), &MeshMerger::add_mesh_data_resource, DEFVAL(Transform()), DEFVAL(Rect2(0, 0, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_bone", "mesh", "bones", "wrights", "transform", "uv_rect"), &MeshMerger::add_mesh_data_resource_bone, DEFVAL(Transform()), DEFVAL(Rect2(0, 0, 1, 1))); #endif diff --git a/modules/mesh_utils/mesh_merger.h b/modules/mesh_utils/mesh_merger.h index 5def0c499..994054873 100644 --- a/modules/mesh_utils/mesh_merger.h +++ b/modules/mesh_utils/mesh_merger.h @@ -40,7 +40,9 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/mesh_data_resource.h" #endif @@ -103,7 +105,7 @@ public: void reset(); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void add_mesh_data_resource(Ref mesh, const Transform transform = Transform(), const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_bone(Ref mesh, const Vector &bones, const Vector &weights, const Transform transform = Transform(), const Rect2 uv_rect = Rect2(0, 0, 1, 1)); #endif diff --git a/modules/props/SCsub b/modules/props/SCsub index db771abf4..6051a5293 100644 --- a/modules/props/SCsub +++ b/modules/props/SCsub @@ -6,9 +6,6 @@ module_env = env.Clone() import version -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - if os.path.isdir('../mesh_utils'): module_env.Append(CPPDEFINES=['MESH_UTILS_PRESENT']) diff --git a/modules/props/material_cache/prop_material_cache.cpp b/modules/props/material_cache/prop_material_cache.cpp index 1ccd2c7bd..6efbe0ea7 100644 --- a/modules/props/material_cache/prop_material_cache.cpp +++ b/modules/props/material_cache/prop_material_cache.cpp @@ -28,7 +28,9 @@ SOFTWARE. #include "../singleton/prop_cache.h" #include "../tiled_wall/tiled_wall_data.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -173,7 +175,7 @@ void PropMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -214,7 +216,7 @@ void PropMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/props/prop_instance.cpp b/modules/props/prop_instance.cpp index a4692ecc8..fcef14a04 100644 --- a/modules/props/prop_instance.cpp +++ b/modules/props/prop_instance.cpp @@ -4,7 +4,9 @@ #include "scene/3d/light.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -195,7 +197,7 @@ void PropInstance::_prop_preprocess(Transform transform, const Ref &pr continue; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref mesh_data = e; if (mesh_data.is_valid()) { diff --git a/modules/props/prop_instance_merger.cpp b/modules/props/prop_instance_merger.cpp index 60cd4694c..c113d50d4 100644 --- a/modules/props/prop_instance_merger.cpp +++ b/modules/props/prop_instance_merger.cpp @@ -22,7 +22,7 @@ #include "./singleton/prop_cache.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -669,7 +669,7 @@ void PropInstanceMerger::_prop_preprocess(Transform transform, const Ref mesh_data = e; if (mesh_data.is_valid()) { diff --git a/modules/props/prop_instance_prop_job.cpp b/modules/props/prop_instance_prop_job.cpp index 98f69b3cb..1d91382f6 100644 --- a/modules/props/prop_instance_prop_job.cpp +++ b/modules/props/prop_instance_prop_job.cpp @@ -35,7 +35,7 @@ SOFTWARE. #include "modules/modules_enabled.gen.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/mesh_data_resource.h" #endif @@ -47,7 +47,7 @@ SOFTWARE. #include "../texture_packer/texture_packer.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -114,7 +114,7 @@ void PropInstancePropJob::set_prop_mesher(const Ref &mesher) { _prop_mesher = mesher; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void PropInstancePropJob::add_mesh(const Ref &mesh_data, const Transform &base_transform) { PMDREntry e; e.mesh_data = mesh_data; @@ -150,7 +150,7 @@ void PropInstancePropJob::clear_lights() { void PropInstancePropJob::_physics_process(float delta) { if (_phase == 0) { phase_physics_process(); - } + } } void PropInstancePropJob::_execute_phase() { @@ -161,7 +161,7 @@ void PropInstancePropJob::_execute_phase() { finished(); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) { //reset_meshes(); set_complete(true); @@ -200,7 +200,9 @@ void PropInstancePropJob::_reset() { _prop_tiled_wall_datas.clear(); +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED _prop_mesh_datas.clear(); +#endif clear_collision_shapes(); set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); @@ -291,14 +293,18 @@ void PropInstancePropJob::phase_prop() { } if (should_do()) { - if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) { + if ( +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED + _prop_mesh_datas.size() == 0 && +#endif + _prop_tiled_wall_datas.size() == 0) { //reset_meshes(); reset_stages(); set_complete(true); //So threadpool knows it's done return; } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < _prop_mesh_datas.size(); ++i) { PMDREntry &e = _prop_mesh_datas.write[i]; @@ -419,7 +425,7 @@ void PropInstancePropJob::phase_steps() { if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) { RS::get_singleton()->mesh_remove_surface(mesh_rid, 0); - } + } } } } @@ -605,7 +611,7 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const { if (Math::is_equal_approx(v.x, vc.x) && Math::is_equal_approx(v.y, vc.y) && Math::is_equal_approx(v.z, vc.z)) { equals.push_back(j); - } + } } for (int k = 0; k < equals.size(); ++k) { @@ -616,22 +622,22 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const { if (has_normals) { normals.remove(remk); - } + } if (has_uvs) { uvs.remove(remk); - } + } if (has_colors) { colors.remove(remk); - } + } for (int j = 0; j < indices.size(); ++j) { int indx = indices[j]; if (indx == remk) { indices.set(j, i); - } else if (indx > remk) { + } else if (indx > remk) { indices.set(j, indx - 1); - } + } } } @@ -642,13 +648,13 @@ Array PropInstancePropJob::merge_mesh_array(Array arr) const { if (has_normals) { arr[RenderingServer::ARRAY_NORMAL] = normals; - } + } if (has_uvs) { arr[RenderingServer::ARRAY_TEX_UV] = uvs; - } + } if (has_colors) { arr[RenderingServer::ARRAY_COLOR] = colors; - } + } arr[RenderingServer::ARRAY_INDEX] = indices; @@ -669,7 +675,7 @@ Array PropInstancePropJob::bake_mesh_array_uv(Array arr, Ref tex, const if (colors.size() < uvs.size()) { colors.resize(uvs.size()); - } + } img->lock(); @@ -706,7 +712,7 @@ void PropInstancePropJob::reset_meshes() { if (RS::get_singleton()->mesh_get_surface_count(mesh_rid) > 0) { RS::get_singleton()->mesh_remove_surface(mesh_rid, 0); - } + } } } } diff --git a/modules/props/prop_instance_prop_job.h b/modules/props/prop_instance_prop_job.h index 8e94ac6e2..e5df475d1 100644 --- a/modules/props/prop_instance_prop_job.h +++ b/modules/props/prop_instance_prop_job.h @@ -24,6 +24,8 @@ SOFTWARE. #include "prop_instance_job.h" +#include "modules/modules_enabled.gen.h" + class PropMesher; class PropInstance; class PropInstanceMerger; @@ -33,7 +35,7 @@ class Shape; class PropLight; class PropDataTiledWall; -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED class PropDataMeshData; #endif @@ -60,7 +62,7 @@ public: Ref get_prop_mesher() const; void set_prop_mesher(const Ref &mesher); -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void add_mesh(const Ref &mesh_data, const Transform &base_transform); void clear_meshes(); #endif @@ -99,7 +101,7 @@ protected: static void _bind_methods(); protected: -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED struct PMDREntry { Ref mesh_data; Transform base_transform; @@ -130,7 +132,7 @@ protected: Ref _prop_mesher; PropInstanceMerger *_prop_instace; -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Vector _prop_mesh_datas; #endif diff --git a/modules/props/prop_mesher.cpp b/modules/props/prop_mesher.cpp index 1b5c9380c..35f3ec2ff 100644 --- a/modules/props/prop_mesher.cpp +++ b/modules/props/prop_mesher.cpp @@ -743,7 +743,7 @@ Vector2 PropMesher::transform_uv_scaled(const Vector2 &uv, const Rect2 &rect, co } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void PropMesher::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); @@ -1488,7 +1488,7 @@ void PropMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &PropMesher::transform_uv); ClassDB::bind_method(D_METHOD("transform_uv_scaled", "uv", "rect", "x", "y", "texture_scale"), &PropMesher::transform_uv_scaled); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &PropMesher::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"), &PropMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &PropMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/modules/props/prop_mesher.h b/modules/props/prop_mesher.h index 2fc67c7ca..dd640c4b4 100644 --- a/modules/props/prop_mesher.h +++ b/modules/props/prop_mesher.h @@ -37,7 +37,7 @@ SOFTWARE. #include "modules/modules_enabled.gen.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/mesh_data_resource.h" #endif @@ -136,7 +136,7 @@ public: Vector2 transform_uv(const Vector2 &uv, const Rect2 &rect) const; Vector2 transform_uv_scaled(const Vector2 &uv, const Rect2 &rect, const int x, const int y, const int texture_scale) const; -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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)); void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); diff --git a/modules/props/singleton/prop_utils.cpp b/modules/props/singleton/prop_utils.cpp index 760f1be9b..d0713335f 100644 --- a/modules/props/singleton/prop_utils.cpp +++ b/modules/props/singleton/prop_utils.cpp @@ -31,8 +31,11 @@ SOFTWARE. #include "scene/3d/room_manager.h" #include "scene/3d/mesh_instance.h" +#include "scene/resources/mesh.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/nodes/mesh_data_instance.h" #endif @@ -340,7 +343,7 @@ void PropUtils::get_mesh_arrays(Node *node, Vector> *arrs) { } } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED { MeshDataInstance *mdi = Object::cast_to(node); diff --git a/modules/props_2d/SCsub b/modules/props_2d/SCsub index 6a0e8ee12..ebcf18c44 100644 --- a/modules/props_2d/SCsub +++ b/modules/props_2d/SCsub @@ -6,9 +6,6 @@ module_env = env.Clone() import version -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - if os.path.isdir('../terraman_2d'): module_env.Append(CPPDEFINES=['TERRAMAN_2D_PRESENT']) diff --git a/modules/props_2d/material_cache/prop_2d_material_cache.cpp b/modules/props_2d/material_cache/prop_2d_material_cache.cpp index c8b4bab55..c87e63726 100644 --- a/modules/props_2d/material_cache/prop_2d_material_cache.cpp +++ b/modules/props_2d/material_cache/prop_2d_material_cache.cpp @@ -28,7 +28,9 @@ SOFTWARE. #include "../singleton/prop_2d_cache.h" #include "../tiled_wall/tiled_wall_2d_data.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. #define PROPS_2D_PRESENT 1 @@ -139,7 +141,7 @@ void Prop2DMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -180,7 +182,7 @@ void Prop2DMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/props_2d/prop_2d_instance.cpp b/modules/props_2d/prop_2d_instance.cpp index 78e6fdf18..2c4f5743e 100644 --- a/modules/props_2d/prop_2d_instance.cpp +++ b/modules/props_2d/prop_2d_instance.cpp @@ -4,7 +4,9 @@ #include "scene/3d/light.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. #define PROPS_2D_PRESENT 1 @@ -193,7 +195,7 @@ void Prop2DInstance::_prop_preprocess(Transform2D transform, const Ref mesh_data = e; diff --git a/modules/props_2d/prop_2d_instance_merger.cpp b/modules/props_2d/prop_2d_instance_merger.cpp index 7da1e1671..aca49ce2f 100644 --- a/modules/props_2d/prop_2d_instance_merger.cpp +++ b/modules/props_2d/prop_2d_instance_merger.cpp @@ -21,7 +21,9 @@ #include "servers/rendering_server.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. #define PROPS_2D_PRESENT 1 @@ -458,7 +460,7 @@ void Prop2DInstanceMerger::_prop_preprocess(Transform2D transform, const Ref mesh_data = e; if (mesh_data.is_valid()) { diff --git a/modules/props_2d/prop_2d_instance_prop_job.cpp b/modules/props_2d/prop_2d_instance_prop_job.cpp index e1a069828..f9ab6e87f 100644 --- a/modules/props_2d/prop_2d_instance_prop_job.cpp +++ b/modules/props_2d/prop_2d_instance_prop_job.cpp @@ -30,7 +30,9 @@ SOFTWARE. #include "scene/resources/shape.h" #include "singleton/prop_2d_cache.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/mesh_data_resource.h" #endif @@ -42,7 +44,7 @@ SOFTWARE. #include "../texture_packer/texture_packer.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED //define PROPS_PRESENT, so things compile. That module's scsub will define this too while compiling, //but not when included from here. #define PROPS_2D_PRESENT 1 @@ -90,7 +92,7 @@ void Prop2DInstanceProp2DJob::set_prop_mesher(const Ref &mesher) { _prop_mesher = mesher; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void Prop2DInstanceProp2DJob::add_mesh(const Ref &mesh_data, const Transform2D &base_transform) { PMDREntry e; e.mesh_data = mesh_data; @@ -137,7 +139,7 @@ void Prop2DInstanceProp2DJob::_execute_phase() { finished(); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) { //reset_meshes(); set_complete(true); @@ -172,8 +174,9 @@ void Prop2DInstanceProp2DJob::_reset() { } _prop_tiled_wall_datas.clear(); - +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED _prop_mesh_datas.clear(); +#endif clear_collision_shapes(); set_build_phase_type(BUILD_PHASE_TYPE_PHYSICS_PROCESS); @@ -267,14 +270,19 @@ void Prop2DInstanceProp2DJob::phase_prop() { } if (should_do()) { - if (_prop_mesh_datas.size() == 0 && _prop_tiled_wall_datas.size() == 0) { + if ( +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED + _prop_mesh_datas.size() == 0 && +#endif + _prop_tiled_wall_datas.size() == 0 + ) { //reset_meshes(); reset_stages(); set_complete(true); //So threadpool knows it's done return; } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < _prop_mesh_datas.size(); ++i) { PMDREntry &e = _prop_mesh_datas.write[i]; diff --git a/modules/props_2d/prop_2d_instance_prop_job.h b/modules/props_2d/prop_2d_instance_prop_job.h index 882342b5e..ae5e1b803 100644 --- a/modules/props_2d/prop_2d_instance_prop_job.h +++ b/modules/props_2d/prop_2d_instance_prop_job.h @@ -26,6 +26,8 @@ SOFTWARE. #include "scene/resources/shape_2d.h" +#include "modules/modules_enabled.gen.h" + class Prop2DMesher; class Prop2DInstance; class Prop2DInstanceMerger; @@ -35,7 +37,7 @@ class Shape; class Prop2DLight; class Prop2DDataTiledWall2D; -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED class Prop2DDataMeshData; #endif @@ -56,7 +58,7 @@ public: Ref get_prop_mesher() const; void set_prop_mesher(const Ref &mesher); -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void add_mesh(const Ref &mesh_data, const Transform2D &base_transform); void clear_meshes(); #endif @@ -90,7 +92,7 @@ protected: static void _bind_methods(); protected: -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED struct PMDREntry { Ref mesh_data; Transform2D base_transform; @@ -117,7 +119,7 @@ protected: Ref _prop_mesher; Prop2DInstanceMerger *_prop_instace; -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Vector _prop_mesh_datas; #endif diff --git a/modules/props_2d/prop_2d_mesher.cpp b/modules/props_2d/prop_2d_mesher.cpp index 8a1bae1f1..2b6a318f8 100644 --- a/modules/props_2d/prop_2d_mesher.cpp +++ b/modules/props_2d/prop_2d_mesher.cpp @@ -29,6 +29,8 @@ SOFTWARE. #include "material_cache/prop_2d_material_cache.h" #include "tiled_wall/tiled_wall_2d_data.h" +#include "modules/modules_enabled.gen.h" + const String Prop2DMesher::BINDING_STRING_BUILD_FLAGS = "Use Lighting,Use AO,Use RAO,Bake Lights"; bool Prop2DMesher::Vertex::operator==(const Vertex &p_vertex) const { @@ -528,7 +530,7 @@ _FORCE_INLINE_ Vector2 Prop2DMesher::transform_uv(const Vector2 &uv, const Rect2 return ruv; } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void Prop2DMesher::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); @@ -1170,7 +1172,7 @@ void Prop2DMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_tiled_wall_mesh_rect_simple", "x", "y", "transform", "texture_rect"), &Prop2DMesher::add_tiled_wall_mesh_rect_simple); ClassDB::bind_method(D_METHOD("transform_uv", "uv", "rect"), &Prop2DMesher::transform_uv); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &Prop2DMesher::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"), &Prop2DMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &Prop2DMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/modules/props_2d/prop_2d_mesher.h b/modules/props_2d/prop_2d_mesher.h index c2192e314..4651f7e75 100644 --- a/modules/props_2d/prop_2d_mesher.h +++ b/modules/props_2d/prop_2d_mesher.h @@ -35,7 +35,9 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../mesh_data_resource/mesh_data_resource.h" #endif @@ -122,7 +124,7 @@ public: void add_tiled_wall_mesh_rect_simple(const int x, const int y, const Transform2D &transform, const Rect2 &texture_uv_rect, const Vector2 &size); Vector2 transform_uv(const Vector2 &uv, const Rect2 &rect) const; -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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)); void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); diff --git a/modules/props_2d/singleton/prop_2d_utils.cpp b/modules/props_2d/singleton/prop_2d_utils.cpp index ccbdc938b..5d73b6261 100644 --- a/modules/props_2d/singleton/prop_2d_utils.cpp +++ b/modules/props_2d/singleton/prop_2d_utils.cpp @@ -32,7 +32,9 @@ SOFTWARE. #include "scene/3d/mesh_instance.h" -#if MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/nodes/mesh_data_instance.h" #endif diff --git a/modules/terraman/SCsub b/modules/terraman/SCsub index 0f4317b1b..ff2770a76 100644 --- a/modules/terraman/SCsub +++ b/modules/terraman/SCsub @@ -4,9 +4,6 @@ Import('env') module_env = env.Clone() -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - if os.path.isdir('../mesh_utils'): module_env.Append(CPPDEFINES=['MESH_UTILS_PRESENT']) diff --git a/modules/terraman/library/terrain_library_merger.cpp b/modules/terraman/library/terrain_library_merger.cpp index 33b0b0c53..f970a496f 100644 --- a/modules/terraman/library/terrain_library_merger.cpp +++ b/modules/terraman/library/terrain_library_merger.cpp @@ -32,7 +32,7 @@ SOFTWARE. #include "../../props/props/prop_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif #endif @@ -411,7 +411,7 @@ bool TerrainLibraryMerger::process_prop_textures(Ref prop) { bool texture_added = false; for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/terraman/library/terrain_library_merger_pcm.cpp b/modules/terraman/library/terrain_library_merger_pcm.cpp index caa68178a..1bf3142af 100644 --- a/modules/terraman/library/terrain_library_merger_pcm.cpp +++ b/modules/terraman/library/terrain_library_merger_pcm.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "../../props/props/prop_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif #endif @@ -415,7 +415,7 @@ void TerrainLibraryMergerPCM::_prop_material_cache_get_key(Ref chu #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); @@ -510,7 +510,7 @@ void TerrainLibraryMergerPCM::_prop_material_cache_get_key(Ref chu #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); diff --git a/modules/terraman/library/terrain_material_cache.cpp b/modules/terraman/library/terrain_material_cache.cpp index c2ed8d3b9..e9254daad 100644 --- a/modules/terraman/library/terrain_material_cache.cpp +++ b/modules/terraman/library/terrain_material_cache.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "../../props/props/prop_data.h" #include "../../props/props/prop_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif #endif @@ -205,7 +205,7 @@ void TerrainMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -231,7 +231,7 @@ void TerrainMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/terraman/meshers/terrain_mesher.cpp b/modules/terraman/meshers/terrain_mesher.cpp index 8aabeee6f..390c1e0bf 100644 --- a/modules/terraman/meshers/terrain_mesher.cpp +++ b/modules/terraman/meshers/terrain_mesher.cpp @@ -29,6 +29,8 @@ SOFTWARE. #include "../world/default/terrain_chunk_default.h" #include "../world/terrain_chunk.h" +#include "modules/modules_enabled.gen.h" + bool TerrainMesher::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -433,7 +435,7 @@ void TerrainMesher::add_chunk(Ref chunk) { call("_add_chunk", chunk); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void TerrainMesher::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); @@ -992,7 +994,7 @@ void TerrainMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &TerrainMesher::add_chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &TerrainMesher::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"), &TerrainMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &TerrainMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/modules/terraman/meshers/terrain_mesher.h b/modules/terraman/meshers/terrain_mesher.h index 256061b82..23a6a5375 100644 --- a/modules/terraman/meshers/terrain_mesher.h +++ b/modules/terraman/meshers/terrain_mesher.h @@ -39,7 +39,9 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/mesh_data_resource.h" #endif @@ -127,7 +129,7 @@ public: void add_chunk(Ref chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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)); void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); diff --git a/modules/terraman/world/jobs/terrain_prop_job.cpp b/modules/terraman/world/jobs/terrain_prop_job.cpp index a34d50e77..7d2815d3c 100644 --- a/modules/terraman/world/jobs/terrain_prop_job.cpp +++ b/modules/terraman/world/jobs/terrain_prop_job.cpp @@ -34,7 +34,9 @@ SOFTWARE. #include "scene/resources/world_3d.h" #include "servers/physics_server.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../../mesh_data_resource/mesh_data_resource.h" #endif @@ -85,7 +87,7 @@ void TerrainPropJob::phase_physics_process() { chunk->colliders_clear(); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref mdr = chunk->mesh_data_resource_get(i); @@ -134,7 +136,7 @@ void TerrainPropJob::phase_physics_process() { } void TerrainPropJob::phase_prop() { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref chunk = _chunk; if (!get_prop_mesher().is_valid()) { @@ -235,7 +237,7 @@ void TerrainPropJob::_execute_phase() { Ref chunk = _chunk; if (!chunk.is_valid() -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED || chunk->mesh_data_resource_get_count() == 0 #endif ) { @@ -302,7 +304,7 @@ void TerrainPropJob::phase_setup() { OS::get_singleton()->delay_usec(100); } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) { Ref tex = _chunk->mesh_data_resource_get_texture(i); diff --git a/modules/terraman/world/terrain_chunk.cpp b/modules/terraman/world/terrain_chunk.cpp index ac9c3185f..582ba1fa1 100644 --- a/modules/terraman/world/terrain_chunk.cpp +++ b/modules/terraman/world/terrain_chunk.cpp @@ -736,7 +736,7 @@ void TerrainChunk::props_clear() { } #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int TerrainChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { ERR_FAIL_COND_V(!mesh.is_valid(), 0); @@ -1097,7 +1097,7 @@ TerrainChunk::~TerrainChunk() { props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED mesh_data_resource_clear(); #endif @@ -1470,7 +1470,7 @@ void TerrainChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("props_clear"), &TerrainChunk::props_clear); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_addv, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &TerrainChunk::mesh_data_resource_add, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); diff --git a/modules/terraman/world/terrain_chunk.h b/modules/terraman/world/terrain_chunk.h index 730d5e2fc..cffdc3a75 100644 --- a/modules/terraman/world/terrain_chunk.h +++ b/modules/terraman/world/terrain_chunk.h @@ -226,7 +226,7 @@ public: void props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_voxel_scale = true); int mesh_data_resource_add(const Transform &local_transform, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_voxel_scale = true); @@ -310,7 +310,7 @@ protected: }; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED struct MeshDataResourceEntry { Ref mesh; Ref texture; @@ -389,7 +389,7 @@ protected: Vector _props; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Vector _mesh_data_resources; #endif diff --git a/modules/terraman/world/terrain_world.cpp b/modules/terraman/world/terrain_world.cpp index 12446b1ee..3dee5346b 100644 --- a/modules/terraman/world/terrain_world.cpp +++ b/modules/terraman/world/terrain_world.cpp @@ -38,7 +38,7 @@ SOFTWARE. #include "../../props/props/prop_data_scene.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -656,7 +656,7 @@ void TerrainWorld::prop_add(Transform transform, const Ref &prop, cons continue; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref mesh_data = entry; if (mesh_data.is_valid()) { diff --git a/modules/terraman_2d/SCsub b/modules/terraman_2d/SCsub index 406568f40..d13ac50a7 100644 --- a/modules/terraman_2d/SCsub +++ b/modules/terraman_2d/SCsub @@ -4,9 +4,6 @@ Import('env') module_env = env.Clone() -if os.path.isdir('../mesh_data_resource'): - module_env.Append(CPPDEFINES=['MESH_DATA_RESOURCE_PRESENT']) - if os.path.isdir('../props_2d'): module_env.Append(CPPDEFINES=['PROPS_2D_PRESENT']) diff --git a/modules/terraman_2d/library/terrain_2d_library_merger.cpp b/modules/terraman_2d/library/terrain_2d_library_merger.cpp index fd5a0097c..c3a2cc89c 100644 --- a/modules/terraman_2d/library/terrain_2d_library_merger.cpp +++ b/modules/terraman_2d/library/terrain_2d_library_merger.cpp @@ -25,12 +25,14 @@ SOFTWARE. #include "scene/resources/packed_scene.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + #ifdef PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #include "../../props_2d/props/prop_2d_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif #endif @@ -363,7 +365,7 @@ bool Terrain2DLibraryMerger::process_prop_textures(Ref prop) { bool texture_added = false; for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/terraman_2d/library/terrain_2d_library_merger_pcm.cpp b/modules/terraman_2d/library/terrain_2d_library_merger_pcm.cpp index f3df64f02..29efec9bc 100644 --- a/modules/terraman_2d/library/terrain_2d_library_merger_pcm.cpp +++ b/modules/terraman_2d/library/terrain_2d_library_merger_pcm.cpp @@ -26,12 +26,14 @@ SOFTWARE. #include "scene/resources/packed_scene.h" #include "scene/resources/texture.h" +#include "modules/modules_enabled.gen.h" + #ifdef PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #include "../../props_2d/props/prop_2d_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif #endif @@ -260,7 +262,7 @@ void Terrain2DLibraryMergerPCM::_prop_material_cache_get_key(Ref #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); @@ -349,7 +351,7 @@ void Terrain2DLibraryMergerPCM::_prop_material_cache_get_key(Ref #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); diff --git a/modules/terraman_2d/library/terrain_2d_material_cache.cpp b/modules/terraman_2d/library/terrain_2d_material_cache.cpp index 5f6ccd890..7fed254f6 100644 --- a/modules/terraman_2d/library/terrain_2d_material_cache.cpp +++ b/modules/terraman_2d/library/terrain_2d_material_cache.cpp @@ -24,11 +24,13 @@ SOFTWARE. #include "../defines.h" +#include "modules/modules_enabled.gen.h" + #ifdef PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #include "../../props_2d/props/prop_2d_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif #endif @@ -166,7 +168,7 @@ void Terrain2DMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -192,7 +194,7 @@ void Terrain2DMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/terraman_2d/meshers/terrain_2d_mesher.cpp b/modules/terraman_2d/meshers/terrain_2d_mesher.cpp index aca2944a0..3ff60df86 100644 --- a/modules/terraman_2d/meshers/terrain_2d_mesher.cpp +++ b/modules/terraman_2d/meshers/terrain_2d_mesher.cpp @@ -31,6 +31,8 @@ SOFTWARE. #include "scene/resources/rectangle_shape_2d.h" #include "servers/physics_2d_server.h" +#include "modules/modules_enabled.gen.h" + bool Terrain2DMesher::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -482,7 +484,7 @@ void Terrain2DMesher::add_chunk(Ref chunk) { call("_add_chunk", chunk); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED void Terrain2DMesher::add_mesh_data_resource(Ref mesh, const Vector3 position, const Vector3 rotation, const Vector3 scale, const Rect2 uv_rect) { //Transform2D transform = Transform(Basis(rotation).scaled(scale), position); //TODO @@ -935,7 +937,7 @@ void Terrain2DMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &Terrain2DMesher::add_chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("add_mesh_data_resource", "mesh", "position", "rotation", "scale", "uv_rect"), &Terrain2DMesher::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"), &Terrain2DMesher::add_mesh_data_resource_transform, DEFVAL(Rect2(0, 0, 1, 1))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &Terrain2DMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/modules/terraman_2d/meshers/terrain_2d_mesher.h b/modules/terraman_2d/meshers/terrain_2d_mesher.h index 884d9cff2..0bab34846 100644 --- a/modules/terraman_2d/meshers/terrain_2d_mesher.h +++ b/modules/terraman_2d/meshers/terrain_2d_mesher.h @@ -38,7 +38,9 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/mesh_data_resource.h" #endif @@ -118,7 +120,7 @@ public: void add_chunk(Ref chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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 Transform2D transform, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); void add_mesh_data_resource_transform_colored(Ref mesh, const Transform2D transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); diff --git a/modules/terraman_2d/world/jobs/terrain_2d_prop_job.cpp b/modules/terraman_2d/world/jobs/terrain_2d_prop_job.cpp index a8bbe953f..793864b3f 100644 --- a/modules/terraman_2d/world/jobs/terrain_2d_prop_job.cpp +++ b/modules/terraman_2d/world/jobs/terrain_2d_prop_job.cpp @@ -32,7 +32,9 @@ SOFTWARE. #include "../../meshers/terrain_2d_mesher.h" #include "../default/terrain_2d_chunk_default.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../../mesh_data_resource/mesh_data_resource.h" #endif @@ -62,7 +64,7 @@ void Terrain2DProp2DJob::phase_physics_process() { chunk->colliders_clear(); */ -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED //TODO /* for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { @@ -114,7 +116,7 @@ void Terrain2DProp2DJob::phase_physics_process() { } void Terrain2DProp2DJob::phase_prop() { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref chunk = _chunk; if (!get_prop_mesher().is_valid()) { @@ -218,7 +220,7 @@ void Terrain2DProp2DJob::_execute_phase() { Ref chunk = _chunk; if (!chunk.is_valid() -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED || chunk->mesh_data_resource_get_count() == 0 #endif ) { @@ -282,7 +284,7 @@ void Terrain2DProp2DJob::phase_setup() { OS::get_singleton()->delay_usec(100); } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) { Ref tex = _chunk->mesh_data_resource_get_texture(i); diff --git a/modules/terraman_2d/world/terrain_2d_chunk.cpp b/modules/terraman_2d/world/terrain_2d_chunk.cpp index f99cb32d8..c4cb5acb8 100644 --- a/modules/terraman_2d/world/terrain_2d_chunk.cpp +++ b/modules/terraman_2d/world/terrain_2d_chunk.cpp @@ -34,6 +34,8 @@ SOFTWARE. #include "core/os/thread_pool.h" +#include "modules/modules_enabled.gen.h" + _FORCE_INLINE_ bool Terrain2DChunk::get_process() const { return _is_processing; } @@ -770,7 +772,7 @@ void Terrain2DChunk::props_clear() { } #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int Terrain2DChunk::mesh_data_resource_addv(const Vector2 &local_data_pos, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { //TODO /* @@ -1173,7 +1175,7 @@ Terrain2DChunk::~Terrain2DChunk() { props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED mesh_data_resource_clear(); #endif @@ -1590,7 +1592,7 @@ void Terrain2DChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("props_clear"), &Terrain2DChunk::props_clear); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &Terrain2DChunk::mesh_data_resource_addv, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &Terrain2DChunk::mesh_data_resource_add, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); diff --git a/modules/terraman_2d/world/terrain_2d_chunk.h b/modules/terraman_2d/world/terrain_2d_chunk.h index 13a3a3dc6..aa070706c 100644 --- a/modules/terraman_2d/world/terrain_2d_chunk.h +++ b/modules/terraman_2d/world/terrain_2d_chunk.h @@ -43,6 +43,8 @@ SOFTWARE. #include "../meshers/terrain_2d_mesher.h" +#include "modules/modules_enabled.gen.h" + #if PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #endif @@ -267,7 +269,7 @@ public: void props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int mesh_data_resource_addv(const Vector2 &local_data_pos, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_scale = true); int mesh_data_resource_add(const Transform2D &local_transform, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_scale = true); @@ -364,7 +366,7 @@ protected: }; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED struct MeshDataResourceEntry { Ref mesh; Ref texture; @@ -442,7 +444,7 @@ protected: Vector _props; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Vector _mesh_data_resources; #endif diff --git a/modules/terraman_2d/world/terrain_2d_world.cpp b/modules/terraman_2d/world/terrain_2d_world.cpp index 2930c06aa..5b8813edc 100644 --- a/modules/terraman_2d/world/terrain_2d_world.cpp +++ b/modules/terraman_2d/world/terrain_2d_world.cpp @@ -28,6 +28,8 @@ SOFTWARE. #include "../defines.h" +#include "modules/modules_enabled.gen.h" + #if PROPS_2D_PRESENT #include "../../props_2d/props/prop_2d_data.h" #include "../../props_2d/props/prop_2d_data_entry.h" @@ -36,7 +38,7 @@ SOFTWARE. #include "../../props_2d/props/prop_2d_data_scene.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h" #endif @@ -709,7 +711,7 @@ void Terrain2DWorld::prop_add(Transform transform, const Ref &prop, continue; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref mesh_data = entry; if (mesh_data.is_valid()) { diff --git a/modules/voxelman/SCsub b/modules/voxelman/SCsub index de90dd280..69367bf07 100644 --- a/modules/voxelman/SCsub +++ b/modules/voxelman/SCsub @@ -4,9 +4,6 @@ Import('env') module_env = env.Clone() -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']) diff --git a/modules/voxelman/library/voxel_library_merger.cpp b/modules/voxelman/library/voxel_library_merger.cpp index 7b3cd902c..68b16116a 100644 --- a/modules/voxelman/library/voxel_library_merger.cpp +++ b/modules/voxelman/library/voxel_library_merger.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "../../props/props/prop_data_prop.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -410,6 +410,7 @@ bool VoxelLibraryMerger::process_prop_textures(Ref prop) { bool texture_added = false; +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < prop->get_prop_count(); ++i) { Ref pdm = prop->get_prop(i); @@ -432,6 +433,7 @@ bool VoxelLibraryMerger::process_prop_textures(Ref prop) { texture_added = true; } } +#endif return texture_added; } diff --git a/modules/voxelman/library/voxel_library_merger_pcm.cpp b/modules/voxelman/library/voxel_library_merger_pcm.cpp index a04fa1129..577e441d6 100644 --- a/modules/voxelman/library/voxel_library_merger_pcm.cpp +++ b/modules/voxelman/library/voxel_library_merger_pcm.cpp @@ -33,7 +33,7 @@ SOFTWARE. #include "../../props/props/prop_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif #endif @@ -235,7 +235,7 @@ void VoxelLibraryMergerPCM::_prop_material_cache_get_key(Ref chunk) #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); @@ -330,7 +330,7 @@ void VoxelLibraryMergerPCM::_prop_material_cache_get_key(Ref chunk) #endif */ -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref tex = chunk->mesh_data_resource_get_texture(i); @@ -753,6 +753,7 @@ bool VoxelLibraryMergerPCM::process_prop_textures(Ref prop) { bool texture_added = false; +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < prop->get_prop_count(); ++i) { Ref pdm = prop->get_prop(i); @@ -775,6 +776,7 @@ bool VoxelLibraryMergerPCM::process_prop_textures(Ref prop) { texture_added = true; } } +#endif return texture_added; } diff --git a/modules/voxelman/library/voxel_material_cache.cpp b/modules/voxelman/library/voxel_material_cache.cpp index 1c67ef518..af6175020 100644 --- a/modules/voxelman/library/voxel_material_cache.cpp +++ b/modules/voxelman/library/voxel_material_cache.cpp @@ -30,7 +30,7 @@ SOFTWARE. #include "../../props/props/prop_data.h" #include "../../props/props/prop_data_prop.h" -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif #endif @@ -205,7 +205,7 @@ void VoxelMaterialCache::prop_add_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { @@ -231,7 +231,7 @@ void VoxelMaterialCache::prop_remove_textures(const Ref &prop) { } for (int i = 0; i < prop->get_prop_count(); ++i) { -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref pdm = prop->get_prop(i); if (pdm.is_valid()) { diff --git a/modules/voxelman/meshers/voxel_mesher.cpp b/modules/voxelman/meshers/voxel_mesher.cpp index 9acbd4f36..863cb3a0a 100644 --- a/modules/voxelman/meshers/voxel_mesher.cpp +++ b/modules/voxelman/meshers/voxel_mesher.cpp @@ -29,6 +29,8 @@ SOFTWARE. #include "../world/default/voxel_chunk_default.h" #include "../world/voxel_chunk.h" +#include "modules/modules_enabled.gen.h" + bool VoxelMesher::Vertex::operator==(const Vertex &p_vertex) const { if (vertex != p_vertex.vertex) return false; @@ -429,7 +431,7 @@ void VoxelMesher::add_chunk(Ref chunk) { call("_add_chunk", chunk); } -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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); @@ -981,7 +983,7 @@ void VoxelMesher::_bind_methods() { ClassDB::bind_method(D_METHOD("add_chunk", "chunk"), &VoxelMesher::add_chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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))); ClassDB::bind_method(D_METHOD("add_mesh_data_resource_transform_colored", "mesh", "transform", "colors", "uv_rect"), &VoxelMesher::add_mesh_data_resource_transform_colored, DEFVAL(Rect2(0, 0, 1, 1))); diff --git a/modules/voxelman/meshers/voxel_mesher.h b/modules/voxelman/meshers/voxel_mesher.h index ed4cf2877..a1e3135b6 100644 --- a/modules/voxelman/meshers/voxel_mesher.h +++ b/modules/voxelman/meshers/voxel_mesher.h @@ -37,7 +37,9 @@ SOFTWARE. #include "scene/resources/material.h" #include "scene/resources/mesh.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/mesh_data_resource.h" #endif @@ -123,7 +125,7 @@ public: void add_chunk(Ref chunk); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED 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)); void add_mesh_data_resource_transform_colored(Ref mesh, const Transform transform, const PoolColorArray &colors, const Rect2 uv_rect = Rect2(0, 0, 1, 1)); diff --git a/modules/voxelman/world/jobs/voxel_prop_job.cpp b/modules/voxelman/world/jobs/voxel_prop_job.cpp index f6b4a7051..6d3ab4554 100644 --- a/modules/voxelman/world/jobs/voxel_prop_job.cpp +++ b/modules/voxelman/world/jobs/voxel_prop_job.cpp @@ -35,7 +35,9 @@ SOFTWARE. #include "scene/resources/world_3d.h" #include "servers/physics_server.h" -#ifdef MESH_DATA_RESOURCE_PRESENT +#include "modules/modules_enabled.gen.h" + +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../../mesh_data_resource/mesh_data_resource.h" #endif @@ -86,7 +88,7 @@ void VoxelPropJob::phase_physics_process() { chunk->colliders_clear(); -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < chunk->mesh_data_resource_get_count(); ++i) { Ref mdr = chunk->mesh_data_resource_get(i); @@ -135,7 +137,7 @@ void VoxelPropJob::phase_physics_process() { } void VoxelPropJob::phase_prop() { -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref chunk = _chunk; if (!get_prop_mesher().is_valid()) { @@ -236,7 +238,7 @@ void VoxelPropJob::_execute_phase() { Ref chunk = _chunk; if (!chunk.is_valid() -#ifdef MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED || chunk->mesh_data_resource_get_count() == 0 #endif ) { @@ -303,7 +305,7 @@ void VoxelPropJob::phase_setup() { OS::get_singleton()->delay_usec(100); } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED for (int i = 0; i < _chunk->mesh_data_resource_get_count(); ++i) { Ref tex = _chunk->mesh_data_resource_get_texture(i); diff --git a/modules/voxelman/world/voxel_chunk.cpp b/modules/voxelman/world/voxel_chunk.cpp index e21a90dc7..e5e7ee4f0 100644 --- a/modules/voxelman/world/voxel_chunk.cpp +++ b/modules/voxelman/world/voxel_chunk.cpp @@ -733,7 +733,7 @@ void VoxelChunk::props_clear() { } #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int VoxelChunk::mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture, const Color &color, const bool apply_voxel_scale) { ERR_FAIL_COND_V(!mesh.is_valid(), 0); @@ -1093,7 +1093,7 @@ VoxelChunk::~VoxelChunk() { props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED mesh_data_resource_clear(); #endif @@ -1458,7 +1458,7 @@ void VoxelChunk::_bind_methods() { ClassDB::bind_method(D_METHOD("props_clear"), &VoxelChunk::props_clear); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED ClassDB::bind_method(D_METHOD("mesh_data_resource_addv", "local_data_pos", "mesh", "texture", "color", "apply_voxel_scale"), &VoxelChunk::mesh_data_resource_addv, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); ClassDB::bind_method(D_METHOD("mesh_data_resource_add", "local_transform", "mesh", "texture", "color", "apply_voxel_scale"), &VoxelChunk::mesh_data_resource_add, DEFVAL(Ref()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(true)); diff --git a/modules/voxelman/world/voxel_chunk.h b/modules/voxelman/world/voxel_chunk.h index 2f580595c..0e9dc68b6 100644 --- a/modules/voxelman/world/voxel_chunk.h +++ b/modules/voxelman/world/voxel_chunk.h @@ -233,7 +233,7 @@ public: void props_clear(); #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED int mesh_data_resource_addv(const Vector3 &local_data_pos, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_voxel_scale = true); int mesh_data_resource_add(const Transform &local_transform, const Ref &mesh, const Ref &texture = Ref(), const Color &color = Color(1, 1, 1, 1), const bool apply_voxel_scale = true); @@ -315,7 +315,7 @@ protected: }; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED struct MeshDataResourceEntry { Ref mesh; Ref texture; @@ -397,7 +397,7 @@ protected: Vector _props; #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Vector _mesh_data_resources; #endif diff --git a/modules/voxelman/world/voxel_world.cpp b/modules/voxelman/world/voxel_world.cpp index bdae20a39..7f04daf08 100644 --- a/modules/voxelman/world/voxel_world.cpp +++ b/modules/voxelman/world/voxel_world.cpp @@ -37,7 +37,7 @@ SOFTWARE. #include "../../props/props/prop_data_scene.h" #endif -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED #include "../../mesh_data_resource/props/prop_data_mesh_data.h" #endif @@ -620,7 +620,7 @@ void VoxelWorld::prop_add(Transform tarnsform, const Ref &prop, const continue; } -#if MESH_DATA_RESOURCE_PRESENT +#ifdef MODULE_MESH_DATA_RESOURCE_ENABLED Ref mesh_data = entry; if (mesh_data.is_valid()) {