util/dataio + Lightmap.encode
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
#include "Lightmap.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include "../util/data_io.h"
|
||||
|
||||
Lightmap::Lightmap(){
|
||||
map = new unsigned short[CHUNK_VOL];
|
||||
for (unsigned int i = 0; i < CHUNK_VOL; i++){
|
||||
map = new light_t[CHUNK_VOL];
|
||||
for (uint i = 0; i < CHUNK_VOL; i++){
|
||||
map[i] = 0x0000;
|
||||
}
|
||||
}
|
||||
@@ -16,3 +19,13 @@ void Lightmap::set(const Lightmap* lightmap) {
|
||||
map[i] = lightmap->map[i];
|
||||
}
|
||||
}
|
||||
|
||||
static_assert(sizeof(light_t) == 2, "replace dataio calls to new light_t");
|
||||
|
||||
ubyte* Lightmap::encode() const {
|
||||
ubyte* buffer = new ubyte[CHUNK_VOL * sizeof(light_t)];
|
||||
for (uint i = 0; i < CHUNK_VOL; i++) {
|
||||
dataio::write_int16_big(map[i], buffer, i * sizeof(light_t));
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user