Cuberite
A lightweight, fast and extensible game server for Minecraft
ChunkData.cpp
Go to the documentation of this file.
1 
2 // ChunkData.cpp
3 
4 // Implements the cChunkData class that represents the block's type, meta, blocklight and skylight storage for a chunk
5 
6 #include "Globals.h"
7 #include "ChunkData.h"
8 
9 
10 
11 
12 
13 namespace
14 {
16  template <typename T>
17  bool IsAllValue(const T * a_Array, size_t a_NumElements, T a_Value)
18  {
19  for (size_t i = 0; i < a_NumElements; i++)
20  {
21  if (a_Array[i] != a_Value)
22  {
23  return false;
24  }
25  }
26  return true;
27  }
28 
29 
30 
31 
32 
33  struct sSectionIndices
34  {
35  int Section = 0; // Index into m_Sections
36  int Index = 0; // Index into a single sChunkSection
37  };
38 
39  sSectionIndices IndicesFromRelPos(Vector3i a_RelPos)
40  {
42  sSectionIndices Ret;
43  Ret.Section = a_RelPos.y / cChunkData::SectionHeight;
44  Ret.Index = cChunkDef::MakeIndexNoCheck(a_RelPos.x, a_RelPos.y % cChunkData::SectionHeight, a_RelPos.z);
45  return Ret;
46  }
47 } // namespace (anonymous)
48 
49 
50 
51 
52 
54  m_Sections(),
55  m_Pool(a_Pool)
56 {
57 }
58 
59 
60 
61 
62 
64  m_Pool(a_Other.m_Pool)
65 {
66  for (size_t i = 0; i < NumSections; i++)
67  {
68  m_Sections[i] = a_Other.m_Sections[i];
69  a_Other.m_Sections[i] = nullptr;
70  }
71 }
72 
73 
74 
75 
76 
78 {
79  Clear();
80 }
81 
82 
83 
84 
85 
86 void cChunkData::Assign(const cChunkData & a_Other)
87 {
88  // If assigning to self, no-op
89  if (&a_Other == this)
90  {
91  return;
92  }
93 
94  Clear();
95  for (size_t i = 0; i < NumSections; ++i)
96  {
97  if (a_Other.m_Sections[i] != nullptr)
98  {
99  m_Sections[i] = Allocate();
100  *m_Sections[i] = *a_Other.m_Sections[i];
101  }
102  }
103 }
104 
105 
106 
107 
108 
110 {
111  if (&a_Other == this)
112  {
113  return;
114  }
115 
116  if (m_Pool != a_Other.m_Pool)
117  {
118  // Cannot transfer the memory, do a copy instead
119  const cChunkData & CopyOther = a_Other;
120  Assign(CopyOther);
121  return;
122  }
123 
124  Clear();
125  for (size_t i = 0; i < NumSections; i++)
126  {
127  m_Sections[i] = a_Other.m_Sections[i];
128  a_Other.m_Sections[i] = nullptr;
129  }
130 }
131 
132 
133 
134 
135 
137 {
138  if (!cChunkDef::IsValidRelPos(a_RelPos))
139  {
140  return E_BLOCK_AIR; // Coordinates are outside outside the world, so this must be an air block
141  }
142  auto Idxs = IndicesFromRelPos(a_RelPos);
143  if (m_Sections[Idxs.Section] != nullptr)
144  {
145  return m_Sections[Idxs.Section]->m_BlockTypes[Idxs.Index];
146  }
147  else
148  {
149  return 0;
150  }
151 }
152 
153 
154 
155 
156 
157 void cChunkData::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_Block)
158 {
159  if (!cChunkDef::IsValidRelPos(a_RelPos))
160  {
161  ASSERT(!"cChunkData::SetMeta(): index out of range!");
162  return;
163  }
164 
165  auto Idxs = IndicesFromRelPos(a_RelPos);
166  if (m_Sections[Idxs.Section] == nullptr)
167  {
168  if (a_Block == 0x00)
169  {
170  return;
171  }
172  m_Sections[Idxs.Section] = Allocate();
173  if (m_Sections[Idxs.Section] == nullptr)
174  {
175  ASSERT(!"Failed to allocate a new section in Chunkbuffer");
176  return;
177  }
178  ZeroSection(m_Sections[Idxs.Section]);
179  }
180  m_Sections[Idxs.Section]->m_BlockTypes[Idxs.Index] = a_Block;
181 }
182 
183 
184 
185 
186 
188 {
189  if (cChunkDef::IsValidRelPos(a_RelPos))
190  {
191  auto Idxs = IndicesFromRelPos(a_RelPos);
192  if (m_Sections[Idxs.Section] != nullptr)
193  {
194  return (m_Sections[Idxs.Section]->m_BlockMetas[Idxs.Index / 2] >> ((Idxs.Index & 1) * 4)) & 0x0f;
195  }
196  else
197  {
198  return 0;
199  }
200  }
201  // Coordinates are outside outside the world, so it must be an air block with a blank meta
202  return 0;
203 }
204 
205 
206 
207 
208 
209 bool cChunkData::SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Nibble)
210 {
211  if (!cChunkDef::IsValidRelPos(a_RelPos))
212  {
213  ASSERT(!"cChunkData::SetMeta(): index out of range!");
214  return false;
215  }
216 
217  auto Idxs = IndicesFromRelPos(a_RelPos);
218  if (m_Sections[Idxs.Section] == nullptr)
219  {
220  if ((a_Nibble & 0xf) == 0x00)
221  {
222  return false;
223  }
224  m_Sections[Idxs.Section] = Allocate();
225  if (m_Sections[Idxs.Section] == nullptr)
226  {
227  ASSERT(!"Failed to allocate a new section in Chunkbuffer");
228  return false;
229  }
230  ZeroSection(m_Sections[Idxs.Section]);
231  }
232  NIBBLETYPE oldval = m_Sections[Idxs.Section]->m_BlockMetas[Idxs.Index / 2] >> ((Idxs.Index & 1) * 4) & 0xf;
233  m_Sections[Idxs.Section]->m_BlockMetas[Idxs.Index / 2] = static_cast<NIBBLETYPE>(
234  (m_Sections[Idxs.Section]->m_BlockMetas[Idxs.Index / 2] & (0xf0 >> ((Idxs.Index & 1) * 4))) | // The untouched nibble
235  ((a_Nibble & 0x0f) << ((Idxs.Index & 1) * 4)) // The nibble being set
236  );
237  return oldval != a_Nibble;
238 }
239 
240 
241 
242 
243 
245 {
246  if (cChunkDef::IsValidRelPos(a_RelPos))
247  {
248  auto Idxs = IndicesFromRelPos(a_RelPos);
249  if (m_Sections[Idxs.Section] != nullptr)
250  {
251  return (m_Sections[Idxs.Section]->m_BlockLight[Idxs.Index / 2] >> ((Idxs.Index & 1) * 4)) & 0x0f;
252  }
253  else
254  {
255  return 0;
256  }
257  }
258  ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
259  return 0;
260 }
261 
262 
263 
264 
265 
267 {
268  if (cChunkDef::IsValidRelPos(a_RelPos))
269  {
270  auto Idxs = IndicesFromRelPos(a_RelPos);
271  if (m_Sections[Idxs.Section] != nullptr)
272  {
273  return (m_Sections[Idxs.Section]->m_BlockSkyLight[Idxs.Index / 2] >> ((Idxs.Index & 1) * 4)) & 0x0f;
274  }
275  else
276  {
277  return 0xF;
278  }
279  }
280  ASSERT(!"cChunkData::GetMeta(): coords out of chunk range!");
281  return 0;
282 }
283 
284 
285 
286 
287 
288 const cChunkData::sChunkSection * cChunkData::GetSection(size_t a_SectionNum) const
289 {
290  if (a_SectionNum < NumSections)
291  {
292  return m_Sections[a_SectionNum];
293  }
294  ASSERT(!"cChunkData::GetSection: section index out of range");
295  return nullptr;
296 }
297 
298 
299 
300 
301 
303 {
304  static_assert(NumSections <= 16U, "cChunkData::GetSectionBitmask needs a bigger data type");
305  UInt16 Res = 0U;
306  for (size_t i = 0U; i < NumSections; ++i)
307  {
308  Res |= ((m_Sections[i] != nullptr) << i);
309  }
310  return Res;
311 }
312 
313 
314 
315 
316 
318 {
319  for (size_t i = 0; i < NumSections; ++i)
320  {
321  if (m_Sections[i] != nullptr)
322  {
323  Free(m_Sections[i]);
324  m_Sections[i] = nullptr;
325  }
326  }
327 }
328 
329 
330 
331 
332 
333 void cChunkData::CopyBlockTypes(BLOCKTYPE * a_Dest, size_t a_Idx, size_t a_Length) const
334 {
335  size_t ToSkip = a_Idx;
336 
337  for (size_t i = 0; i < NumSections; i++)
338  {
339  size_t StartPos = 0;
340  if (ToSkip > 0)
341  {
342  StartPos = std::min(ToSkip, +SectionBlockCount);
343  ToSkip -= StartPos;
344  }
345  if (StartPos < SectionBlockCount)
346  {
347  size_t ToCopy = std::min(+SectionBlockCount - StartPos, a_Length);
348  a_Length -= ToCopy;
349  if (m_Sections[i] != nullptr)
350  {
351  BLOCKTYPE * blockbuffer = m_Sections[i]->m_BlockTypes;
352  memcpy(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], blockbuffer + StartPos, sizeof(BLOCKTYPE) * ToCopy);
353  }
354  else
355  {
356  memset(&a_Dest[(i * SectionBlockCount) + StartPos - a_Idx], 0, sizeof(BLOCKTYPE) * ToCopy);
357  }
358  }
359  }
360 }
361 
362 
363 
364 
365 
366 void cChunkData::CopyMetas(NIBBLETYPE * a_Dest) const
367 {
368  for (size_t i = 0; i < NumSections; i++)
369  {
370  if (m_Sections[i] != nullptr)
371  {
372  memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockMetas, sizeof(m_Sections[i]->m_BlockMetas));
373  }
374  else
375  {
376  memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockMetas));
377  }
378  }
379 }
380 
381 
382 
383 
384 
386 {
387  for (size_t i = 0; i < NumSections; i++)
388  {
389  if (m_Sections[i] != nullptr)
390  {
391  memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockLight, sizeof(m_Sections[i]->m_BlockLight));
392  }
393  else
394  {
395  memset(&a_Dest[i * SectionBlockCount / 2], 0, sizeof(m_Sections[i]->m_BlockLight));
396  }
397  }
398 }
399 
400 
401 
402 
403 
405 {
406  for (size_t i = 0; i < NumSections; i++)
407  {
408  if (m_Sections[i] != nullptr)
409  {
410  memcpy(&a_Dest[i * SectionBlockCount / 2], &m_Sections[i]->m_BlockSkyLight, sizeof(m_Sections[i]->m_BlockSkyLight));
411  }
412  else
413  {
414  memset(&a_Dest[i * SectionBlockCount / 2], 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
415  }
416  }
417 }
418 
419 
420 
421 
422 
424 {
425  // If needed, allocate any missing sections
426  if (a_Value != 0x00)
427  {
428  for (auto & Section : m_Sections)
429  {
430  if (Section == nullptr)
431  {
432  Section = Allocate();
433  std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00);
434  std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00);
435  std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff);
436  }
437  }
438  }
439 
440  for (auto Section : m_Sections)
441  {
442  if (Section != nullptr)
443  {
444  std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), a_Value);
445  }
446  }
447 }
448 
449 
450 
451 
452 
454 {
455  // If needed, allocate any missing sections
456  if (a_Value != 0x00)
457  {
458  for (auto & Section : m_Sections)
459  {
460  if (Section == nullptr)
461  {
462  Section = Allocate();
463  std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00);
464  std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00);
465  std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff);
466  }
467  }
468  }
469 
470  NIBBLETYPE NewMeta = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value);
471  for (auto Section : m_Sections)
472  {
473  if (Section != nullptr)
474  {
475  std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), NewMeta);
476  }
477  }
478 }
479 
480 
481 
482 
483 
485 {
486  // If needed, allocate any missing sections
487  if (a_Value != 0x00)
488  {
489  for (auto & Section : m_Sections)
490  {
491  if (Section == nullptr)
492  {
493  Section = Allocate();
494  std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00);
495  std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00);
496  std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), 0xff);
497  }
498  }
499  }
500 
501  NIBBLETYPE NewLight = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value);
502  for (auto Section : m_Sections)
503  {
504  if (Section != nullptr)
505  {
506  std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), NewLight);
507  }
508  }
509 }
510 
511 
512 
513 
514 
516 {
517  // If needed, allocate any missing sections
518  if (a_Value != 0x0f)
519  {
520  for (auto & Section : m_Sections)
521  {
522  if (Section == nullptr)
523  {
524  Section = Allocate();
525  std::fill(std::begin(Section->m_BlockTypes), std::end(Section->m_BlockTypes), 0x00);
526  std::fill(std::begin(Section->m_BlockMetas), std::end(Section->m_BlockMetas), 0x00);
527  std::fill(std::begin(Section->m_BlockLight), std::end(Section->m_BlockLight), 0x00);
528  }
529  }
530  }
531 
532  NIBBLETYPE NewSkyLight = static_cast<NIBBLETYPE>((a_Value << 4) | a_Value);
533  for (auto Section : m_Sections)
534  {
535  if (Section != nullptr)
536  {
537  std::fill(std::begin(Section->m_BlockSkyLight), std::end(Section->m_BlockSkyLight), NewSkyLight);
538  }
539  }
540 }
541 
542 
543 
544 
545 
547 {
548  ASSERT(a_Src != nullptr);
549 
550  for (size_t i = 0; i < NumSections; i++)
551  {
552  // If the section is already allocated, copy the data into it:
553  if (m_Sections[i] != nullptr)
554  {
555  memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes));
556  continue;
557  }
558 
559  // The section doesn't exist, find out if it is needed:
560  if (IsAllValue(a_Src + i * SectionBlockCount, SectionBlockCount, static_cast<BLOCKTYPE>(0)))
561  {
562  // No need for the section, the data is all-air
563  continue;
564  }
565 
566  // Allocate the section and copy the data into it:
567  m_Sections[i] = Allocate();
568  memcpy(m_Sections[i]->m_BlockTypes, &a_Src[i * SectionBlockCount], sizeof(m_Sections[i]->m_BlockTypes));
569  memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
570  memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
571  memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
572  } // for i - m_Sections[]
573 }
574 
575 
576 
577 
578 
579 void cChunkData::SetMetas(const NIBBLETYPE * a_Src)
580 {
581  ASSERT(a_Src != nullptr);
582 
583  for (size_t i = 0; i < NumSections; i++)
584  {
585  // If the section is already allocated, copy the data into it:
586  if (m_Sections[i] != nullptr)
587  {
588  memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas));
589  continue;
590  }
591 
592  // The section doesn't exist, find out if it is needed:
593  if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0)))
594  {
595  // No need for the section, the data is all zeroes
596  continue;
597  }
598 
599  // Allocate the section and copy the data into it:
600  m_Sections[i] = Allocate();
601  memcpy(m_Sections[i]->m_BlockMetas, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockMetas));
602  memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
603  memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
604  memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
605  } // for i - m_Sections[]
606 }
607 
608 
609 
610 
611 
613 {
614  if (a_Src == nullptr)
615  {
616  return;
617  }
618 
619  for (size_t i = 0; i < NumSections; i++)
620  {
621  // If the section is already allocated, copy the data into it:
622  if (m_Sections[i] != nullptr)
623  {
624  memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight));
625  continue;
626  }
627 
628  // The section doesn't exist, find out if it is needed:
629  if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0)))
630  {
631  // No need for the section, the data is all zeroes
632  continue;
633  }
634 
635  // Allocate the section and copy the data into it:
636  m_Sections[i] = Allocate();
637  memcpy(m_Sections[i]->m_BlockLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockLight));
638  memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
639  memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
640  memset(m_Sections[i]->m_BlockSkyLight, 0xff, sizeof(m_Sections[i]->m_BlockSkyLight));
641  } // for i - m_Sections[]
642 }
643 
644 
645 
646 
647 
649 {
650  if (a_Src == nullptr)
651  {
652  return;
653  }
654 
655  for (size_t i = 0; i < NumSections; i++)
656  {
657  // If the section is already allocated, copy the data into it:
658  if (m_Sections[i] != nullptr)
659  {
660  memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight));
661  continue;
662  }
663 
664  // The section doesn't exist, find out if it is needed:
665  if (IsAllValue(a_Src + i * SectionBlockCount / 2, SectionBlockCount / 2, static_cast<NIBBLETYPE>(0xff)))
666  {
667  // No need for the section, the data is all zeroes
668  continue;
669  }
670 
671  // Allocate the section and copy the data into it:
672  m_Sections[i] = Allocate();
673  memcpy(m_Sections[i]->m_BlockSkyLight, &a_Src[i * SectionBlockCount / 2], sizeof(m_Sections[i]->m_BlockSkyLight));
674  memset(m_Sections[i]->m_BlockTypes, 0x00, sizeof(m_Sections[i]->m_BlockTypes));
675  memset(m_Sections[i]->m_BlockMetas, 0x00, sizeof(m_Sections[i]->m_BlockMetas));
676  memset(m_Sections[i]->m_BlockLight, 0x00, sizeof(m_Sections[i]->m_BlockLight));
677  } // for i - m_Sections[]
678 }
679 
680 
681 
682 
683 
685 {
686  UInt32 Ret = 0U;
687  for (size_t i = 0; i < NumSections; i++)
688  {
689  if (m_Sections[i] != nullptr)
690  {
691  ++Ret;
692  }
693  }
694  return Ret;
695 }
696 
697 
698 
699 
700 
702 {
703  return m_Pool.Allocate();
704 }
705 
706 
707 
708 
709 
711 {
712  m_Pool.Free(a_Section);
713 }
714 
715 
716 
717 
718 
720 {
721  memset(a_Section->m_BlockTypes, 0x00, sizeof(a_Section->m_BlockTypes));
722  memset(a_Section->m_BlockMetas, 0x00, sizeof(a_Section->m_BlockMetas));
723  memset(a_Section->m_BlockLight, 0x00, sizeof(a_Section->m_BlockLight));
724  memset(a_Section->m_BlockSkyLight, 0xff, sizeof(a_Section->m_BlockSkyLight));
725 }
726 
727 
728 
729 
void CopyMetas(NIBBLETYPE *a_Dest) const
Copies the metadata into the specified flat array.
Definition: ChunkData.cpp:366
T x
Definition: Vector3.h:17
cChunkData(cAllocationPool< sChunkSection > &a_Pool)
Definition: ChunkData.cpp:53
BLOCKTYPE m_BlockTypes[SectionBlockCount]
Definition: ChunkData.h:29
unsigned char BLOCKTYPE
The datatype used by blockdata.
Definition: ChunkDef.h:42
const sChunkSection * GetSection(size_t a_SectionNum) const
Return a pointer to the chunk section or nullptr if all air.
Definition: ChunkData.cpp:288
static bool IsValidRelPos(Vector3i a_RelPos)
Validates a chunk relative coordinate.
Definition: ChunkDef.h:224
NIBBLETYPE GetBlockLight(Vector3i a_RelPos) const
Definition: ChunkData.cpp:244
BLOCKTYPE GetBlock(Vector3i a_RelPos) const
Definition: ChunkData.cpp:136
void CopyBlockLight(NIBBLETYPE *a_Dest) const
Copies the block light data into the specified flat array.
Definition: ChunkData.cpp:385
sChunkSection * Allocate(void)
Allocates a new section.
Definition: ChunkData.cpp:701
void CopySkyLight(NIBBLETYPE *a_Dest) const
Copies the skylight data into the specified flat array.
Definition: ChunkData.cpp:404
void SetBlockLight(const NIBBLETYPE *a_Src)
Copies the blocklight data from the specified flat array into the internal representation.
Definition: ChunkData.cpp:612
void SetBlock(Vector3i a_RelPos, BLOCKTYPE a_Block)
Definition: ChunkData.cpp:157
unsigned char NIBBLETYPE
The datatype used by nibbledata (meta, light, skylight)
Definition: ChunkDef.h:45
void CopyBlockTypes(BLOCKTYPE *a_Dest, size_t a_Idx=0, size_t a_Length=cChunkDef::NumBlocks) const
Copies the blocktype data into the specified flat array.
Definition: ChunkData.cpp:333
static int MakeIndexNoCheck(int x, int y, int z)
Definition: ChunkDef.h:275
T y
Definition: Vector3.h:17
void SetBlockTypes(const BLOCKTYPE *a_Src)
Copies the blocktype data from the specified flat array into the internal representation.
Definition: ChunkData.cpp:546
void Free(sChunkSection *a_Section)
Frees the specified section, previously allocated using Allocate().
Definition: ChunkData.cpp:710
T z
Definition: Vector3.h:17
cAllocationPool< sChunkSection > & m_Pool
Definition: ChunkData.h:122
static const size_t SectionBlockCount
Definition: ChunkData.h:25
void ZeroSection(sChunkSection *a_Section) const
Sets the data in the specified section to their default values.
Definition: ChunkData.cpp:719
NIBBLETYPE GetSkyLight(Vector3i a_RelPos) const
Definition: ChunkData.cpp:266
void FillBlockTypes(BLOCKTYPE a_Value)
Fills the chunk with the specified block.
Definition: ChunkData.cpp:423
void FillBlockLight(NIBBLETYPE a_Value)
Fills the chunk with the specified block light.
Definition: ChunkData.cpp:484
#define ASSERT(x)
Definition: Globals.h:335
NIBBLETYPE m_BlockSkyLight[SectionBlockCount/2]
Definition: ChunkData.h:32
void SetSkyLight(const NIBBLETYPE *a_Src)
Copies the skylight data from the specified flat array into the internal representation.
Definition: ChunkData.cpp:648
void FillMetas(NIBBLETYPE a_Value)
Fills the chunk with the specified meta value.
Definition: ChunkData.cpp:453
unsigned short UInt16
Definition: Globals.h:114
NIBBLETYPE m_BlockMetas[SectionBlockCount/2]
Definition: ChunkData.h:30
UInt16 GetSectionBitmask() const
Returns a bitmask of chunk sections which are currently stored.
Definition: ChunkData.cpp:302
bool SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Nibble)
Definition: ChunkData.cpp:209
void Assign(const cChunkData &a_Other)
Copy assign from another cChunkData.
Definition: ChunkData.cpp:86
unsigned int UInt32
Definition: Globals.h:113
static const size_t NumSections
Definition: ChunkData.h:24
void FillSkyLight(NIBBLETYPE a_Value)
Fills the chunk with the specified sky light.
Definition: ChunkData.cpp:515
void SetMetas(const NIBBLETYPE *a_Src)
Copies the metadata from the specified flat array into the internal representation.
Definition: ChunkData.cpp:579
UInt32 NumPresentSections() const
Returns the number of sections present (i.e.
Definition: ChunkData.cpp:684
sChunkSection * m_Sections[NumSections]
Definition: ChunkData.h:120
NIBBLETYPE m_BlockLight[SectionBlockCount/2]
Definition: ChunkData.h:31
void Clear()
Clears all data.
Definition: ChunkData.cpp:317
static const int SectionHeight
Definition: ChunkData.h:23
NIBBLETYPE GetMeta(Vector3i a_RelPos) const
Definition: ChunkData.cpp:187