Zylann / godot_voxel

Voxel module for Godot Engine
MIT License
2.72k stars 251 forks source link

voxel blocky library - going over hard limit causes infinite loop #644

Open QueenTurtle opened 5 months ago

QueenTurtle commented 5 months ago

Describe the bug Despite being able to set the bit depth to 32bit or higher through the voxelviewer; the library in the mesher seems to have a hard limit and the game will lock up if you try to place any more models in it.

To Reproduce Create a voxel blocky library Create a for loop with 70000 iterations Use libary.add on a new voxel blocky model

It gets stuck here possibly due to the constants in voxelblockylibarybase which only seems to support 16 bit

Expected behavior We really would like to use more 65k voxels as we are working on something quite specialised and it is likely that we will need close to a million in any case it probably shouldn't get stuck

Environment

Zylann commented 5 months ago

set the bit depth to 32bit or higher through the voxelviewer

I'm not aware of ways to use VoxelViewer to do that 🤔 viewers just tell where to load things, nothing to do with blocky mesher. I guess you did that in a custom generator?

the library in the mesher seems to have a hard limit

It does, it's documented here: https://voxel-tools.readthedocs.io/en/latest/api/VoxelBlockyLibraryBase/#constants

It gets stuck here

Stuck how? Looks like the code is lacking checks to prevent you from going over the limit, it's quite an old area. But no idea what gets stuck there. Probably some checks need to be added to prevent lockups.

We really would like to use more 65k voxels

This is quite an insane amount already. It sounds like you're trying to do something or workaround something, that is simply not the right approach here. And even then, the mesher won't work on 32-bit, it only has cases for 8 and 16.

we will need close to a million

This is way too much. You're not using the right tool here. This is going to use gigabytes of JUST models data... I'm not really willing to add that to the module at the moment, but maybe you could do some changes on your side. Though still, it really sounds like you aren't using the right system.

QueenTurtle commented 5 months ago

Sorry I mistyped...I meant the voxelbuffer instead of the voxelviewer. It has the depth enum which seems to imply you can set it all the way up to 64bit

When I say it gets stuck I mean the for loop never finishes.

Zylann commented 5 months ago

It has the depth enum which seems to imply you can set it all the way up to 64bit

Yes you can set it to higher depths, but that doesn't mean the rest of the module is tuned to use every possible depth everywhere. Meshers generally don't use 64 bits at all, and some dont use 32 either because it's beyond common/reasonable use cases. It also depends on the channel. I'm actually wondering if I should even keep 64, as I never had any use for it.

When I say it gets stuck I mean the for loop never finishes.

I just tested this:

extends Node

func _ready():
    var library := VoxelBlockyLibrary.new()
    for i in 70000:
        var model := VoxelBlockyModelEmpty.new()
        library.add_model(model)
    print("Loop finished")

It prints Loop finished. Not getting stuck.