Zylann / godot_voxel

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

VoxelStreamSQLite: Cannot load large coordinates #636

Closed NuclearPhoenixx closed 5 months ago

NuclearPhoenixx commented 6 months ago

Using VoxelStreamSQLite on a VoxelTerrain and moving the VoxelViewer to x/y/z greater than about 530_000 will result in the following error message and no terrain loading:

E 0:00:04:0998   zylann::voxel::VoxelStreamSQLite::load_voxel_blocks: Assertion failed: "can_convert_to_i16(pos)" is false.
  <C++ Source>   modules\voxel\streams\sqlite\voxel_stream_sqlite.cpp:712 @ zylann::voxel::VoxelStreamSQLite::load_voxel_blocks()
E 0:00:04:0998   zylann::voxel::LoadBlockDataTask::run: Error loading voxel block
  <C++ Source>   modules\voxel\streams\load_block_data_task.cpp:65 @ zylann::voxel::LoadBlockDataTask::run()

These two lines are just repeated over and over (for each block it tries to load I presume). This seems to be an issue specifically with the SQLite DB since the same issue does not affect the Region Files Stream.

A small test project: project.zip

I'm using one of the latest Windows builds of Voxel Tools that were generated by GitHub actions on here.

Zylann commented 6 months ago

SQLite streams are limited to a range of 32,767 blocks away from the origin, which corresponds to 524,272 voxels (524 Km if you use unit-sized voxels). It's currently an intended limitation. Keys of the database are indexed with one 64-bit integer per row, which isn't enough to store larger coordinates.

Zylann commented 6 months ago

The experimental branch sqlite_large_coordinates implements new coordinate formats that allow larger worlds. The new default format should allow x/y/z beyond 530_000. You have to create a new save though.

NuclearPhoenixx commented 6 months ago

Works like a charm now. I was able to get to 100 million voxels and more, amazing!

Also fixes the performance issues with res:// and user:// for the SQLite stream❤️

NuclearPhoenixx commented 5 months ago

Closing this issue since you've fixed everything. It only needs to be pulled into master anymore afaik.