01-09-2019, 09:55 PM
(01-09-2019, 06:45 AM)NiLSPACE Wrote: If I'm completely honest I was surprised cBlockArea wasn't used for it already. What were the reasons for not unifying them before?Two reasons:
1. cBlockArea was created much later than cChunk, for different initial purposes (loading and saving prefabs)
2. Until now the chunk sections are exactly the same memory size, and we are using this to provide a special allocator just for the sections (cAllocationPool) that was meant to provide an out-of-memory and almost-out-of-memory handling.
(01-09-2019, 06:45 AM)NiLSPACE Wrote: I've been programming C# for years now which has the following convention: ClassName, MethodName, _fieldName, argumentName, localVariableSo we agree on ClassName and localVariable; partially on argumentName (by forcing an "a" prefix). Whether methods use first capital or not is not a big issue with me, but what I resent is the underscore. It is the most unfortunate character - its very low visibility makes it too easy to mix up with a space. I'll be adamant about having as little underscores as possible.
(01-09-2019, 06:45 AM)NiLSPACE Wrote:That's the general idea - for each storage use only as few bits as possible. For performance reasons, we may want to limit to 4-, 8-, 16- and 32-bit numbers. There are special cases when we'll need to use more bits than actually needed - when merging two BAs.xoft Wrote:... This could even be gradual - first implement only 32-bit numbers ...Would it be possible to dynamically change the size?
(01-09-2019, 06:45 AM)NiLSPACE Wrote: I'm having trouble visualizing how block manipulation would happen. Would we return strings to specify a block type? What happens when two plugins register a type of the same name?I was thinking something like this (in a *single* BlockArea):
/** Sets a single block using its full blockspec */ void setBlock(const Vector3i & aPos, const AString & aBlockName, const BlockState & aBlockState); /** Sets a single block using an index to the palette (retrieved earlier by paletteIndex()). */ void setBlock(const Vector3i & aPos, UInt32 aPalleteIndex); /** Returns the index into the palette that is used by the specified full blockspec. Adds the blockspec to palette if not already there. */ UInt32 paletteIndex(const AString & aBlockName, const BlockState & aBlockState); /** Returns the index into the palette that is used by the specified full blockspec. Returns <undefined, false> if blockspec not in palette. */ std::pair<UInt32, bool> maybePaletteIndex(const AString & aBlockName, const BlockState & aBlockState); /** Returns the index into the palette for the block at the specified pos. */ UInt32 blockPaletteIndex(const Vector3i & aPos); /** Returns the full (copy of) blockspec of the block at the specified position. */ std::pair<AString, BlockState> block(const Vector3i & aPos); /** Returns (an editable (?) blockspec represented by the specified palette index. */ std::pair<AString &, BlockState &> paletteEntry(UInt32 aPaletteIndex);