Update to new module registration
parent
35ddc51f18
commit
35e4b5cd17
|
@ -68,10 +68,11 @@
|
|||
#include "tests/tests.h"
|
||||
#endif
|
||||
|
||||
void register_voxel_types() {
|
||||
void initialize_voxel_module(ModuleInitializationLevel p_level) {
|
||||
using namespace zylann;
|
||||
using namespace voxel;
|
||||
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
VoxelMemoryPool::create_singleton();
|
||||
VoxelStringNames::create_singleton();
|
||||
VoxelGraphNodeDB::create_singleton();
|
||||
|
@ -80,9 +81,11 @@ void register_voxel_types() {
|
|||
|
||||
Engine::get_singleton()->add_singleton(Engine::Singleton("VoxelServer", gd::VoxelServer::get_singleton()));
|
||||
|
||||
VoxelMetadataFactory::get_singleton().add_constructor_by_type<gd::VoxelMetadataVariant>(gd::METADATA_TYPE_VARIANT);
|
||||
VoxelMetadataFactory::get_singleton().add_constructor_by_type<gd::VoxelMetadataVariant>(
|
||||
gd::METADATA_TYPE_VARIANT);
|
||||
|
||||
// TODO Can I prevent users from instancing it? is "register_virtual_class" correct for a class that's not abstract?
|
||||
// TODO Can I prevent users from instancing it? is "register_virtual_class" correct for a class that's not
|
||||
// abstract?
|
||||
ClassDB::register_class<gd::VoxelServer>();
|
||||
|
||||
// Misc
|
||||
|
@ -169,19 +172,6 @@ void register_voxel_types() {
|
|||
ZN_PRINT_VERBOSE(format("Size of VoxelInstancer: {}", sizeof(VoxelInstancer)));
|
||||
ZN_PRINT_VERBOSE(format("Size of VoxelDataMap: {}", sizeof(VoxelDataMap)));
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
EditorPlugins::add_by_type<VoxelGraphEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelTerrainEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelInstanceLibraryEditorPlugin>();
|
||||
EditorPlugins::add_by_type<ZN_FastNoiseLiteEditorPlugin>();
|
||||
EditorPlugins::add_by_type<magica::VoxEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelInstancerEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelMeshSDFEditorPlugin>();
|
||||
#ifdef VOXEL_ENABLE_FAST_NOISE_2
|
||||
EditorPlugins::add_by_type<FastNoise2EditorPlugin>();
|
||||
#endif
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
#ifdef VOXEL_RUN_TESTS
|
||||
zylann::voxel::tests::run_voxel_tests();
|
||||
#endif
|
||||
|
@ -195,10 +185,27 @@ void register_voxel_types() {
|
|||
//ClassDB::add_compatibility_class("VoxelInstanceLibraryItemBase", "VoxelInstanceLibraryItem");
|
||||
}
|
||||
|
||||
void unregister_voxel_types() {
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
EditorPlugins::add_by_type<VoxelGraphEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelTerrainEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelInstanceLibraryEditorPlugin>();
|
||||
EditorPlugins::add_by_type<ZN_FastNoiseLiteEditorPlugin>();
|
||||
EditorPlugins::add_by_type<magica::VoxEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelInstancerEditorPlugin>();
|
||||
EditorPlugins::add_by_type<VoxelMeshSDFEditorPlugin>();
|
||||
#ifdef VOXEL_ENABLE_FAST_NOISE_2
|
||||
EditorPlugins::add_by_type<FastNoise2EditorPlugin>();
|
||||
#endif
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
}
|
||||
|
||||
void uninitialize_voxel_module(ModuleInitializationLevel p_level) {
|
||||
using namespace zylann;
|
||||
using namespace voxel;
|
||||
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_SCENE) {
|
||||
// At this point, the GDScript module has nullified GDScriptLanguage::singleton!!
|
||||
// That means it's impossible to free scripts still referenced by VoxelServer. And that can happen, because
|
||||
// users can write custom generators, which run inside threads, and these threads are hosted in the server...
|
||||
|
@ -218,11 +225,14 @@ void unregister_voxel_types() {
|
|||
}
|
||||
VoxelMemoryPool::destroy_singleton();
|
||||
// TODO No remove?
|
||||
}
|
||||
|
||||
#ifdef TOOLS_ENABLED
|
||||
if (p_level == MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
zylann::free_debug_resources();
|
||||
|
||||
// TODO Seriously, no remove?
|
||||
//EditorPlugins::remove_by_type<VoxelGraphEditorPlugin>();
|
||||
#endif
|
||||
}
|
||||
#endif // TOOLS_ENABLED
|
||||
}
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
void register_voxel_types();
|
||||
void unregister_voxel_types();
|
||||
#include "modules/register_module_types.h"
|
||||
|
||||
void initialize_voxel_module(ModuleInitializationLevel p_level);
|
||||
void uninitialize_voxel_module(ModuleInitializationLevel p_level);
|
||||
|
|
Loading…
Reference in New Issue