Fixes for style conformance

This commit is contained in:
matsukaze 2014-02-04 21:58:14 -05:00
parent 259b285841
commit ef3d795938
5 changed files with 324 additions and 369 deletions

View file

@ -9,31 +9,27 @@
#include "OctreeElement.h" #include "OctreeElement.h"
#include "PrimitiveRenderer.h" #include "PrimitiveRenderer.h"
Primitive::Primitive() Primitive::Primitive() {
{} }
Primitive::~Primitive() Primitive::~Primitive() {
{} }
// Simple dispatch between API and SPI // Simple dispatch between API and SPI
VertexElementList const & Primitive::vertexElements() const VertexElementList const & Primitive::vertexElements() const {
{
return vVertexElements(); return vVertexElements();
} }
VertexElementIndexList & Primitive::vertexElementIndices() VertexElementIndexList& Primitive::vertexElementIndices() {
{
return vVertexElementIndices(); return vVertexElementIndices();
} }
TriElementList & Primitive::triElements() TriElementList& Primitive::triElements() {
{
return vTriElements(); return vTriElements();
} }
void Primitive::releaseVertexElements() void Primitive::releaseVertexElements() {
{
vReleaseVertexElements(); vReleaseVertexElements();
} }
@ -47,13 +43,11 @@ Cube::Cube(
unsigned char g, unsigned char g,
unsigned char b, unsigned char b,
unsigned char faceExclusions unsigned char faceExclusions
) ) {
{
initialize(x, y, z, s, r, g, b, faceExclusions); initialize(x, y, z, s, r, g, b, faceExclusions);
} }
Cube::~Cube() Cube::~Cube() {
{
terminate(); terminate();
} }
@ -66,14 +60,14 @@ void Cube::initialize(
unsigned char g, unsigned char g,
unsigned char b, unsigned char b,
unsigned char faceExclusions unsigned char faceExclusions
) ) {
{
initializeVertices(x, y, z, s, r, g, b, faceExclusions); initializeVertices(x, y, z, s, r, g, b, faceExclusions);
initializeTris(faceExclusions); initializeTris(faceExclusions);
} }
void Cube::terminate() void Cube::terminate() {
{
terminateTris(); terminateTris();
terminateVertices(); terminateVertices();
} }
@ -87,27 +81,25 @@ void Cube::initializeVertices(
unsigned char g, unsigned char g,
unsigned char b, unsigned char b,
unsigned char faceExclusions unsigned char faceExclusions
) ) {
{
for (int i = 0; i < 24; i++) for (int i = 0; i < _sNumVerticesPerCube; i++) {
{
// Check whether the vertex is necessary for the faces indicated by faceExclusions bit mask. // Check whether the vertex is necessary for the faces indicated by faceExclusions bit mask.
if (~faceExclusions & s_faceIndexToHalfSpaceMask[i >> 2]) if (~faceExclusions & _sFaceIndexToHalfSpaceMask[i >> 2]) {
//if (~0x00 & s_faceIndexToHalfSpaceMask[i >> 2]) //if (~0x00 & _sFaceIndexToHalfSpaceMask[i >> 2]) {
//if (faceExclusions & s_faceIndexToHalfSpaceMask[i >> 2]) //if (faceExclusions & _sFaceIndexToHalfSpaceMask[i >> 2]) {
{
VertexElement *v = new VertexElement(); VertexElement* v = new VertexElement();
if (v) if (v) {
{
// Construct vertex position // Construct vertex position
v->position.x = x + s * s_vertexIndexToConstructionVector[i][0]; v->position.x = x + s * _sVertexIndexToConstructionVector[i][0];
v->position.y = y + s * s_vertexIndexToConstructionVector[i][1]; v->position.y = y + s * _sVertexIndexToConstructionVector[i][1];
v->position.z = z + s * s_vertexIndexToConstructionVector[i][2]; v->position.z = z + s * _sVertexIndexToConstructionVector[i][2];
// Construct vertex normal // Construct vertex normal
v->normal.x = s_vertexIndexToNormalVector[i >> 2][0]; v->normal.x = _sVertexIndexToNormalVector[i >> 2][0];
v->normal.y = s_vertexIndexToNormalVector[i >> 2][1]; v->normal.y = _sVertexIndexToNormalVector[i >> 2][1];
v->normal.z = s_vertexIndexToNormalVector[i >> 2][2]; v->normal.z = _sVertexIndexToNormalVector[i >> 2][2];
// Construct vertex color // Construct vertex color
//#define FALSE_COLOR //#define FALSE_COLOR
@ -138,13 +130,12 @@ void Cube::initializeVertices(
} }
} }
void Cube::terminateVertices() void Cube::terminateVertices() {
{
VertexElementList::iterator it = _vertices.begin(); VertexElementList::iterator it = _vertices.begin();
VertexElementList::iterator end = _vertices.end(); VertexElementList::iterator end = _vertices.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{
delete *it; delete *it;
} }
_vertices.clear(); _vertices.clear();
@ -152,17 +143,16 @@ void Cube::terminateVertices()
void Cube::initializeTris( void Cube::initializeTris(
unsigned char faceExclusions unsigned char faceExclusions
) ) {
{
int index = 0; int index = 0;
for (int i = 0; i < 6; i++) for (int i = 0; i < _sNumFacesPerCube; i++) {
{
// Check whether the vertex is necessary for the faces indicated by faceExclusions bit mask. // Check whether the vertex is necessary for the faces indicated by faceExclusions bit mask.
// uncomment this line to exclude shared faces: // uncomment this line to exclude shared faces:
if (~faceExclusions & s_faceIndexToHalfSpaceMask[i]) if (~faceExclusions & _sFaceIndexToHalfSpaceMask[i]) {
// uncomment this line to load all faces: if (~0x00 & s_faceIndexToHalfSpaceMask[i]) // uncomment this line to load all faces: if (~0x00 & _sFaceIndexToHalfSpaceMask[i]) {
// uncomment this line to include shared faces: if (faceExclusions & s_faceIndexToHalfSpaceMask[i]) // uncomment this line to include shared faces: if (faceExclusions & _sFaceIndexToHalfSpaceMask[i]) {
{
int start = index; int start = index;
// Create the triangulated face, two tris, six indices referencing four vertices, both // Create the triangulated face, two tris, six indices referencing four vertices, both
// with cw winding order, such that: // with cw winding order, such that:
@ -174,8 +164,7 @@ void Cube::initializeTris(
// Store triangle ABC // Store triangle ABC
TriElement *tri = new TriElement(); TriElement *tri = new TriElement();
if (tri) if (tri) {
{
tri->indices[0] = index++; tri->indices[0] = index++;
tri->indices[1] = index++; tri->indices[1] = index++;
tri->indices[2] = index; tri->indices[2] = index;
@ -186,8 +175,7 @@ void Cube::initializeTris(
// Now store triangle ACD // Now store triangle ACD
tri = new TriElement(); tri = new TriElement();
if (tri) if (tri) {
{
tri->indices[0] = start; tri->indices[0] = start;
tri->indices[1] = index++; tri->indices[1] = index++;
tri->indices[2] = index++; tri->indices[2] = index++;
@ -199,39 +187,34 @@ void Cube::initializeTris(
} }
} }
void Cube::terminateTris() void Cube::terminateTris() {
{
TriElementList::iterator it = _tris.begin(); TriElementList::iterator it = _tris.begin();
TriElementList::iterator end = _tris.end(); TriElementList::iterator end = _tris.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{
delete *it; delete *it;
} }
_tris.clear(); _tris.clear();
} }
VertexElementList const & Cube::vVertexElements() const VertexElementList const & Cube::vVertexElements() const {
{
return _vertices; return _vertices;
} }
VertexElementIndexList & Cube::vVertexElementIndices() VertexElementIndexList& Cube::vVertexElementIndices() {
{
return _vertexIndices; return _vertexIndices;
} }
TriElementList & Cube::vTriElements() TriElementList& Cube::vTriElements() {
{
return _tris; return _tris;
} }
void Cube::vReleaseVertexElements() void Cube::vReleaseVertexElements() {
{
terminateVertices(); terminateVertices();
} }
unsigned char Cube::s_faceIndexToHalfSpaceMask[6] = { unsigned char Cube::_sFaceIndexToHalfSpaceMask[6] = {
OctreeElement::HalfSpace::Bottom, OctreeElement::HalfSpace::Bottom,
OctreeElement::HalfSpace::Top, OctreeElement::HalfSpace::Top,
OctreeElement::HalfSpace::Right, OctreeElement::HalfSpace::Right,
@ -244,7 +227,7 @@ unsigned char Cube::s_faceIndexToHalfSpaceMask[6] = {
#ifdef CW_CONSTRUCTION #ifdef CW_CONSTRUCTION
// Construction vectors ordered such that the vertices of each face are // Construction vectors ordered such that the vertices of each face are
// CW in a right-handed coordinate system with B-L-N at 0,0,0. // CW in a right-handed coordinate system with B-L-N at 0,0,0.
float Cube::s_vertexIndexToConstructionVector[24][3] = { float Cube::_sVertexIndexToConstructionVector[24][3] = {
// Bottom // Bottom
{ 0,0,0 }, { 0,0,0 },
{ 1,0,0 }, { 1,0,0 },
@ -279,7 +262,7 @@ float Cube::s_vertexIndexToConstructionVector[24][3] = {
#else // CW_CONSTRUCTION #else // CW_CONSTRUCTION
// Construction vectors ordered such that the vertices of each face are // Construction vectors ordered such that the vertices of each face are
// CCW in a right-handed coordinate system with B-L-N at 0,0,0. // CCW in a right-handed coordinate system with B-L-N at 0,0,0.
float Cube::s_vertexIndexToConstructionVector[24][3] = { float Cube::_sVertexIndexToConstructionVector[24][3] = {
// Bottom // Bottom
{ 0,0,0 }, { 0,0,0 },
{ 0,0,1 }, { 0,0,1 },
@ -314,7 +297,7 @@ float Cube::s_vertexIndexToConstructionVector[24][3] = {
#endif #endif
// Normals for a right-handed coordinate system // Normals for a right-handed coordinate system
float Cube::s_vertexIndexToNormalVector[6][3] = { float Cube::_sVertexIndexToNormalVector[6][3] = {
{ 0,-1, 0 }, // Bottom { 0,-1, 0 }, // Bottom
{ 0, 1, 0 }, // Top { 0, 1, 0 }, // Top
{ 1, 0, 0 }, // Right { 1, 0, 0 }, // Right
@ -323,29 +306,26 @@ float Cube::s_vertexIndexToNormalVector[6][3] = {
{ 0, 0, 1 }, // Far { 0, 0, 1 }, // Far
}; };
Renderer::Renderer() Renderer::Renderer() {
{} }
Renderer::~Renderer() Renderer::~Renderer() {
{} }
// Simple dispatch between API and SPI // Simple dispatch between API and SPI
int Renderer::add( int Renderer::add(
Primitive *primitive Primitive* primitive
) ) {
{
return vAdd(primitive); return vAdd(primitive);
} }
void Renderer::remove( void Renderer::remove(
int id int id
) ) {
{
vRemove(id); vRemove(id);
} }
void Renderer::render() void Renderer::render() {
{
vRender(); vRender();
} }
@ -369,19 +349,19 @@ PrimitiveRenderer::PrimitiveRenderer(
initialize(); initialize();
} }
PrimitiveRenderer::~PrimitiveRenderer() PrimitiveRenderer::~PrimitiveRenderer() {
{
terminate(); terminate();
} }
void PrimitiveRenderer::initialize() void PrimitiveRenderer::initialize() {
{
initializeGL(); initializeGL();
initializeBookkeeping(); initializeBookkeeping();
} }
void PrimitiveRenderer::initializeGL() void PrimitiveRenderer::initializeGL() {
{
glGenBuffers(1, &_triBufferId); glGenBuffers(1, &_triBufferId);
glGenBuffers(1, &_vertexBufferId); glGenBuffers(1, &_vertexBufferId);
@ -417,51 +397,54 @@ void PrimitiveRenderer::initializeGL()
GLint err = glGetError(); GLint err = glGetError();
} }
void PrimitiveRenderer::initializeBookkeeping() void PrimitiveRenderer::initializeBookkeeping() {
{
// Start primitive count at one, because zero is reserved for the degenerate triangle
_primitiveCount = 1; _primitiveCount = 1;
_cpuMemoryUsage = sizeof(PrimitiveRenderer); _cpuMemoryUsage = sizeof(PrimitiveRenderer);
} }
void PrimitiveRenderer::terminate() void PrimitiveRenderer::terminate() {
{
terminateBookkeeping(); terminateBookkeeping();
terminateGL(); terminateGL();
} }
void PrimitiveRenderer::terminateGL() void PrimitiveRenderer::terminateGL() {
{
glDeleteBuffers(1, &_vertexBufferId); glDeleteBuffers(1, &_vertexBufferId);
glDeleteBuffers(1, &_triBufferId); glDeleteBuffers(1, &_triBufferId);
GLint err = glGetError(); GLint err = glGetError();
} }
void PrimitiveRenderer::terminateBookkeeping() void PrimitiveRenderer::terminateBookkeeping() {
{
// Drain all of the queues, stop updating the counters // Drain all of the queues, stop updating the counters
while (_availableVertexElementIndex.remove()); while (_availableVertexElementIndex.remove() != 0)
while (_availableTriElementIndex.remove()); ;
while (_deconstructTriElementIndex.remove());
while (_availableTriElementIndex.remove() != 0)
;
while (_deconstructTriElementIndex.remove() != 0)
;
std::map<int, Primitive *>::iterator it = _indexToPrimitiveMap.begin(); std::map<int, Primitive *>::iterator it = _indexToPrimitiveMap.begin();
std::map<int, Primitive *>::iterator end = _indexToPrimitiveMap.end(); std::map<int, Primitive *>::iterator end = _indexToPrimitiveMap.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{
Primitive *primitive = it->second; Primitive *primitive = it->second;
delete primitive; delete primitive;
} }
} }
int PrimitiveRenderer::vAdd( int PrimitiveRenderer::vAdd(
Primitive *primitive Primitive* primitive
) ) {
{
int index = getAvailablePrimitiveIndex(); int index = getAvailablePrimitiveIndex();
if (index != 0) if (index != 0) {
{ try {
try
{
// Take ownership of primitive, including responsibility // Take ownership of primitive, including responsibility
// for destruction // for destruction
_indexToPrimitiveMap[index] = primitive; _indexToPrimitiveMap[index] = primitive;
@ -469,9 +452,7 @@ int PrimitiveRenderer::vAdd(
// No need to keep an extra copy of the vertices // No need to keep an extra copy of the vertices
primitive->releaseVertexElements(); primitive->releaseVertexElements();
} } catch(...) {
catch(...)
{
// STL failed, recycle the index // STL failed, recycle the index
_availablePrimitiveIndex.add(index); _availablePrimitiveIndex.add(index);
index = 0; index = 0;
@ -482,17 +463,15 @@ int PrimitiveRenderer::vAdd(
void PrimitiveRenderer::vRemove( void PrimitiveRenderer::vRemove(
int index int index
) ) {
{
try try {
{
// Locate the primitive by id in the associative map // Locate the primitive by id in the associative map
std::map<int, Primitive *>::iterator it = _indexToPrimitiveMap.find(index); std::map<int, Primitive *>::iterator it = _indexToPrimitiveMap.find(index);
if (it != _indexToPrimitiveMap.end()) if (it != _indexToPrimitiveMap.end()) {
{
Primitive *primitive = it->second; Primitive *primitive = it->second;
if (primitive) if (primitive) {
{
_indexToPrimitiveMap[index] = 0; _indexToPrimitiveMap[index] = 0;
deconstructElements(primitive); deconstructElements(primitive);
_availablePrimitiveIndex.add(index); _availablePrimitiveIndex.add(index);
@ -501,31 +480,27 @@ void PrimitiveRenderer::vRemove(
// the index is going to be re-used, but if you want to... uncomment the following: // the index is going to be re-used, but if you want to... uncomment the following:
//_indexToPrimitiveMap.erase(it); //_indexToPrimitiveMap.erase(it);
} }
} } catch(...) {
catch(...)
{
// STL failed // STL failed
} }
} }
void PrimitiveRenderer::constructElements( void PrimitiveRenderer::constructElements(
Primitive *primitive Primitive* primitive
) ) {
{
// Load vertex elements // Load vertex elements
VertexElementIndexList & vertexElementIndexList = primitive->vertexElementIndices(); VertexElementIndexList& vertexElementIndexList = primitive->vertexElementIndices();
{ {
VertexElementList const & vertices = primitive->vertexElements(); VertexElementList const & vertices = primitive->vertexElements();
VertexElementList::const_iterator it = vertices.begin(); VertexElementList::const_iterator it = vertices.begin();
VertexElementList::const_iterator end = vertices.end(); VertexElementList::const_iterator end = vertices.end();
for ( ; it != end; ++it ) for ( ; it != end; ++it ) {
{
int index = getAvailableVertexElementIndex(); int index = getAvailableVertexElementIndex();
if (index != 0) if (index != 0) {
{
vertexElementIndexList.push_back(index); vertexElementIndexList.push_back(index);
VertexElement *vertex = *it; VertexElement* vertex = *it;
transferVertexElement(index, vertex); transferVertexElement(index, vertex);
} }
} }
@ -533,16 +508,14 @@ void PrimitiveRenderer::constructElements(
// Load tri elements // Load tri elements
{ {
TriElementList & tris = primitive->triElements(); TriElementList& tris = primitive->triElements();
TriElementList::iterator it = tris.begin(); TriElementList::iterator it = tris.begin();
TriElementList::iterator end = tris.end(); TriElementList::iterator end = tris.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{ TriElement* tri = *it;
TriElement *tri = *it;
int index = getAvailableTriElementIndex(); int index = getAvailableTriElementIndex();
if (index != 0) if (index != 0) {
{
int k; int k;
k = tri->indices[0]; k = tri->indices[0];
tri->indices[0] = vertexElementIndexList[k]; tri->indices[0] = vertexElementIndexList[k];
@ -561,18 +534,17 @@ void PrimitiveRenderer::constructElements(
} }
void PrimitiveRenderer::deconstructElements( void PrimitiveRenderer::deconstructElements(
Primitive *primitive Primitive* primitive
) ) {
{
// Schedule the tri elements of the face for deconstruction // Schedule the tri elements of the face for deconstruction
{ {
TriElementList & tris = primitive->triElements(); TriElementList& tris = primitive->triElements();
TriElementList::iterator it = tris.begin(); TriElementList::iterator it = tris.begin();
TriElementList::iterator end = tris.end(); TriElementList::iterator end = tris.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{ TriElement* tri = *it;
TriElement *tri = *it;
// Put the tri element index into decon queue // Put the tri element index into decon queue
_deconstructTriElementIndex.add(tri->id); _deconstructTriElementIndex.add(tri->id);
@ -581,12 +553,11 @@ void PrimitiveRenderer::deconstructElements(
// Return the vertex element index to the available queue, it is not necessary // Return the vertex element index to the available queue, it is not necessary
// to zero the data // to zero the data
{ {
VertexElementIndexList & vertexIndexList = primitive->vertexElementIndices(); VertexElementIndexList& vertexIndexList = primitive->vertexElementIndices();
VertexElementIndexList::iterator it = vertexIndexList.begin(); VertexElementIndexList::iterator it = vertexIndexList.begin();
VertexElementIndexList::iterator end = vertexIndexList.end(); VertexElementIndexList::iterator end = vertexIndexList.end();
for ( ; it != end; ++it) for ( ; it != end; ++it) {
{
int index = *it; int index = *it;
// Put the vertex element index into the available queue // Put the vertex element index into the available queue
@ -598,13 +569,12 @@ void PrimitiveRenderer::deconstructElements(
delete primitive; delete primitive;
} }
int PrimitiveRenderer::getAvailablePrimitiveIndex() int PrimitiveRenderer::getAvailablePrimitiveIndex() {
{
// Check the available primitive index queue first for an available index. // Check the available primitive index queue first for an available index.
int index = _availablePrimitiveIndex.remove(); int index = _availablePrimitiveIndex.remove();
// Remember that the primitive index 0 is used not used. // Remember that the primitive index 0 is used not used.
if (index == 0) if (index == 0) {
{
// There are no primitive indices available from the queue, // There are no primitive indices available from the queue,
// make one up // make one up
index = _primitiveCount++; index = _primitiveCount++;
@ -612,37 +582,36 @@ int PrimitiveRenderer::getAvailablePrimitiveIndex()
return index; return index;
} }
int PrimitiveRenderer::getAvailableVertexElementIndex() int PrimitiveRenderer::getAvailableVertexElementIndex() {
{
// Check the available vertex element queue first for an available index. // Check the available vertex element queue first for an available index.
int index = _availableVertexElementIndex.remove(); int index = _availableVertexElementIndex.remove();
// Remember that the vertex element 0 is used for degenerate triangles. // Remember that the vertex element 0 is used for degenerate triangles.
if (index == 0) if (index == 0) {
{
// There are no vertex elements available from the queue, // There are no vertex elements available from the queue,
// grab one from the end of the list // grab one from the end of the list
if (_vertexElementCount < _maxVertexElementCount) if (_vertexElementCount < _maxVertexElementCount) {
index = _vertexElementCount++; index = _vertexElementCount++;
}
} }
return index; return index;
} }
int PrimitiveRenderer::getAvailableTriElementIndex() int PrimitiveRenderer::getAvailableTriElementIndex() {
{
// Check the deconstruct tri element queue first for an available index. // Check the deconstruct tri element queue first for an available index.
int index = _deconstructTriElementIndex.remove(); int index = _deconstructTriElementIndex.remove();
// Remember that the tri element 0 is used for degenerate triangles. // Remember that the tri element 0 is used for degenerate triangles.
if (index == 0) if (index == 0) {
{
// There are no tri elements in the deconstruct tri element queue that are reusable. // There are no tri elements in the deconstruct tri element queue that are reusable.
// Check the available tri element queue. // Check the available tri element queue.
index = _availableTriElementIndex.remove(); index = _availableTriElementIndex.remove();
if (index == 0) if (index == 0) {
{
// There are no reusable tri elements available from any queue, // There are no reusable tri elements available from any queue,
// grab one from the end of the list // grab one from the end of the list
if (_triElementCount < _maxTriElementCount) if (_triElementCount < _maxTriElementCount) {
index = _triElementCount++; index = _triElementCount++;
}
} }
} }
return index; return index;
@ -650,8 +619,8 @@ int PrimitiveRenderer::getAvailableTriElementIndex()
void PrimitiveRenderer::deconstructTriElement( void PrimitiveRenderer::deconstructTriElement(
int idx int idx
) ) {
{
// Set the element to the degenerate case. // Set the element to the degenerate case.
int degenerate[3] = { 0, 0, 0 }; int degenerate[3] = { 0, 0, 0 };
transferTriElement(idx, degenerate); transferTriElement(idx, degenerate);
@ -660,9 +629,9 @@ void PrimitiveRenderer::deconstructTriElement(
void PrimitiveRenderer::transferVertexElement( void PrimitiveRenderer::transferVertexElement(
int idx, int idx,
VertexElement *vertex VertexElement* vertex
) ) {
{
glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferId); glBindBuffer(GL_ARRAY_BUFFER, _vertexBufferId);
glBufferSubData(GL_ARRAY_BUFFER, idx * sizeof(VertexElement), sizeof(VertexElement), vertex); glBufferSubData(GL_ARRAY_BUFFER, idx * sizeof(VertexElement), sizeof(VertexElement), vertex);
glBindBuffer(GL_ARRAY_BUFFER, 0); glBindBuffer(GL_ARRAY_BUFFER, 0);
@ -671,20 +640,19 @@ void PrimitiveRenderer::transferVertexElement(
void PrimitiveRenderer::transferTriElement( void PrimitiveRenderer::transferTriElement(
int idx, int idx,
int tri[3] int tri[3]
) ) {
{
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _triBufferId); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _triBufferId);
glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, idx * sizeof(GLint) * 3, sizeof(GLint) * 3, tri); glBufferSubData(GL_ELEMENT_ARRAY_BUFFER, idx * sizeof(GLint) * 3, sizeof(GLint) * 3, tri);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
} }
void PrimitiveRenderer::vRender() void PrimitiveRenderer::vRender() {
{
// Now would be an appropriate time to set the element array buffer ids // Now would be an appropriate time to set the element array buffer ids
// scheduled for deconstruction to the degenerate case. // scheduled for deconstruction to the degenerate case.
int id; int id;
while ((id = _deconstructTriElementIndex.remove())) while ((id = _deconstructTriElementIndex.remove()) != 0) {
{
deconstructTriElement(id); deconstructTriElement(id);
_availableTriElementIndex.add(id); _availableTriElementIndex.add(id);
} }

View file

@ -1,24 +1,23 @@
/** ///
* @file PrimitiveRenderer.h /// @file PrimitiveRenderer.h
* A geometric primitive renderer. /// A geometric primitive renderer.
* ///
* @author: Norman Crafts /// @author: Norman Crafts
* @copyright 2014, High Fidelity, Inc. All rights reserved. /// @copyright 2014, High Fidelity, Inc. All rights reserved.
*/ ///
#ifndef __interface__PrimitiveRenderer__ #ifndef __interface__PrimitiveRenderer__
#define __interface__PrimitiveRenderer__ #define __interface__PrimitiveRenderer__
#include <vector> #include <vector>
#include <Queue.h> #include "Queue.h"
/** Vertex element structure /// Vertex element structure.
* Using the array of structures approach to specifying /// Using the array of structures approach to specifying
* vertex data to GL cuts down on the calls to glBufferSubData /// vertex data to GL cuts down on the calls to glBufferSubData
*/ ///
typedef typedef
struct __VertexElement struct __VertexElement {
{
struct __position { struct __position {
float x; float x;
float y; float y;
@ -37,102 +36,98 @@ typedef
} color; } color;
} VertexElement; } VertexElement;
/** Triangle element index structure /// Triangle element index structure.
* Specify the vertex indices of the triangle and its element index. /// Specify the vertex indices of the triangle and its element index.
*/ ///
typedef typedef
struct __TriElement struct __TriElement {
{ int indices[3];
int indices[3]; int id;
int id;
} TriElement; } TriElement;
typedef std::vector<VertexElement *, std::allocator<VertexElement *> > VertexElementList; typedef std::vector<VertexElement *, std::allocator<VertexElement *> > VertexElementList;
typedef std::vector<int, std::allocator<int> > VertexElementIndexList; typedef std::vector<int, std::allocator<int> > VertexElementIndexList;
typedef std::vector<TriElement *, std::allocator<TriElement *> > TriElementList; typedef std::vector<TriElement *, std::allocator<TriElement *> > TriElementList;
/** ///
* @class Primitive /// @class Primitive
* Primitive Interface class /// Primitive Interface class.
* Abstract class for accessing vertex and tri elements of geometric primitives /// Abstract class for accessing vertex and tri elements of geometric primitives
* ///
*/ ///
class Primitive class Primitive {
{
public: public:
virtual ~Primitive(); virtual ~Primitive();
// API methods go here // API methods go here
/** Vertex element accessor /// Vertex element accessor.
* @return A list of vertex elements of the primitive /// @return A list of vertex elements of the primitive
*/ ///
VertexElementList const & vertexElements() const; VertexElementList const & vertexElements() const;
/** Vertex element index accessor /// Vertex element index accessor.
* @return A list of vertex element indices of the primitive /// @return A list of vertex element indices of the primitive
*/ ///
VertexElementIndexList & vertexElementIndices(); VertexElementIndexList& vertexElementIndices();
/** Tri element accessor /// Tri element accessor.
* @return A list of tri elements of the primitive /// @return A list of tri elements of the primitive
*/ ///
TriElementList & triElements(); TriElementList& triElements();
/** Release vertex elements /// Release vertex elements.
*/ ///
void releaseVertexElements(); void releaseVertexElements();
protected: protected:
/** Default constructor prohibited to API user, restricted to service implementer /// Default constructor prohibited to API user, restricted to service implementer.
*/ ///
Primitive(); Primitive();
private: private:
/** Copy constructor prohibited /// Copy constructor prohibited.
*/ ///
Primitive( Primitive(
Primitive const & prim Primitive const & prim
); );
// SPI methods are defined here // SPI methods are defined here
/** Vertex element accessor /// Vertex element accessor.
* Service implementer to provide private override for this method /// Service implementer to provide private override for this method
* in derived class /// in derived class
*/ ///
virtual VertexElementList const & vVertexElements() const = 0; virtual VertexElementList const & vVertexElements() const = 0;
/** Vertex element index accessor /// Vertex element index accessor.
* Service implementer to provide private override for this method /// Service implementer to provide private override for this method
* in derived class /// in derived class
*/ ///
virtual VertexElementIndexList & vVertexElementIndices() = 0; virtual VertexElementIndexList& vVertexElementIndices() = 0;
/** Tri element accessor /// Tri element accessor.
* Service implementer to provide private override for this method /// Service implementer to provide private override for this method
* in derived class /// in derived class
*/ ///
virtual TriElementList & vTriElements() = 0; virtual TriElementList& vTriElements() = 0;
/** Release vertex elements /// Release vertex elements.
*/ ///
virtual void vReleaseVertexElements() = 0; virtual void vReleaseVertexElements() = 0;
}; };
/** ///
* @class Cube /// @class Cube
* Class for accessing the vertex and tri elements of a cube /// Class for accessing the vertex and tri elements of a cube
*/ ///
class Cube: class Cube: public Primitive {
public Primitive
{
public: public:
/** Configuration dependency injection constructor /// Configuration dependency injection constructor.
*/ ///
Cube( Cube(
float x, float x,
float y, float y,
@ -147,8 +142,8 @@ public:
~Cube(); ~Cube();
private: private:
/** Copy constructor prohibited /// Copy constructor prohibited.
*/ ///
Cube ( Cube (
Cube const & cube Cube const & cube
); );
@ -188,8 +183,8 @@ private:
// SPI virtual override methods go here // SPI virtual override methods go here
VertexElementList const & vVertexElements() const; VertexElementList const & vVertexElements() const;
VertexElementIndexList & vVertexElementIndices(); VertexElementIndexList& vVertexElementIndices();
TriElementList & vTriElements(); TriElementList& vTriElements();
void vReleaseVertexElements(); void vReleaseVertexElements();
@ -198,91 +193,90 @@ private:
VertexElementIndexList _vertexIndices; ///< Vertex element index list VertexElementIndexList _vertexIndices; ///< Vertex element index list
TriElementList _tris; ///< Tri element list TriElementList _tris; ///< Tri element list
static unsigned char s_faceIndexToHalfSpaceMask[6]; static const int _sNumFacesPerCube = 6;
static float s_vertexIndexToConstructionVector[24][3]; static const int _sNumVerticesPerCube = 24;
static float s_vertexIndexToNormalVector[6][3]; static unsigned char _sFaceIndexToHalfSpaceMask[6];
static float _sVertexIndexToConstructionVector[24][3];
static float _sVertexIndexToNormalVector[6][3];
}; };
/** ///
* @class Renderer /// @class Renderer
* GL renderer interface class /// GL renderer interface class.
* Abstract class for rendering geometric primitives in GL /// Abstract class for rendering geometric primitives in GL
*/ ///
class Renderer class Renderer {
{
public: public:
virtual ~Renderer(); virtual ~Renderer();
// API methods go here // API methods go here
/** Add primitive to renderer database /// Add primitive to renderer database.
*/ ///
int add( int add(
Primitive *primitive ///< Pointer to primitive Primitive* primitive ///< Pointer to primitive
); );
/** Remove primitive from renderer database /// Remove primitive from renderer database.
*/ ///
void remove( void remove(
int id ///< Primitive id int id ///< Primitive id
); );
/** Render primitive database /// Render primitive database.
* The render method assumes appropriate GL context and state has /// The render method assumes appropriate GL context and state has
* already been provided for /// already been provided for
*/ ///
void render(); void render();
protected: protected:
/** Default constructor prohibited to API user, restricted to service implementer /// Default constructor prohibited to API user, restricted to service implementer.
*/ ///
Renderer(); Renderer();
private: private:
/** Copy constructor prohibited /// Copy constructor prohibited.
*/ ///
Renderer( Renderer(
Renderer const & primitive Renderer const & primitive
); );
// SPI methods are defined here // SPI methods are defined here
/** Add primitive to renderer database /// Add primitive to renderer database.
* Service implementer to provide private override for this method /// Service implementer to provide private override for this method
* in derived class /// in derived class
*/ ///
virtual int vAdd( virtual int vAdd(
Primitive *primitive ///< Pointer to primitive Primitive* primitive ///< Pointer to primitive
) = 0; ) = 0;
/** Remove primitive from renderer database /// Remove primitive from renderer database.
* Service implementer to provide private override for this method /// Service implementer to provide private override for this method
* in derived class /// in derived class
*/ ///
virtual void vRemove( virtual void vRemove(
int id ///< Primitive id int id ///< Primitive id
) = 0; ) = 0;
/** Render primitive database /// Render primitive database.
* Service implementer to provide private virtual override for this method /// Service implementer to provide private virtual override for this method
* in derived class /// in derived class
*/ ///
virtual void vRender() = 0; virtual void vRender() = 0;
}; };
/** ///
* @class PrimitiveRenderer /// @class PrimitiveRenderer
* Renderer implementation class for the rendering of geometric primitives /// Renderer implementation class for the rendering of geometric primitives
* using GL element array and GL array buffers /// using GL element array and GL array buffers
*/ ///
class PrimitiveRenderer : class PrimitiveRenderer : public Renderer {
public Renderer
{
public: public:
/** Configuration dependency injection constructor /// Configuration dependency injection constructor.
*/ ///
PrimitiveRenderer( PrimitiveRenderer(
int maxCount int maxCount
); );
@ -290,12 +284,12 @@ public:
~PrimitiveRenderer(); ~PrimitiveRenderer();
private: private:
/** Default constructor prohibited /// Default constructor prohibited.
*/ ///
PrimitiveRenderer(); PrimitiveRenderer();
/** Copy constructor prohibited /// Copy constructor prohibited.
*/ ///
PrimitiveRenderer( PrimitiveRenderer(
PrimitiveRenderer const & renderer PrimitiveRenderer const & renderer
); );
@ -303,84 +297,84 @@ private:
void initialize(); void initialize();
void terminate(); void terminate();
/** Allocate and initialize GL buffers /// Allocate and initialize GL buffers.
*/ ///
void initializeGL(); void initializeGL();
/** Terminate and deallocate GL buffers /// Terminate and deallocate GL buffers.
*/ ///
void terminateGL(); void terminateGL();
void initializeBookkeeping(); void initializeBookkeeping();
void terminateBookkeeping(); void terminateBookkeeping();
/** Construct the elements of the faces of the primitive /// Construct the elements of the faces of the primitive.
*/ ///
void constructElements( void constructElements(
Primitive *primitive Primitive* primitive
); );
/** Deconstruct the elements of the faces of the primitive /// Deconstruct the elements of the faces of the primitive.
*/ ///
void deconstructElements( void deconstructElements(
Primitive *primitive Primitive* primitive
); );
/** Deconstruct the triangle element from the GL buffer /// Deconstruct the triangle element from the GL buffer.
*/ ///
void deconstructTriElement( void deconstructTriElement(
int idx int idx
); );
/** Transfer the vertex element to the GL buffer /// Transfer the vertex element to the GL buffer.
*/ ///
void transferVertexElement( void transferVertexElement(
int idx, int idx,
VertexElement *vertex VertexElement *vertex
); );
/** Transfer the triangle element to the GL buffer /// Transfer the triangle element to the GL buffer.
*/ ///
void transferTriElement( void transferTriElement(
int idx, int idx,
int tri[3] int tri[3]
); );
/** Get available primitive index /// Get available primitive index.
* Get an available primitive index from either the recycling /// Get an available primitive index from either the recycling
* queue or incrementing the counter /// queue or incrementing the counter
*/ ///
int getAvailablePrimitiveIndex(); int getAvailablePrimitiveIndex();
/** Get available vertex element index /// Get available vertex element index.
* Get an available vertex element index from either the recycling /// Get an available vertex element index from either the recycling
* queue or incrementing the counter /// queue or incrementing the counter
*/ ///
int getAvailableVertexElementIndex(); int getAvailableVertexElementIndex();
/** Get available triangle element index /// Get available triangle element index.
* Get an available triangle element index from either the elements /// Get an available triangle element index from either the elements
* scheduled for deconstruction queue, the recycling /// scheduled for deconstruction queue, the recycling
* queue or incrementing the counter /// queue or incrementing the counter
*/ ///
int getAvailableTriElementIndex(); int getAvailableTriElementIndex();
// SPI virtual override methods go here // SPI virtual override methods go here
/** Add primitive to renderer database /// Add primitive to renderer database.
*/ ///
int vAdd( int vAdd(
Primitive *primitive Primitive* primitive
); );
/** Remove primitive from renderer database /// Remove primitive from renderer database.
*/ ///
void vRemove( void vRemove(
int id int id
); );
/** Render triangle database /// Render triangle database.
*/ ///
void vRender(); void vRender();
private: private:
@ -400,7 +394,7 @@ private:
int _triElementCount; ///< Count of triangles int _triElementCount; ///< Count of triangles
int _maxTriElementCount; ///< Max count of triangles int _maxTriElementCount; ///< Max count of triangles
std::map<int, Primitive *> _indexToPrimitiveMap; ///< Associative map between index and primitive std::map<int, Primitive*> _indexToPrimitiveMap; ///< Associative map between index and primitive
int _primitiveCount; ///< Count of primitives int _primitiveCount; ///< Count of primitives
Queue<int> _availablePrimitiveIndex; ///< Queue of primitive indices available Queue<int> _availablePrimitiveIndex; ///< Queue of primitive indices available

View file

@ -1050,15 +1050,13 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo
if (primitiveIndex) { if (primitiveIndex) {
_renderer->remove(primitiveIndex); _renderer->remove(primitiveIndex);
node->setPrimitiveIndex(0); node->setPrimitiveIndex(0);
} } else {
else {
node->setVoxelSystem(this); node->setVoxelSystem(this);
} }
inspectForInteriorOcclusionsOperation(node, 0); inspectForInteriorOcclusionsOperation(node, 0);
if (node->getInteriorOcclusions() != OctreeElement::HalfSpace::All) if (node->getInteriorOcclusions() != OctreeElement::HalfSpace::All) {
{ Cube* cube = new Cube(
Cube *cube = new Cube(
startVertex.x, startVertex.y, startVertex.z, voxelScale, startVertex.x, startVertex.y, startVertex.z, voxelScale,
color[RED_INDEX], color[GREEN_INDEX], color[BLUE_INDEX], color[RED_INDEX], color[GREEN_INDEX], color[BLUE_INDEX],
node->getInteriorOcclusions()); node->getInteriorOcclusions());
@ -1067,8 +1065,7 @@ int VoxelSystem::updateNodeInArrays(VoxelTreeElement* node, bool reuseIndex, boo
node->setPrimitiveIndex(primitiveIndex); node->setPrimitiveIndex(primitiveIndex);
} }
} }
} } else {
else {
glBufferIndex nodeIndex = GLBUFFER_INDEX_UNKNOWN; glBufferIndex nodeIndex = GLBUFFER_INDEX_UNKNOWN;
if (reuseIndex && node->isKnownBufferIndex()) { if (reuseIndex && node->isKnownBufferIndex()) {
nodeIndex = node->getBufferIndex(); nodeIndex = node->getBufferIndex();
@ -1531,12 +1528,12 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element,
} }
// Bit mask of occluded shared faces indexed by child // Bit mask of occluded shared faces indexed by child
unsigned char occludedSharedFace[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; unsigned char occludedSharedFace[NUMBER_OF_CHILDREN] = { 0, 0, 0, 0, 0, 0, 0, 0 };
// Traverse all pair combinations of children // Traverse all pair combinations of children
for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) { for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) {
VoxelTreeElement *childA = voxel->getChildAtIndex(i); VoxelTreeElement* childA = voxel->getChildAtIndex(i);
if (childA) { if (childA) {
// Get the child A's occluding faces, for a leaf that will be // Get the child A's occluding faces, for a leaf that will be
@ -1551,7 +1548,7 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element,
for (int j = i; --j >= 0; ) { for (int j = i; --j >= 0; ) {
VoxelTreeElement *childB = voxel->getChildAtIndex(j); VoxelTreeElement* childB = voxel->getChildAtIndex(j);
if (childB) { if (childB) {
// Get child B's occluding faces // Get child B's occluding faces
@ -1564,22 +1561,22 @@ bool VoxelSystem::inspectForInteriorOcclusionsOperation(OctreeElement* element,
// Determine the shared halfspace partition between siblings A and B, // Determine the shared halfspace partition between siblings A and B,
// i.e., near/far, left/right, or top/bottom // i.e., near/far, left/right, or top/bottom
unsigned char partition = octantIndexToSharedBitMask[i][j] & unsigned char partition = _sOctantIndexToSharedBitMask[i][j] &
exteriorOcclusionsA & exteriorOcclusionsB; exteriorOcclusionsA & exteriorOcclusionsB;
// Determine which face of each sibling is occluded. // Determine which face of each sibling is occluded.
// Note the intentionally crossed indicies. It is necessary because // Note the intentionally crossed indicies. It is necessary because
// the octantIndexToBitMask is a partition occupancy mask. For // the _sOctantIndexToBitMask is a partition occupancy mask. For
// example, if the near-left-top (NLT) and near-left-bottom (NLB) child voxels // example, if the near-left-top (NLT) and near-left-bottom (NLB) child voxels
// exist, the shared partition is top-bottom (TB), and thus the occluded // exist, the shared partition is top-bottom (TB), and thus the occluded
// shared face of the NLT voxel is its bottom face. // shared face of the NLT voxel is its bottom face.
occludedSharedFace[i] |= (partition & octantIndexToBitMask[j]); occludedSharedFace[i] |= (partition & _sOctantIndexToBitMask[j]);
occludedSharedFace[j] |= (partition & octantIndexToBitMask[i]); occludedSharedFace[j] |= (partition & _sOctantIndexToBitMask[i]);
} }
} }
// Combine this voxel's interior excluded shared face only to those children which are coincident // Combine this voxel's interior excluded shared face only to those children which are coincident
// with the excluded face. // with the excluded face.
occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & octantIndexToBitMask[i]); occludedSharedFace[i] |= (voxel->getInteriorOcclusions() & _sOctantIndexToBitMask[i]);
// Inform the child // Inform the child
childA->setInteriorOcclusions(occludedSharedFace[i]); childA->setInteriorOcclusions(occludedSharedFace[i]);
@ -1610,13 +1607,13 @@ bool VoxelSystem::inspectForExteriorOcclusionsOperation(OctreeElement* element,
// Traverse all children // Traverse all children
for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) { for (int i = NUMBER_OF_CHILDREN; --i >= 0; ) {
VoxelTreeElement *child = voxel->getChildAtIndex(i); VoxelTreeElement* child = voxel->getChildAtIndex(i);
if (child) { if (child) {
// Get the child's occluding faces, for a leaf, that will be // Get the child's occluding faces, for a leaf, that will be
// all six voxel faces, and for a non leaf, that will be // all six voxel faces, and for a non leaf, that will be
// all faces which are completely covered by four child octants. // all faces which are completely covered by four child octants.
unsigned char exteriorOcclusionsOfChild = child->getExteriorOcclusions(); unsigned char exteriorOcclusionsOfChild = child->getExteriorOcclusions();
exteriorOcclusionsOfChild &= octantIndexToBitMask[i]; exteriorOcclusionsOfChild &= _sOctantIndexToBitMask[i];
for (int j = 6; --j >= 0; ) { for (int j = 6; --j >= 0; ) {
@ -1656,9 +1653,7 @@ bool VoxelSystem::inspectForExteriorOcclusionsOperation(OctreeElement* element,
// occupied. Hence, the subtree from this node could be // occupied. Hence, the subtree from this node could be
// pruned and replaced by a leaf voxel, if the visible // pruned and replaced by a leaf voxel, if the visible
// properties of the children are the same // properties of the children are the same
} } else if (exteriorOcclusions) {
else
if (exteriorOcclusions) {
//const glm::vec3& v = voxel->getCorner(); //const glm::vec3& v = voxel->getCorner();
//float s = voxel->getScale(); //float s = voxel->getScale();
@ -1682,8 +1677,7 @@ bool VoxelSystem::clearOcclusionsOperation(OctreeElement* element, void* extraDa
// And the sibling occluders // And the sibling occluders
voxel->setInteriorOcclusions(0); voxel->setInteriorOcclusions(0);
rc = false; rc = false;
} } else {
else {
voxel->setExteriorOcclusions(0); voxel->setExteriorOcclusions(0);
voxel->setInteriorOcclusions(0); voxel->setInteriorOcclusions(0);
rc = true; rc = true;
@ -1711,8 +1705,7 @@ void VoxelSystem::cullSharedFaces() {
_tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation); _tree->recurseTreeWithOperation(inspectForInteriorOcclusionsOperation);
unlockTree(); unlockTree();
qDebug("culling shared faces in %d nodes", _nodeCount); qDebug("culling shared faces in %d nodes", _nodeCount);
} } else {
else {
cleanupVoxelMemory(); cleanupVoxelMemory();
_usePrimitiveRenderer = false; _usePrimitiveRenderer = false;
initVoxelMemory(); initVoxelMemory();
@ -3112,7 +3105,7 @@ void VoxelSystem::beginLoadingLocalVoxelCache() {
// Octant bitmask array indexed by octant. The mask value indicates the octant's halfspace partitioning. The index // Octant bitmask array indexed by octant. The mask value indicates the octant's halfspace partitioning. The index
// value corresponds to the voxel's octal code derived in "pointToVoxel" in SharedUtil.cpp, which, BTW, does *not* // value corresponds to the voxel's octal code derived in "pointToVoxel" in SharedUtil.cpp, which, BTW, does *not*
// correspond to the "ChildIndex" enum value in OctreeElement.h // correspond to the "ChildIndex" enum value in OctreeElement.h
unsigned char VoxelSystem::octantIndexToBitMask[8] = { unsigned char VoxelSystem::_sOctantIndexToBitMask[8] = {
OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near, OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near,
OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Far, OctreeElement::HalfSpace::Bottom | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Far,
OctreeElement::HalfSpace::Top | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near, OctreeElement::HalfSpace::Top | OctreeElement::HalfSpace::Left | OctreeElement::HalfSpace::Near,
@ -3125,7 +3118,7 @@ unsigned char VoxelSystem::octantIndexToBitMask[8] = {
// Two dimensional array map indexed by octant row and column. The mask value // Two dimensional array map indexed by octant row and column. The mask value
// indicates the two faces shared by the octants // indicates the two faces shared by the octants
unsigned char VoxelSystem::octantIndexToSharedBitMask[8][8] = { unsigned char VoxelSystem::_sOctantIndexToSharedBitMask[8][8] = {
{ // Index 0: Bottom-Left-Near { // Index 0: Bottom-Left-Near
0, // Bottom-Left-Near 0, // Bottom-Left-Near
OctreeElement::HalfSpace::Near | OctreeElement::HalfSpace::Far, // Bottom-Left-Far OctreeElement::HalfSpace::Near | OctreeElement::HalfSpace::Far, // Bottom-Left-Far

View file

@ -315,11 +315,11 @@ private:
void lockTree(); void lockTree();
void unlockTree(); void unlockTree();
bool _usePrimitiveRenderer; bool _usePrimitiveRenderer; ///< Flag primitive renderer for use
PrimitiveRenderer *_renderer; ///< Voxel renderer PrimitiveRenderer* _renderer; ///< Voxel renderer
static unsigned char octantIndexToBitMask[8]; ///< Map octant index to partition mask static unsigned char _sOctantIndexToBitMask[8]; ///< Map octant index to partition mask
static unsigned char octantIndexToSharedBitMask[8][8]; ///< Map octant indices to shared partition mask static unsigned char _sOctantIndexToSharedBitMask[8][8]; ///< Map octant indices to shared partition mask
}; };

View file

@ -99,8 +99,8 @@ protected:
private: private:
int _primitiveIndex; int _primitiveIndex;
unsigned char _exteriorOcclusions; ///< exterior shared partition boundaries that are completely occupied unsigned char _exteriorOcclusions; /// exterior shared partition boundaries that are completely occupied
unsigned char _interiorOcclusions; ///< interior shared partition boundaries with siblings unsigned char _interiorOcclusions; /// interior shared partition boundaries with siblings
}; };
inline void VoxelTreeElement::setExteriorOcclusions(unsigned char exteriorOcclusions) { inline void VoxelTreeElement::setExteriorOcclusions(unsigned char exteriorOcclusions) {