PolyVox
0.3.0-dev
Open source voxel management library
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
PolyVoxCore
include
PolyVoxCore
Impl
Block.h
Go to the documentation of this file.
1
/*******************************************************************************
2
Copyright (c) 2005-2009 David Williams
3
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
7
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
11
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
17
2. Altered source versions must be plainly marked as such, and must not be
18
misrepresented as being the original software.
19
20
3. This notice may not be removed or altered from any source
21
distribution.
22
*******************************************************************************/
23
24
#ifndef __PolyVox_Block_H__
25
#define __PolyVox_Block_H__
26
27
#include "
PolyVoxCore/Impl/TypeDef.h
"
28
29
#include "
PolyVoxCore/PolyVoxForwardDeclarations.h
"
30
#include "
PolyVoxCore/Vector.h
"
31
32
#include <limits>
33
#include <vector>
34
35
namespace
PolyVox
36
{
37
template
<
typename
VoxelType>
38
class
Block
39
{
40
template
<
typename
LengthType>
41
struct
RunlengthEntry
42
{
43
LengthType length;
44
VoxelType
value;
45
46
//We can parametise the length on anything up to uint32_t.
47
//This lets us experiment with the optimal size in the future.
48
static
uint32_t
maxRunlength(
void
) {
return
(std::numeric_limits<LengthType>::max)();}
49
};
50
51
public
:
52
Block
(
uint16_t
uSideLength = 0);
53
54
uint16_t
getSideLength
(
void
)
const
;
55
VoxelType
getVoxelAt
(
uint16_t
uXPos,
uint16_t
uYPos,
uint16_t
uZPos)
const
;
56
VoxelType
getVoxelAt
(
const
Vector3DUint16
& v3dPos)
const
;
57
58
void
setVoxelAt
(
uint16_t
uXPos,
uint16_t
uYPos,
uint16_t
uZPos,
VoxelType
tValue);
59
void
setVoxelAt
(
const
Vector3DUint16
& v3dPos,
VoxelType
tValue);
60
61
void
initialise
(
uint16_t
uSideLength);
62
uint32_t
calculateSizeInBytes
(
void
);
63
64
public
:
65
void
compress
(
Compressor
* pCompressor);
66
void
uncompress
(
Compressor
* pCompressor);
67
68
uint8_t
*
m_pCompressedData
;
69
uint32_t
m_uCompressedDataLength
;
70
VoxelType
*
m_tUncompressedData
;
71
uint16_t
m_uSideLength
;
72
uint8_t
m_uSideLengthPower
;
73
bool
m_bIsCompressed
;
74
bool
m_bIsUncompressedDataModified
;
75
};
76
}
77
78
#include "
PolyVoxCore/Impl/Block.inl
"
79
80
#endif
Generated by
1.8.2