Zylann / godot_voxel

Voxel module for Godot Engine
Other
2.46k stars 227 forks source link

Would be nice to be able to disable VoxelInstancer in editor #299

Open slapin opened 2 years ago

slapin commented 2 years ago

Would be nice to be able to disable VoxelInstancer in editor or crashes like this occur at times especially with scenes (and no way to minimize these upfront).

ERROR: Condition "item == nullptr" is true. Continuing.
   at: process_mesh_lods (/home/slapin/godot-projects/small-game/src/modules/voxel/terrain/instancing/voxel_instancer.cpp:210)
ERROR: Condition "item == nullptr" is true. Continuing.
   at: process_mesh_lods (/home/slapin/godot-projects/small-game/src/modules/voxel/terrain/instancing/voxel_instancer.cpp:210)
ERROR: Condition "item == nullptr" is true. Continuing.
   at: process_mesh_lods (/home/slapin/godot-projects/small-game/src/modules/voxel/terrain/instancing/voxel_instancer.cpp:210)
ERROR: All memory pool allocations are in use.
   at: resize (./core/pool_vector.h:512)
ERROR: All memory pool allocations are in use.
   at: resize (./core/pool_vector.h:512)
handle_crash: Program crashed with signal 11
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3be30) [0x7f1316e6de30] (??:0)
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3be30) [0x7f1316e6de30] (??:0)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0xa7956) [0x7f1316ed9956] (??:0)
[2] /lib/x86_64-linux-gnu/libc.so.6(+0xa7956) [0x7f1316ed9956] (??:0)
ERROR: All memory pool allocations are in use.
   at: resize (./core/pool_vector.h:512)
ERROR: All memory pool allocations are in use.
   at: resize (./core/pool_vector.h:512)
handle_crash: Program crashed with signal 11
Dumping the backtrace. Please include this when reporting the bug on https://github.com/godotengine/godot/issues
[1] /lib/x86_64-linux-gnu/libc.so.6(+0x3be30) [0x7f1316e6de30] (??:0)
[3] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf08fa] (/home/slapin/godot-projects/small-game/src/godot/./core/pool_vector.h:291)
[3] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf3863] (/home/slapin/godot-projects/small-game/src/godot/./core/pool_vector.h:291)
[2] ../../src/godot/bin/godot.x11.opt.tools.64() [0x2d2c310] (/home/slapin/godot-projects/small-game/src/godot/servers/visual_server.cpp:415)
[4] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf3509] (/usr/include/c++/10/bits/stl_vector.h:919)
[4] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf6e56] (/home/slapin/godot-projects/small-game/src/modules/voxel/meshers/transvoxel/voxel_mesher_transvoxel.cpp:191)
[3] ../../src/godot/bin/godot.x11.opt.tools.64() [0x2d2d67b] (/home/slapin/godot-projects/small-game/src/godot/servers/visual_server.cpp:1094 (discriminator 1))
[5] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf6d2a] (/home/slapin/godot-projects/small-game/src/modules/voxel/meshers/transvoxel/voxel_mesher_transvoxel.cpp:175)
[5] ../../src/godot/bin/godot.x11.opt.tools.64() [0xd37a9d] (/home/slapin/godot-projects/small-game/src/modules/voxel/server/voxel_server.cpp:882)
[4] ../../src/godot/bin/godot.x11.opt.tools.64() [0x2a0e9f7] (/home/slapin/godot-projects/small-game/src/godot/scene/resources/mesh.cpp:855)
[6] ../../src/godot/bin/godot.x11.opt.tools.64() [0xd40184] (/usr/include/c++/10/bits/stl_vector.h:919 (discriminator 2))
[6] ../../src/godot/bin/godot.x11.opt.tools.64() [0xd37a9d] (/home/slapin/godot-projects/small-game/src/modules/voxel/server/voxel_server.cpp:882)
[5] ../../src/godot/bin/godot.x11.opt.tools.64() [0xcd3557] (/home/slapin/godot-projects/small-game/src/modules/voxel/terrain/voxel_lod_terrain.cpp:38 (discriminator 3))
[7] ../../src/godot/bin/godot.x11.opt.tools.64() [0xd40184] (/usr/include/c++/10/bits/stl_vector.h:919 (discriminator 2))
[7] ../../src/godot/bin/godot.x11.opt.tools.64() [0x3354cea] (/home/slapin/godot-projects/small-game/src/godot/core/os/thread.cpp:76)
[6] ../../src/godot/bin/godot.x11.opt.tools.64() [0xcdf6ad] (/home/slapin/godot-projects/small-game/src/godot/./core/cowdata.h:384)
[8] ../../src/godot/bin/godot.x11.opt.tools.64() [0x3354cea] (/home/slapin/godot-projects/small-game/src/godot/core/os/thread.cpp:76)
[8] ../../src/godot/bin/godot.x11.opt.tools.64() [0x367fc60] (thread.o:?)
[9] /lib/x86_64-linux-gnu/libpthread.so.0(+0x8ea7) [0x7f1317149ea7] (??:0)
[10] /lib/x86_64-linux-gnu/libc.so.6(clone+0x3f) [0x7f1316f2feaf] (??:0)
-- END OF BACKTRACE --
slapin commented 2 years ago

I know it is not quite intended to be controllable from inspector but still would be nice to avoid things like that...

Zylann commented 2 years ago
ERROR: Condition "item == nullptr" is true. Continuing.
   at: process_mesh_lods (/home/slapin/godot-projects/small-game/src/modules/voxel/terrain/instancing/voxel_instancer.cpp:210)

This one is actually a bug, it is trying to update mesh lods on an instance block which I guess is using scene items. Scene items do not have this feature so I think it should skip them instead.

ERROR: All memory pool allocations are in use.
   at: resize (./core/pool_vector.h:512)

This is broader, and most likely cause is that there are more than 65536 PoolVectors currently in use, which is a hardcoded limitation of Godot 3 (a pretty dumb one if I must say). It happens often when there are many meshes in the scene, even if there is a lot of spare memory on the computer.

As for the crash, it needs further investigation. Could be a consequence of previous error.

[2] ../../src/godot/bin/godot.x11.opt.tools.64() [0x2d2c310] (/home/slapin/godot-projects/small-game/src/godot/servers/visual_server.cpp:415)
[4] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf3509] (/usr/include/c++/10/bits/stl_vector.h:919)
[4] ../../src/godot/bin/godot.x11.opt.tools.64() [0xbf6e56] (/home/slapin/godot-projects/small-game/src/modules/voxel/meshers/transvoxel/voxel_mesher_transvoxel.cpp:191)

That jump between areas of the engine looks pretty wild. For a moment I thought there was an issue accessing an std::vector, but the next stack frame is inside... VisualServer Oo

slapin commented 2 years ago

The problem is you can't reduce the count when adding an item, thus disabling instancing in editor while fiddling with parameters would be nice.

Zylann commented 2 years ago

You can reduce count by reducing density. Also keep in mind scene instances are incredibly expensive in Godot (all these niceties come at a cost), so it is really intented to use at low densities.

So in summary, there are a few bugs to fix here, and an enhancement for being able to turn off instancing.

slapin commented 2 years ago

Yes, but I don't get the chance to get to the parameters, I add an item and crash happens :)

slapin commented 2 years ago

This only affects inspector, from code everything works fine.

Zylann commented 2 years ago

Adressed some errors and crash in d6e4769f08b253225a7898a32544876e067b3466 and 2853f42dd7ae504dc8f863616ea6869330e86098, you can retry see if a crash still happens.

Disabling is actually more work than it sounds, it's not just an inspector thing. The instancer reacts to events coming from the parent node, it also reacts to multiple kinds of changes that can happen in its library, and it also has a process function. And even if hidden, in the case of scenes, they still have to get instanced. And if not instanced, there is nowhere to store their position so it will desync. Currently the easiest workaround to edit scene items without having a VoxelInstancer active, is to have the library be saved in its own file, so you can edit it while the scene is closed.