Refactor module initialization

* Changed to use the same stages as extensions.
* Makes the initialization more coherent, helping solve problems due to lack of stages.
* Makes it easier to port between module and extension.
* removed the DRIVER initialization level (no longer needed).
This commit is contained in:
reduz
2022-05-03 11:56:08 +02:00
parent 0a9d31a7eb
commit de0ca3b999
103 changed files with 897 additions and 454 deletions

View File

@@ -32,7 +32,11 @@
#include "scene/resources/surface_tool.h"
#include "thirdparty/meshoptimizer/meshoptimizer.h"
void register_meshoptimizer_types() {
void initialize_meshoptimizer_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
SurfaceTool::optimize_vertex_cache_func = meshopt_optimizeVertexCache;
SurfaceTool::simplify_func = meshopt_simplify;
SurfaceTool::simplify_with_attrib_func = meshopt_simplifyWithAttributes;
@@ -43,7 +47,11 @@ void register_meshoptimizer_types() {
SurfaceTool::remap_index_func = meshopt_remapIndexBuffer;
}
void unregister_meshoptimizer_types() {
void uninitialize_meshoptimizer_module(ModuleInitializationLevel p_level) {
if (p_level != MODULE_INITIALIZATION_LEVEL_SCENE) {
return;
}
SurfaceTool::optimize_vertex_cache_func = nullptr;
SurfaceTool::simplify_func = nullptr;
SurfaceTool::simplify_scale_func = nullptr;

View File

@@ -31,7 +31,9 @@
#ifndef MESHOPTIMIZER_REGISTER_TYPES_H
#define MESHOPTIMIZER_REGISTER_TYPES_H
void register_meshoptimizer_types();
void unregister_meshoptimizer_types();
#include "modules/register_module_types.h"
void initialize_meshoptimizer_module(ModuleInitializationLevel p_level);
void uninitialize_meshoptimizer_module(ModuleInitializationLevel p_level);
#endif // PVR_REGISTER_TYPES_H