Register `VoxelToolBuffer` because otherwise it gets initialized lazily, causing crashes in threads

master
Marc Gilleron 2021-01-17 22:18:41 +00:00
parent fcd9284edf
commit a3bad1af64
2 changed files with 5 additions and 0 deletions

View File

@ -8,6 +8,7 @@ class VoxelBuffer;
class VoxelToolBuffer : public VoxelTool {
GDCLASS(VoxelToolBuffer, VoxelTool)
public:
VoxelToolBuffer() {}
VoxelToolBuffer(Ref<VoxelBuffer> vb);
bool is_area_editable(const Rect3i &box) const override;

View File

@ -1,5 +1,6 @@
#include "register_types.h"
#include "edition/voxel_tool.h"
#include "edition/voxel_tool_buffer.h"
#include "edition/voxel_tool_terrain.h"
#include "editor/editor_plugin.h"
#include "editor/fast_noise_lite/fast_noise_lite_editor_plugin.h"
@ -90,6 +91,9 @@ void register_voxel_types() {
ClassDB::register_class<VoxelRaycastResult>();
ClassDB::register_class<VoxelTool>();
ClassDB::register_class<VoxelToolTerrain>();
// 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>();
ClassDB::register_class<VoxelBlockSerializer>();
ClassDB::register_class<VoxelVoxLoader>();
ClassDB::register_class<FastNoiseLite>();