2016-05-01 06:00:02 -07:00
|
|
|
#include "register_types.h"
|
2020-01-26 12:29:44 -08:00
|
|
|
#include "edition/voxel_tool.h"
|
2021-01-17 14:18:41 -08:00
|
|
|
#include "edition/voxel_tool_buffer.h"
|
2021-02-20 19:06:40 -08:00
|
|
|
#include "edition/voxel_tool_lod_terrain.h"
|
2020-07-28 12:32:33 -07:00
|
|
|
#include "edition/voxel_tool_terrain.h"
|
2020-03-01 10:12:16 -08:00
|
|
|
#include "editor/editor_plugin.h"
|
2021-01-01 16:59:12 -08:00
|
|
|
#include "editor/fast_noise_lite/fast_noise_lite_editor_plugin.h"
|
2020-07-30 10:50:45 -07:00
|
|
|
#include "editor/graph/voxel_graph_editor_plugin.h"
|
2021-02-14 13:55:31 -08:00
|
|
|
#include "editor/instance_library/voxel_instance_library_editor_plugin.h"
|
2020-08-14 12:33:09 -07:00
|
|
|
#include "editor/terrain/voxel_terrain_editor_plugin.h"
|
2020-02-19 11:26:14 -08:00
|
|
|
#include "generators/graph/voxel_generator_graph.h"
|
2020-02-23 11:08:14 -08:00
|
|
|
#include "generators/graph/voxel_graph_node_db.h"
|
2020-12-18 13:19:02 -08:00
|
|
|
#include "generators/simple/voxel_generator_flat.h"
|
|
|
|
#include "generators/simple/voxel_generator_heightmap.h"
|
|
|
|
#include "generators/simple/voxel_generator_image.h"
|
|
|
|
#include "generators/simple/voxel_generator_noise.h"
|
|
|
|
#include "generators/simple/voxel_generator_noise_2d.h"
|
|
|
|
#include "generators/simple/voxel_generator_waves.h"
|
2020-10-31 15:11:25 -07:00
|
|
|
#include "generators/voxel_generator_script.h"
|
2020-01-26 16:04:13 -08:00
|
|
|
#include "meshers/blocky/voxel_library.h"
|
2019-04-28 09:58:29 -07:00
|
|
|
#include "meshers/blocky/voxel_mesher_blocky.h"
|
2020-09-10 16:36:23 -07:00
|
|
|
#include "meshers/cubes/voxel_mesher_cubes.h"
|
2019-04-28 09:58:29 -07:00
|
|
|
#include "meshers/dmc/voxel_mesher_dmc.h"
|
|
|
|
#include "meshers/transvoxel/voxel_mesher_transvoxel.h"
|
2020-09-14 11:33:02 -07:00
|
|
|
#include "storage/voxel_buffer.h"
|
|
|
|
#include "storage/voxel_memory_pool.h"
|
2021-01-31 08:51:42 -08:00
|
|
|
#include "streams/region/voxel_stream_region_files.h"
|
2021-01-28 14:02:49 -08:00
|
|
|
#include "streams/sqlite/voxel_stream_sqlite.h"
|
2020-09-12 13:10:05 -07:00
|
|
|
#include "streams/vox_loader.h"
|
2019-08-23 17:44:27 -07:00
|
|
|
#include "streams/voxel_stream_block_files.h"
|
2020-10-31 15:11:25 -07:00
|
|
|
#include "streams/voxel_stream_script.h"
|
2021-02-07 13:40:55 -08:00
|
|
|
#include "terrain/instancing/voxel_instancer.h"
|
2019-04-28 09:58:29 -07:00
|
|
|
#include "terrain/voxel_box_mover.h"
|
2019-05-03 16:02:10 -07:00
|
|
|
#include "terrain/voxel_lod_terrain.h"
|
2021-04-15 12:25:55 -07:00
|
|
|
#include "terrain/voxel_mesh_block.h"
|
2019-04-28 09:58:29 -07:00
|
|
|
#include "terrain/voxel_terrain.h"
|
2020-09-06 11:01:12 -07:00
|
|
|
#include "terrain/voxel_viewer.h"
|
2020-08-31 13:51:30 -07:00
|
|
|
#include "util/macros.h"
|
2021-02-20 19:02:32 -08:00
|
|
|
#ifdef VOXEL_FAST_NOISE_2_SUPPORT
|
|
|
|
#include "util/noise/fast_noise_2.h"
|
|
|
|
#endif
|
2021-02-21 15:58:00 -08:00
|
|
|
#include "constants/voxel_string_names.h"
|
2021-01-01 16:59:12 -08:00
|
|
|
#include "util/noise/fast_noise_lite.h"
|
|
|
|
#include "util/noise/fast_noise_lite_gradient.h"
|
|
|
|
|
2020-08-31 13:51:30 -07:00
|
|
|
#include <core/engine.h>
|
2016-05-01 06:00:02 -07:00
|
|
|
|
2020-10-23 16:08:14 -07:00
|
|
|
#ifdef TOOLS_ENABLED
|
|
|
|
#include "editor/voxel_debug.h"
|
|
|
|
#endif
|
|
|
|
|
2021-04-03 12:40:35 -07:00
|
|
|
#ifdef VOXEL_RUN_TESTS
|
|
|
|
#include "tests/tests.h"
|
|
|
|
#endif
|
|
|
|
|
2016-05-01 06:00:02 -07:00
|
|
|
void register_voxel_types() {
|
2020-08-10 12:57:03 -07:00
|
|
|
VoxelMemoryPool::create_singleton();
|
|
|
|
VoxelStringNames::create_singleton();
|
|
|
|
VoxelGraphNodeDB::create_singleton();
|
2020-08-25 15:00:38 -07:00
|
|
|
VoxelServer::create_singleton();
|
2020-08-10 12:57:03 -07:00
|
|
|
|
2020-08-26 13:17:57 -07:00
|
|
|
Engine::get_singleton()->add_singleton(Engine::Singleton("VoxelServer", VoxelServer::get_singleton()));
|
|
|
|
|
|
|
|
// TODO Can I prevent users from instancing it? is "register_virtual_class" correct for a class that's not abstract?
|
|
|
|
ClassDB::register_class<VoxelServer>();
|
|
|
|
|
2021-02-14 13:55:31 -08:00
|
|
|
// Misc
|
2020-09-12 18:17:11 -07:00
|
|
|
ClassDB::register_class<Voxel>();
|
|
|
|
ClassDB::register_class<VoxelLibrary>();
|
|
|
|
ClassDB::register_class<VoxelColorPalette>();
|
2021-02-14 13:55:31 -08:00
|
|
|
ClassDB::register_class<VoxelInstanceLibrary>();
|
|
|
|
ClassDB::register_class<VoxelInstanceLibraryItem>();
|
2020-09-12 18:17:11 -07:00
|
|
|
|
2019-04-28 09:58:29 -07:00
|
|
|
// Storage
|
2017-03-24 17:23:36 -07:00
|
|
|
ClassDB::register_class<VoxelBuffer>();
|
2019-04-28 09:58:29 -07:00
|
|
|
|
|
|
|
// Nodes
|
2020-12-18 14:58:41 -08:00
|
|
|
ClassDB::register_virtual_class<VoxelNode>();
|
2017-03-24 17:23:36 -07:00
|
|
|
ClassDB::register_class<VoxelTerrain>();
|
2019-05-03 16:02:10 -07:00
|
|
|
ClassDB::register_class<VoxelLodTerrain>();
|
2020-09-06 11:01:12 -07:00
|
|
|
ClassDB::register_class<VoxelViewer>();
|
2021-02-07 13:30:07 -08:00
|
|
|
ClassDB::register_class<VoxelInstanceGenerator>();
|
2021-02-14 13:55:31 -08:00
|
|
|
ClassDB::register_class<VoxelInstancer>();
|
2019-04-28 09:58:29 -07:00
|
|
|
|
2019-05-27 16:40:09 -07:00
|
|
|
// Streams
|
2020-12-18 14:58:41 -08:00
|
|
|
ClassDB::register_virtual_class<VoxelStream>();
|
2019-08-17 11:43:08 -07:00
|
|
|
ClassDB::register_class<VoxelStreamBlockFiles>();
|
2019-08-17 11:56:21 -07:00
|
|
|
ClassDB::register_class<VoxelStreamRegionFiles>();
|
2020-10-31 15:11:25 -07:00
|
|
|
ClassDB::register_class<VoxelStreamScript>();
|
2021-01-28 14:02:49 -08:00
|
|
|
ClassDB::register_class<VoxelStreamSQLite>();
|
2019-04-28 09:58:29 -07:00
|
|
|
|
2020-01-26 14:34:26 -08:00
|
|
|
// Generators
|
2020-12-18 14:58:41 -08:00
|
|
|
ClassDB::register_virtual_class<VoxelGenerator>();
|
2020-02-17 14:05:16 -08:00
|
|
|
ClassDB::register_class<VoxelGeneratorFlat>();
|
|
|
|
ClassDB::register_class<VoxelGeneratorWaves>();
|
2020-01-26 14:34:26 -08:00
|
|
|
ClassDB::register_class<VoxelGeneratorHeightmap>();
|
|
|
|
ClassDB::register_class<VoxelGeneratorImage>();
|
|
|
|
ClassDB::register_class<VoxelGeneratorNoise2D>();
|
|
|
|
ClassDB::register_class<VoxelGeneratorNoise>();
|
2020-02-19 11:26:14 -08:00
|
|
|
ClassDB::register_class<VoxelGeneratorGraph>();
|
2020-10-31 15:11:25 -07:00
|
|
|
ClassDB::register_class<VoxelGeneratorScript>();
|
2020-01-26 14:34:26 -08:00
|
|
|
|
2020-09-12 18:17:11 -07:00
|
|
|
// Utilities
|
2018-09-30 16:11:33 -07:00
|
|
|
ClassDB::register_class<VoxelBoxMover>();
|
2019-09-24 10:48:30 -07:00
|
|
|
ClassDB::register_class<VoxelRaycastResult>();
|
2019-09-03 14:54:40 -07:00
|
|
|
ClassDB::register_class<VoxelTool>();
|
2020-07-28 12:32:33 -07:00
|
|
|
ClassDB::register_class<VoxelToolTerrain>();
|
2021-02-20 19:06:40 -08:00
|
|
|
ClassDB::register_class<VoxelToolLodTerrain>();
|
2021-01-17 14:18:41 -08:00
|
|
|
// I had to bind this one despite it being useless as-is because otherwise Godot lazily initializes its class.
|
|
|
|
// And this can happen in a thread, causing crashes due to the concurrent access
|
|
|
|
ClassDB::register_class<VoxelToolBuffer>();
|
2020-07-25 13:56:23 -07:00
|
|
|
ClassDB::register_class<VoxelBlockSerializer>();
|
2020-09-12 13:10:05 -07:00
|
|
|
ClassDB::register_class<VoxelVoxLoader>();
|
2021-01-01 16:59:12 -08:00
|
|
|
ClassDB::register_class<FastNoiseLite>();
|
|
|
|
ClassDB::register_class<FastNoiseLiteGradient>();
|
2021-02-20 19:02:32 -08:00
|
|
|
// See SCsub
|
|
|
|
#ifdef VOXEL_FAST_NOISE_2_SUPPORT
|
|
|
|
ClassDB::register_class<FastNoise2>();
|
|
|
|
#endif
|
2019-04-28 09:58:29 -07:00
|
|
|
|
|
|
|
// Meshers
|
2020-12-18 14:58:41 -08:00
|
|
|
ClassDB::register_virtual_class<VoxelMesher>();
|
2019-04-28 09:58:29 -07:00
|
|
|
ClassDB::register_class<VoxelMesherBlocky>();
|
|
|
|
ClassDB::register_class<VoxelMesherTransvoxel>();
|
|
|
|
ClassDB::register_class<VoxelMesherDMC>();
|
2020-09-10 16:36:23 -07:00
|
|
|
ClassDB::register_class<VoxelMesherCubes>();
|
2019-08-29 14:55:02 -07:00
|
|
|
|
2020-02-22 14:45:22 -08:00
|
|
|
// Reminder: how to create a singleton accessible from scripts:
|
|
|
|
// Engine::get_singleton()->add_singleton(Engine::Singleton("SingletonName",singleton_instance));
|
|
|
|
|
2020-08-29 14:09:54 -07:00
|
|
|
PRINT_VERBOSE(String("Size of VoxelBuffer: {0}").format(varray((int)sizeof(VoxelBuffer))));
|
2021-04-15 12:25:55 -07:00
|
|
|
PRINT_VERBOSE(String("Size of VoxelMeshBlock: {0}").format(varray((int)sizeof(VoxelMeshBlock))));
|
2021-02-18 11:50:47 -08:00
|
|
|
PRINT_VERBOSE(String("Size of VoxelTerrain: {0}").format(varray((int)sizeof(VoxelTerrain))));
|
|
|
|
PRINT_VERBOSE(String("Size of VoxelLodTerrain: {0}").format(varray((int)sizeof(VoxelLodTerrain))));
|
|
|
|
PRINT_VERBOSE(String("Size of VoxelInstancer: {0}").format(varray((int)sizeof(VoxelInstancer))));
|
2020-08-29 14:09:54 -07:00
|
|
|
|
2019-08-29 14:55:02 -07:00
|
|
|
#ifdef TOOLS_ENABLED
|
2020-03-01 10:12:16 -08:00
|
|
|
EditorPlugins::add_by_type<VoxelGraphEditorPlugin>();
|
2020-08-14 12:33:09 -07:00
|
|
|
EditorPlugins::add_by_type<VoxelTerrainEditorPlugin>();
|
2021-02-14 13:55:31 -08:00
|
|
|
EditorPlugins::add_by_type<VoxelInstanceLibraryEditorPlugin>();
|
2021-01-01 16:59:12 -08:00
|
|
|
EditorPlugins::add_by_type<FastNoiseLiteEditorPlugin>();
|
2019-08-29 14:55:02 -07:00
|
|
|
#endif
|
2021-04-03 12:40:35 -07:00
|
|
|
|
|
|
|
#ifdef VOXEL_RUN_TESTS
|
|
|
|
run_voxel_tests();
|
|
|
|
#endif
|
2016-05-01 06:00:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void unregister_voxel_types() {
|
2020-08-29 14:55:52 -07:00
|
|
|
// At this point, the GDScript module has nullified GDScriptLanguage::singleton!!
|
2020-08-29 14:09:54 -07:00
|
|
|
// 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...
|
2020-08-29 14:55:52 -07:00
|
|
|
// See https://github.com/Zylann/godot_voxel/issues/189
|
2020-08-29 14:09:54 -07:00
|
|
|
|
2020-08-25 15:00:38 -07:00
|
|
|
VoxelStringNames::destroy_singleton();
|
|
|
|
VoxelGraphNodeDB::destroy_singleton();
|
|
|
|
VoxelServer::destroy_singleton();
|
|
|
|
|
|
|
|
// Do this last as VoxelServer might still be holding some refs to voxel blocks
|
2020-01-25 17:59:53 -08:00
|
|
|
unsigned int used_blocks = VoxelMemoryPool::get_singleton()->debug_get_used_blocks();
|
|
|
|
if (used_blocks > 0) {
|
2020-08-25 15:00:38 -07:00
|
|
|
ERR_PRINT(String("VoxelMemoryPool: "
|
|
|
|
"{0} memory blocks are still used when unregistering the module. Recycling leak?")
|
|
|
|
.format(varray(used_blocks)));
|
2020-01-25 17:59:53 -08:00
|
|
|
}
|
2020-02-19 13:59:41 -08:00
|
|
|
VoxelMemoryPool::destroy_singleton();
|
2020-08-26 13:17:57 -07:00
|
|
|
// TODO No remove?
|
2020-02-19 11:26:14 -08:00
|
|
|
|
2019-08-29 14:55:02 -07:00
|
|
|
#ifdef TOOLS_ENABLED
|
2020-10-23 16:08:14 -07:00
|
|
|
VoxelDebug::free_resources();
|
2020-03-01 10:12:16 -08:00
|
|
|
|
2020-08-26 13:17:57 -07:00
|
|
|
// TODO Seriously, no remove?
|
2020-03-01 10:12:16 -08:00
|
|
|
//EditorPlugins::remove_by_type<VoxelGraphEditorPlugin>();
|
2019-08-29 14:55:02 -07:00
|
|
|
#endif
|
2016-05-01 06:00:02 -07:00
|
|
|
}
|