mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 04:51:49 +00:00
reduce allocations while reading chunks data
This commit is contained in:
parent
21f7390265
commit
9dc9441902
12 changed files with 93 additions and 43 deletions
|
|
@ -23,12 +23,10 @@ std::unique_ptr<ubyte[]> Lightmap::encode() const {
|
|||
return buffer;
|
||||
}
|
||||
|
||||
std::unique_ptr<light_t[]> Lightmap::decode(const ubyte* buffer) {
|
||||
auto lights = std::make_unique<light_t[]>(CHUNK_VOL);
|
||||
void Lightmap::decode(const ubyte* src) {
|
||||
for (uint i = 0; i < CHUNK_VOL; i+=2) {
|
||||
ubyte b = buffer[i/2];
|
||||
lights[i] = ((b & 0xF) << 12);
|
||||
lights[i+1] = ((b & 0xF0) << 8);
|
||||
ubyte b = src[i/2];
|
||||
map[i] = ((b & 0xF) << 12);
|
||||
map[i+1] = ((b & 0xF0) << 8);
|
||||
}
|
||||
return lights;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ public:
|
|||
}
|
||||
|
||||
std::unique_ptr<ubyte[]> encode() const;
|
||||
static std::unique_ptr<light_t[]> decode(const ubyte* buffer);
|
||||
void decode(const ubyte* src);
|
||||
|
||||
static inline light_t SUN_LIGHT_ONLY = combine(0U, 0U, 0U, 15U);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue