Cuberite Forum
[FIXED] Splitting chunk data - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Development (https://forum.cuberite.org/forum-13.html)
+--- Thread: [FIXED] Splitting chunk data (/thread-394.html)



[FIXED] Splitting chunk data - xoft - 03-15-2012

I'll be splitting the chunk data into separate byte arrays for each of BlockType, BlockMeta, BlockLight and BlockSkyLight, to make it possible to implement dynamic chunk height. This means I'll be touching most chunk-data-related stuff, especially storage, generation and packetizing.

This message is only to inform other developers of the upcoming change and a plea that they refrain from changing stuff too much to avoid potential code conflicts Smile


RE: Splitting chunk data - FakeTruth - 03-15-2012

??? Why


RE: Splitting chunk data - xoft - 03-15-2012

Because that needs to be done before you can have dynamic chunk height.


RE: Splitting chunk data - FakeTruth - 03-15-2012

Not really, but whatever


RE: Splitting chunk data - xoft - 03-15-2012

Can you imagine indexing the array if you had dynamic chunk height AND a joined array?
m_BlockData[XZSliceSize * ChunkHeight + XZSliceNibbleSize * ChunkHeight + XZSliceNibbleSize * ChunkHeight + IndexToSkyLight]
There, finished. It's a bit cleaner now. And finally loaders and generators may pass heightmap of the new chunk, instad of having to recalculate it Smile


RE: [FIXED] Splitting chunk data - xoft - 03-15-2012

I've had a hunch that the GetNibble() and SetNibble() functions might be a bit faster on unsigned chars. So I tried it out, turns out there's no differrence at all. Weird, considering that the signed char version has a few more assembly instructions in the code, converting between signed and unsigned. One would expect that on millions of calls that would have matterred. Seems like my knowledge of the x86 processors is being deprecated by the new models.

Anyway, we can now choose between the signed and unsigned variant simply by defining the BLOCKTYPE typedef in ChunkDef.h


RE: Splitting chunk data - FakeTruth - 03-15-2012

(03-15-2012, 06:21 AM)xoft Wrote: Can you imagine indexing the array if you had dynamic chunk height AND a joined array?
m_BlockData[XZSliceSize * ChunkHeight + XZSliceNibbleSize * ChunkHeight + XZSliceNibbleSize * ChunkHeight + IndexToSkyLight]

Actually we were already using offsetted pointers, so there's no need for IndexToSkyLight


RE: [FIXED] Splitting chunk data - xoft - 03-15-2012

But the offsetted pointers would still have to be calculated dynamically upon each call.
And extending the chunk's height, when needed, would be painful Wink


RE: [FIXED] Splitting chunk data - FakeTruth - 03-15-2012

(03-15-2012, 07:55 AM)xoft Wrote: But the offsetted pointers would still have to be calculated dynamically upon each call.
And extending the chunk's height, when needed, would be painful Wink

Once every time the height changed :O

???

Right now you cannot be sure that the metadata comes right after the chunk data in memory


RE: [FIXED] Splitting chunk data - xoft - 03-15-2012

Yes, you cannot, and the point is, you should not have to worry about that. You get your pointers to the specified data, that's all. If you want to merge it into a single array or not, that's up to you.