-
-
Notifications
You must be signed in to change notification settings - Fork 22k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BitMap class limited to XY size 46340x46340 #48399
Comments
That explains it: 46,340 × 46,340 = 2,147,395,600 |
Ah, there it is. Nothing out of the ordinary. Thank you! |
Well if it's going to crash, |
godot/scene/resources/bit_map.h Lines 42 to 44 in eb57dcd
Maybe changing |
I don't think this is the problem, as width and height would still be more than inside their limits. I think something is going wrong in the |
I confirm that I've had issues with resizing |
|
For now, I'll add a check in the create() method to see if the |
I'm fine with sticking to the limit of 1290x1290x1290 for the purposes of my BitMap3D extended class, which I would round down to 1024x1024x1024 max just for simplicity. I'm working with 1m cubes, so that's a 1km volume, which is good enough. I can build arrays of these if need be. If somebody had the urge to create a native Godot BitMap3D class, that would be pretty sweet too for all the voxellers out there :) Thanks for adding the out-of-bounds size check. |
For reference, godot/core/templates/cowdata.h Line 259 in bb6ece1
But godot/core/templates/cowdata.h Lines 132 to 139 in bb6ece1
This is either by design or a bug, at least it looks like to me. 😛 |
The issue is caused by the bug in
The solution is to cast width/height to uint64_t. There are other issues:
|
Yep, that's what I also found. I've fixed it on my machine and once I create the BitMap unit test PR, it should get fixed. |
However, I don't agree that casting to |
Perhaps another reason to give BitMap a rewrite: issue #48545, where it consumes double the needed memory, cancelling one benefit of using an efficient bitmap. |
-Test cases for some public methods in the BitMap class. -Changed the constructor to check if the bitmask was correctly setup to catch issue godotengine#48399 -Fixed blit to actually write to the correct pixel range instead of just writing to the same pixel every time.
The reason being is that the bitmap size is defined using While at it, I'd also change
|
This is waiting on #21922 to be merged. |
How often these methods are called in a typical game? Would they benefit from overloaded methods which accept the bit positions as two doubles instead of Vector2, which avoids object construction? |
The However, to keep compatibility with existing project, you can't rename the current |
It seems to be a duplicate of #46842? We can keep this issue opened to see if anything specific can be done in |
This isn't fixed yet by #86730, but it becomes fixable. The Here's an up-to-date MRP: BitMap64bit.zip Note that it doesn't crash, but triggers errors. It seems we added some guards in the past to prevent passing sizes bigger than |
Godot version:
3.3.stable
OS/device including version:
Linux Ubuntu 20.04.2, NUC7PY, 16 gigs ram.
Issue description:
Cannot create a BitMap larger than 46340 x 46340. Attempting to create a BitMap of (46341, 46341) crashes.
I wanted to use BitMap to create a 3D maze map index of blocks, so that I could build it fast logically before creating the mesh blocks. Since BitMap is 2D, I extended it to stack XY "frames" vertically, representing the Z dimension. e.g a 3D bitmap size of 2,3,4 would create a 2D BitMap of dimensions 2,12 with Y representing the four Z slots. Reading and writing gets translated from the 3D coords to the 2D bitmap coords. See below (in this example, the very first bit at 0,0 shown set to true):
This works well, except I quickly hit the dimension limit for BitMaps, which I was not expecting. I'm guessing the BitMap class is intended mainly for handling bitmap textures/images and therefore was never designed to handle anything larger than the typical 1K, 2K, 4K, 8K standards -- or in this case, 46K.
I'm mainly interested in understanding why the XY size limit is exactly 46340, which is a bit of a strange number in a world where we expect limits to be near power of twos. Thanks!
Steps to reproduce:
Attach below script to a node and run.
Minimal reproduction project:
The text was updated successfully, but these errors were encountered: