Replaced PROPS_2D_PRESENT define for the module system's equivalent.

This commit is contained in:
Relintai 2022-10-05 13:20:42 +02:00
parent 2fdaacfa66
commit 50e1108e18
21 changed files with 57 additions and 63 deletions

View File

@ -4,9 +4,6 @@ Import('env')
module_env = env.Clone()
if env["module_props_2d_enabled"]:
module_env.Append(CPPDEFINES=['PROPS_2D_PRESENT'])
if env["module_mesh_utils_enabled"]:
module_env.Append(CPPDEFINES=['MESH_UTILS_PRESENT'])

View File

@ -24,7 +24,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../nodes/mesh_data_instance.h"
#include "scene/resources/material.h"

View File

@ -24,7 +24,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data_entry.h"
#include "core/math/vector3.h"

View File

@ -44,7 +44,7 @@ SOFTWARE.
#include "props/prop_data_mesh_data.h"
#endif
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../props_2d/singleton/prop_2d_utils.h"
#include "props_2d/prop_2d_data_mesh_data.h"
#endif
@ -62,7 +62,7 @@ void register_mesh_data_resource_types() {
PropUtils::add_processor(processor);
#endif
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::register_class<Prop2DDataMeshData>();
Ref<Prop2DDataMeshData> prop_2d_processor = Ref<Prop2DDataMeshData>(memnew(Prop2DDataMeshData));
Prop2DUtils::add_processor(prop_2d_processor);

View File

@ -31,9 +31,6 @@ SOFTWARE.
#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
#include "../../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif

View File

@ -7,9 +7,6 @@
#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
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif

View File

@ -24,9 +24,6 @@
#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
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif

View File

@ -45,9 +45,6 @@ SOFTWARE.
#endif
#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
#include "../mesh_data_resource/props_2d/prop_2d_data_mesh_data.h"
#endif

View File

@ -4,9 +4,6 @@ Import('env')
module_env = env.Clone()
if os.path.isdir('../props_2d'):
module_env.Append(CPPDEFINES=['PROPS_2D_PRESENT'])
if os.path.isdir('../mesh_utils'):
module_env.Append(CPPDEFINES=['MESH_UTILS_PRESENT'])

View File

@ -26,7 +26,9 @@ SOFTWARE.
#include "terrain_2d_material_cache.h"
#ifdef PROPS_2D_PRESENT
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#endif
@ -194,7 +196,7 @@ int Terrain2DLibrary::scene_get_num() const {
void Terrain2DLibrary::scenes_clear() {
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Ref<Prop2DData> Terrain2DLibrary::prop_get(const int id) {
return Ref<Prop2DData>();
}
@ -322,7 +324,7 @@ void Terrain2DLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("scene_get_num"), &Terrain2DLibrary::scene_get_num);
ClassDB::bind_method(D_METHOD("scenes_clear"), &Terrain2DLibrary::scenes_clear);
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("prop_get", "id"), &Terrain2DLibrary::prop_get);
ClassDB::bind_method(D_METHOD("prop_add", "value"), &Terrain2DLibrary::prop_add);
ClassDB::bind_method(D_METHOD("prop_has", "prop"), &Terrain2DLibrary::prop_has);

View File

@ -32,12 +32,14 @@ SOFTWARE.
#include "../defines.h"
#include "modules/modules_enabled.gen.h"
class Terrain2DMaterialCache;
class Terrain2DSurface;
class Terrain2DMesher;
class PackedScene;
class Terrain2DChunk;
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
class Prop2DData;
#endif
@ -111,7 +113,7 @@ public:
virtual int scene_get_num() const;
virtual void scenes_clear();
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
virtual Ref<Prop2DData> prop_get(const int id);
virtual void prop_add(Ref<Prop2DData> value);
virtual bool prop_has(const Ref<Prop2DData> &value) const;

View File

@ -27,7 +27,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#include "../../props_2d/props/prop_2d_data_prop.h"
@ -153,7 +153,7 @@ void Terrain2DLibraryMerger::set_terra_surfaces(const Vector<Variant> &surfaces)
}
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Ref<Prop2DData> Terrain2DLibraryMerger::get_prop(const int index) {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<Prop2DData>());
@ -263,7 +263,7 @@ void Terrain2DLibraryMerger::refresh_rects() {
setup_material_albedo(MATERIAL_INDEX_LIQUID, tex);
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
//todo add this back
//texture_added = false;
for (int i = 0; i < _props.size(); i++) {
@ -356,7 +356,7 @@ Terrain2DLibraryMerger::~Terrain2DLibraryMerger() {
_prop_packer.unref();
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
bool Terrain2DLibraryMerger::process_prop_textures(Ref<Prop2DData> prop) {
if (!prop.is_valid()) {
return false;
@ -418,7 +418,7 @@ void Terrain2DLibraryMerger::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_terra_surfaces"), &Terrain2DLibraryMerger::set_terra_surfaces);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_surfaces", PROPERTY_HINT_NONE, "23/19:Terrain2DSurfaceMerger", PROPERTY_USAGE_DEFAULT, "Terrain2DSurfaceMerger"), "set_terra_surfaces", "get_terra_surfaces");
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("get_props"), &Terrain2DLibraryMerger::get_props);
ClassDB::bind_method(D_METHOD("set_props"), &Terrain2DLibraryMerger::set_props);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "23/19:Prop2DData", PROPERTY_USAGE_DEFAULT, "Prop2DData"), "set_props", "get_props");

View File

@ -32,6 +32,8 @@ SOFTWARE.
#include "../data/terrain_2d_light.h"
#include "terrain_2d_surface_merger.h"
#include "modules/modules_enabled.gen.h"
class Terrain2DSurfaceSimple;
class Terrain2DMesher;
class PackedScene;
@ -65,7 +67,7 @@ public:
Vector<Variant> get_terra_surfaces();
void set_terra_surfaces(const Vector<Variant> &surfaces);
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Ref<Prop2DData> get_prop(const int index);
void add_prop(Ref<Prop2DData> value);
bool has_prop(const Ref<Prop2DData> &value) const;
@ -90,14 +92,14 @@ public:
~Terrain2DLibraryMerger();
protected:
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
bool process_prop_textures(Ref<Prop2DData> prop);
#endif
static void _bind_methods();
Vector<Ref<Terrain2DSurfaceMerger>> _terra_surfaces;
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Vector<Ref<Prop2DData>> _props;
#endif

View File

@ -28,7 +28,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#include "../../props_2d/props/prop_2d_data_prop.h"
@ -237,7 +237,7 @@ void Terrain2DLibraryMergerPCM::_prop_material_cache_get_key(Ref<Terrain2DChunk>
Vector<uint64_t> props;
/*
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
for (int i = 0; i < chunk->prop_get_count(); ++i) {
Ref<Prop2DData> prop = chunk->prop_get(i);
@ -340,7 +340,7 @@ void Terrain2DLibraryMergerPCM::_prop_material_cache_get_key(Ref<Terrain2DChunk>
}
/*
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
for (int i = 0; i < chunk->prop_get_count(); ++i) {
Ref<Prop2DData> prop = chunk->prop_get(i);
@ -528,7 +528,7 @@ void Terrain2DLibraryMergerPCM::set_terra_surfaces(const Vector<Variant> &surfac
}
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Ref<Prop2DData> Terrain2DLibraryMergerPCM::get_prop(const int index) {
ERR_FAIL_INDEX_V(index, _props.size(), Ref<Prop2DData>());
@ -639,7 +639,7 @@ void Terrain2DLibraryMergerPCM::refresh_rects() {
setup_material_albedo(MATERIAL_INDEX_LIQUID, tex);
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
//todo add this back
//texture_added = false;
for (int i = 0; i < _props.size(); i++) {
@ -731,7 +731,7 @@ Terrain2DLibraryMergerPCM::~Terrain2DLibraryMergerPCM() {
_prop_packer.unref();
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
bool Terrain2DLibraryMergerPCM::process_prop_textures(Ref<Prop2DData> prop) {
/*
if (!prop.is_valid()) {
@ -794,7 +794,7 @@ void Terrain2DLibraryMergerPCM::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_terra_surfaces"), &Terrain2DLibraryMergerPCM::set_terra_surfaces);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "terra_surfaces", PROPERTY_HINT_NONE, "23/19:Terrain2DSurfaceMerger", PROPERTY_USAGE_DEFAULT, "Terrain2DSurfaceMerger"), "set_terra_surfaces", "get_terra_surfaces");
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("get_props"), &Terrain2DLibraryMergerPCM::get_props);
ClassDB::bind_method(D_METHOD("set_props"), &Terrain2DLibraryMergerPCM::set_props);
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "props", PROPERTY_HINT_NONE, "23/19:Prop2DData", PROPERTY_USAGE_DEFAULT, "Prop2DData"), "set_props", "get_props");

View File

@ -34,6 +34,8 @@ SOFTWARE.
#include "core/os/mutex.h"
#include "modules/modules_enabled.gen.h"
class Terrain2DSurfaceSimple;
class Terrain2DMesher;
class PackedScene;
@ -80,7 +82,7 @@ public:
Vector<Variant> get_terra_surfaces();
void set_terra_surfaces(const Vector<Variant> &surfaces);
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Ref<Prop2DData> get_prop(const int index);
void add_prop(Ref<Prop2DData> value);
bool has_prop(const Ref<Prop2DData> &value) const;
@ -105,7 +107,7 @@ public:
~Terrain2DLibraryMergerPCM();
protected:
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
bool process_prop_textures(Ref<Prop2DData> prop);
#endif
@ -115,7 +117,7 @@ protected:
Map<int, Ref<Terrain2DMaterialCachePCM>> _prop_material_cache;
Vector<Ref<Terrain2DSurfaceMerger>> _terra_surfaces;
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Vector<Ref<Prop2DData>> _props;
#endif

View File

@ -26,7 +26,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#include "../../props_2d/props/prop_2d_data_prop.h"
@ -161,7 +161,7 @@ Ref<Texture> Terrain2DMaterialCache::texture_get_merged() {
return Ref<Texture>();
}
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void Terrain2DMaterialCache::prop_add_textures(const Ref<Prop2DData> &prop) {
if (!prop.is_valid()) {
return;
@ -275,7 +275,7 @@ void Terrain2DMaterialCache::_bind_methods() {
ClassDB::bind_method(D_METHOD("texture_get_merged"), &Terrain2DMaterialCache::texture_get_merged);
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("prop_add_textures", "prop"), &Terrain2DMaterialCache::prop_add_textures);
ClassDB::bind_method(D_METHOD("prop_remove_textures", "prop"), &Terrain2DMaterialCache::prop_remove_textures);
#endif

View File

@ -33,6 +33,8 @@ SOFTWARE.
#include "../defines.h"
#include "modules/modules_enabled.gen.h"
class Terrain2DLibrary;
class Terrain2DMaterialCache : public Resource {
@ -74,7 +76,7 @@ public:
//Also do it for props
virtual Ref<Texture> texture_get_merged();
#ifdef PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void prop_add_textures(const Ref<Prop2DData> &prop);
void prop_remove_textures(const Ref<Prop2DData> &prop);
#endif

View File

@ -739,7 +739,7 @@ void Terrain2DChunk::clear_baked_lights() {
call("_clear_baked_lights");
}
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void Terrain2DChunk::prop_add(const Transform2D &tarnsform, const Ref<Prop2DData> &prop) {
ERR_FAIL_COND(!prop.is_valid());
@ -798,7 +798,7 @@ int Terrain2DChunk::mesh_data_resource_addv(const Vector2 &local_data_pos, const
AABB mesh_aabb = e.transform.xform(mesh->get_aabb());
e.is_inside = aabb.encloses(mesh_aabb);
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
if (get_library().is_valid() && texture.is_valid()) {
e.uv_rect = get_library()->get_prop_uv_rect(texture);
} else {
@ -845,7 +845,7 @@ int Terrain2DChunk::mesh_data_resource_add(const Transform2D &local_transform, c
AABB mesh_aabb = e.transform.xform(mesh->get_aabb());
e.is_inside = aabb.encloses(mesh_aabb);
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
if (get_library().is_valid() && texture.is_valid())
e.uv_rect = get_library()->get_prop_uv_rect(texture);
else
@ -1171,7 +1171,7 @@ Terrain2DChunk::~Terrain2DChunk() {
_library.unref();
}
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
props_clear();
#endif
@ -1584,7 +1584,7 @@ void Terrain2DChunk::_bind_methods() {
//Meshes
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("prop_add", "prop"), &Terrain2DChunk::prop_add);
ClassDB::bind_method(D_METHOD("prop_get", "index"), &Terrain2DChunk::prop_get);
ClassDB::bind_method(D_METHOD("prop_get_count"), &Terrain2DChunk::prop_get_count);

View File

@ -45,7 +45,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#endif
@ -260,7 +260,7 @@ public:
void bake_light(Ref<Terrain2DLight> light);
void clear_baked_lights();
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void prop_add(const Transform2D &tarnsform, const Ref<Prop2DData> &prop);
Ref<Prop2DData> prop_get(const int index);
Transform2D prop_get_tarnsform(const int index);
@ -359,7 +359,7 @@ protected:
virtual void _generation_physics_process(const float delta);
protected:
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
struct Prop2DDataStore {
Transform2D transform;
Ref<Prop2DData> prop;
@ -440,7 +440,7 @@ protected:
Vector<Ref<Terrain2DStructure>> _voxel_structures;
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
Vector<Prop2DDataStore> _props;
#endif

View File

@ -30,7 +30,7 @@ SOFTWARE.
#include "modules/modules_enabled.gen.h"
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#include "../../props_2d/props/prop_2d_data_entry.h"
#include "../../props_2d/props/prop_2d_data_light.h"
@ -634,7 +634,7 @@ int Terrain2DWorld::generation_get_size() const {
return _generating.size();
}
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void Terrain2DWorld::prop_add(Transform transform, const Ref<Prop2DData> &prop, const bool apply_voxel_scale) {
//TODO
/*
@ -1286,7 +1286,7 @@ void Terrain2DWorld::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_position_walkable", "position"), &Terrain2DWorld::is_position_walkable);
ClassDB::bind_method(D_METHOD("on_chunk_mesh_generation_finished", "chunk"), &Terrain2DWorld::on_chunk_mesh_generation_finished);
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
ClassDB::bind_method(D_METHOD("prop_add", "transform", "prop", "apply_voxel_scale"), &Terrain2DWorld::prop_add, DEFVAL(true));
#endif

View File

@ -35,7 +35,9 @@ SOFTWARE.
#include "core/os/os.h"
#if PROPS_2D_PRESENT
#include "modules/modules_enabled.gen.h"
#ifdef MODULE_PROPS_2D_ENABLED
#include "../../props_2d/props/prop_2d_data.h"
#endif
@ -176,7 +178,7 @@ public:
void generation_remove_index(const int index);
int generation_get_size() const;
#if PROPS_2D_PRESENT
#ifdef MODULE_PROPS_2D_ENABLED
void prop_add(Transform transform, const Ref<Prop2DData> &prop, const bool apply_scale = true);
#endif