Skip to content

Commit

Permalink
Use server level module initialization to tell Godot to restart after…
Browse files Browse the repository at this point in the history
… detecting the plugin
  • Loading branch information
TokisanGames committed Aug 28, 2023
1 parent b66e2c6 commit dc007d4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ See the [Wiki](https://github.com/outobugi/Terrain3D/wiki) for more details on p
### Run the demo
1. Download the [latest release](https://github.com/outobugi/Terrain3D/releases) and extract the files, or [build the plugin from source](https://github.com/outobugi/Terrain3D/wiki/Building-From-Source).
2. Run Godot, using the console executable so you can see error messages.
3. Import the project folder and open it. Let it complain about importing errors and likely crash. Then restart Godot.
4. If the demo scene doesn't open automatically, open `demo/Demo.tscn`. You should see a terrain. Run it. If you don't see terrain, look at the console for errors, and in `Project Settings / Plugins` to ensure that Terrain3D is enabled.
3. Import the demo project and open it. Allow Godot to restart.
4. In `Project Settings / Plugins`, ensure that Terrain3D is enabled.
5. Select `Project / Reload Current Project` to restart once more.
6. If the demo scene doesn't open automatically, open `demo/Demo.tscn`. You should see a terrain. Run it.

### Install Terrain3D in your own project
1. Copy `addons/terrain_3d` to your project folder in `addons/terrain_3d`.
2. Open Godot and go through the first load process & crash. Restart if needed.
2. Open Godot, restart when it prompts.
3. In `Project Settings / Plugins`, ensure that Terrain3D is enabled.
4. Create or open a scene and add a new Terrain3D node.
5. Select Terrain3D in the scene tree. In the inspector, create a new Terrain3DStorage resource.
6. Click the down arrow to the right of the storage resource and save it as a binary .res file. This is optional, but highly recommended. Otherwise it will save terrain data as text in the current scene file.
7. Read the wiki to learn how to properly [set up your textures](https://github.com/outobugi/Terrain3D/wiki/Setting-Up-Textures), [import data](https://github.com/outobugi/Terrain3D/wiki/Importing-&-Exporting-Data) and [more](https://github.com/outobugi/Terrain3D/wiki) .
4. Select `Project / Reload Current Project` to restart once more.
5. Create or open a 3D scene and add a new Terrain3D node.
6. Select Terrain3D in the scene tree. In the inspector, click the down arrow to the right of the storage resource and save it as a binary .res file. This is optional, but highly recommended. Otherwise it will save terrain data as text in the current scene file.
7. Read the wiki to learn how to properly [set up your textures](https://github.com/outobugi/Terrain3D/wiki/Setting-Up-Textures), [import data](https://github.com/outobugi/Terrain3D/wiki/Importing-&-Exporting-Data) and [more](https://github.com/outobugi/Terrain3D/wiki).

## Getting Support

Expand Down
15 changes: 9 additions & 6 deletions src/register_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

using namespace godot;

void initialize_terrain_types(ModuleInitializationLevel p_level) {
void initialize_terrain_3d(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
Expand All @@ -21,20 +21,23 @@ void initialize_terrain_types(ModuleInitializationLevel p_level) {
ClassDB::register_class<Terrain3DEditor>();
}

void uninitialize_terrain_types(ModuleInitializationLevel p_level) {
void uninitialize_terrain_3d(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
}

extern "C" {
// Initialization.
GDExtensionBool GDE_EXPORT terrain_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
GDExtensionBool GDE_EXPORT terrain_library_init(
GDExtensionInterfaceGetProcAddress p_get_proc_address,
GDExtensionClassLibraryPtr p_library,
GDExtensionInitialization *r_initialization) {
GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization);

init_obj.register_initializer(initialize_terrain_types);
init_obj.register_terminator(uninitialize_terrain_types);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE);
init_obj.register_initializer(initialize_terrain_3d);
init_obj.register_terminator(uninitialize_terrain_3d);
init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SERVERS);

return init_obj.init();
}
Expand Down

0 comments on commit dc007d4

Please sign in to comment.