mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:48:44 +02:00
Merge branch 'master' of https://github.com/worklist/hifi
This commit is contained in:
commit
0816bdcd4a
5 changed files with 72 additions and 20 deletions
|
@ -1576,6 +1576,8 @@ void Application::init() {
|
||||||
|
|
||||||
// Set up VoxelSystem after loading preferences so we can get the desired max voxel count
|
// Set up VoxelSystem after loading preferences so we can get the desired max voxel count
|
||||||
_voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels());
|
_voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels());
|
||||||
|
_voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader));
|
||||||
|
_voxels.setUseByteNormals(Menu::getInstance()->isOptionChecked(MenuOption::UseByteNormals));
|
||||||
_voxels.init();
|
_voxels.init();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -253,6 +253,9 @@ Menu::Menu() :
|
||||||
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
|
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
|
||||||
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0,
|
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0,
|
||||||
false, this, SLOT(switchVoxelShader()));
|
false, this, SLOT(switchVoxelShader()));
|
||||||
|
|
||||||
|
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseByteNormals, 0,
|
||||||
|
false, Application::getInstance()->getVoxels(), SLOT(setUseByteNormals(bool)));
|
||||||
|
|
||||||
QMenu* avatarOptionsMenu = developerMenu->addMenu("Avatar Options");
|
QMenu* avatarOptionsMenu = developerMenu->addMenu("Avatar Options");
|
||||||
|
|
||||||
|
|
|
@ -204,6 +204,7 @@ namespace MenuOption {
|
||||||
const QString UsePerlinFace = "Use Perlin's Face";
|
const QString UsePerlinFace = "Use Perlin's Face";
|
||||||
const QString Quit = "Quit";
|
const QString Quit = "Quit";
|
||||||
const QString UseVoxelShader = "Use Voxel Shader";
|
const QString UseVoxelShader = "Use Voxel Shader";
|
||||||
|
const QString UseByteNormals = "Use Byte Normals";
|
||||||
const QString Voxels = "Voxels";
|
const QString Voxels = "Voxels";
|
||||||
const QString VoxelAddMode = "Add Voxel Mode";
|
const QString VoxelAddMode = "Add Voxel Mode";
|
||||||
const QString VoxelColorMode = "Color Voxel Mode";
|
const QString VoxelColorMode = "Color Voxel Mode";
|
||||||
|
|
|
@ -37,7 +37,7 @@ float identityVertices[] = { 0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,
|
||||||
0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1,
|
0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1,
|
||||||
0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1 };
|
0,0,0, 1,0,0, 1,1,0, 0,1,0, 0,0,1, 1,0,1, 1,1,1, 0,1,1 };
|
||||||
|
|
||||||
GLfloat identityNormals[] = { 0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1,
|
GLbyte identityNormals[] = { 0,0,-1, 0,0,-1, 0,0,-1, 0,0,-1,
|
||||||
0,0,+1, 0,0,+1, 0,0,+1, 0,0,+1,
|
0,0,+1, 0,0,+1, 0,0,+1, 0,0,+1,
|
||||||
0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
|
0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
|
||||||
0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
|
0,-1,0, 0,-1,0, 0,+1,0, 0,+1,0,
|
||||||
|
@ -75,7 +75,9 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
|
||||||
connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
|
connect(_tree, SIGNAL(importSize(float,float,float)), SIGNAL(importSize(float,float,float)));
|
||||||
connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
|
connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
|
||||||
|
|
||||||
_useVoxelShader = false;
|
_useVoxelShader = false;
|
||||||
|
_useByteNormals = false;
|
||||||
|
|
||||||
_writeVoxelShaderData = NULL;
|
_writeVoxelShaderData = NULL;
|
||||||
_readVoxelShaderData = NULL;
|
_readVoxelShaderData = NULL;
|
||||||
|
|
||||||
|
@ -139,6 +141,20 @@ VoxelSystem::~VoxelSystem() {
|
||||||
VoxelNode::removeDeleteHook(this);
|
VoxelNode::removeDeleteHook(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VoxelSystem::setUseByteNormals(bool useByteNormals) {
|
||||||
|
pthread_mutex_lock(&_bufferWriteLock);
|
||||||
|
bool wasInitialized = _initialized;
|
||||||
|
if (wasInitialized) {
|
||||||
|
cleanupVoxelMemory();
|
||||||
|
}
|
||||||
|
_useByteNormals = useByteNormals;
|
||||||
|
if (wasInitialized) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&_bufferWriteLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void VoxelSystem::setMaxVoxels(int maxVoxels) {
|
void VoxelSystem::setMaxVoxels(int maxVoxels) {
|
||||||
pthread_mutex_lock(&_bufferWriteLock);
|
pthread_mutex_lock(&_bufferWriteLock);
|
||||||
bool wasInitialized = _initialized;
|
bool wasInitialized = _initialized;
|
||||||
|
@ -194,6 +210,7 @@ void VoxelSystem::cleanupVoxelMemory() {
|
||||||
|
|
||||||
void VoxelSystem::initVoxelMemory() {
|
void VoxelSystem::initVoxelMemory() {
|
||||||
if (_useVoxelShader) {
|
if (_useVoxelShader) {
|
||||||
|
qDebug("Using Voxel Shader...\n");
|
||||||
GLuint* indicesArray = new GLuint[_maxVoxels];
|
GLuint* indicesArray = new GLuint[_maxVoxels];
|
||||||
|
|
||||||
// populate the indicesArray
|
// populate the indicesArray
|
||||||
|
@ -241,27 +258,55 @@ void VoxelSystem::initVoxelMemory() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GLfloat* normalsArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * _maxVoxels];
|
if (_useByteNormals) {
|
||||||
GLfloat* normalsArrayEndPointer = normalsArray;
|
qDebug("Using Byte Normals...\n");
|
||||||
|
GLbyte* normalsArray = new GLbyte[VERTEX_POINTS_PER_VOXEL * _maxVoxels];
|
||||||
|
GLbyte* normalsArrayEndPointer = normalsArray;
|
||||||
|
|
||||||
// populate the normalsArray
|
// populate the normalsArray
|
||||||
for (int n = 0; n < _maxVoxels; n++) {
|
for (int n = 0; n < _maxVoxels; n++) {
|
||||||
for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) {
|
for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) {
|
||||||
*(normalsArrayEndPointer++) = identityNormals[i];
|
*(normalsArrayEndPointer++) = identityNormals[i];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VBO for the normalsArray
|
||||||
|
glGenBuffers(1, &_vboNormalsID);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
|
VERTEX_POINTS_PER_VOXEL * sizeof(GLbyte) * _maxVoxels,
|
||||||
|
normalsArray, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
// delete the indices and normals arrays that are no longer needed
|
||||||
|
delete[] normalsArray;
|
||||||
|
} else {
|
||||||
|
qDebug("Using Float Normals...\n");
|
||||||
|
GLfloat* normalsArray = new GLfloat[VERTEX_POINTS_PER_VOXEL * _maxVoxels];
|
||||||
|
GLfloat* normalsArrayEndPointer = normalsArray;
|
||||||
|
|
||||||
|
// populate the normalsArray
|
||||||
|
for (int n = 0; n < _maxVoxels; n++) {
|
||||||
|
for (int i = 0; i < VERTEX_POINTS_PER_VOXEL; i++) {
|
||||||
|
*(normalsArrayEndPointer++) = identityNormals[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// VBO for the normalsArray
|
||||||
|
glGenBuffers(1, &_vboNormalsID);
|
||||||
|
glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID);
|
||||||
|
glBufferData(GL_ARRAY_BUFFER,
|
||||||
|
VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels,
|
||||||
|
normalsArray, GL_STATIC_DRAW);
|
||||||
|
|
||||||
|
// delete the indices and normals arrays that are no longer needed
|
||||||
|
delete[] normalsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
glGenBuffers(1, &_vboVerticesID);
|
glGenBuffers(1, &_vboVerticesID);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vboVerticesID);
|
glBindBuffer(GL_ARRAY_BUFFER, _vboVerticesID);
|
||||||
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels, NULL, GL_DYNAMIC_DRAW);
|
glBufferData(GL_ARRAY_BUFFER, VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels, NULL, GL_DYNAMIC_DRAW);
|
||||||
|
|
||||||
// VBO for the normalsArray
|
|
||||||
glGenBuffers(1, &_vboNormalsID);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER,
|
|
||||||
VERTEX_POINTS_PER_VOXEL * sizeof(GLfloat) * _maxVoxels,
|
|
||||||
normalsArray, GL_STATIC_DRAW);
|
|
||||||
|
|
||||||
// VBO for colorsArray
|
// VBO for colorsArray
|
||||||
glGenBuffers(1, &_vboColorsID);
|
glGenBuffers(1, &_vboColorsID);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID);
|
glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID);
|
||||||
|
@ -276,7 +321,6 @@ void VoxelSystem::initVoxelMemory() {
|
||||||
|
|
||||||
// delete the indices and normals arrays that are no longer needed
|
// delete the indices and normals arrays that are no longer needed
|
||||||
delete[] indicesArray;
|
delete[] indicesArray;
|
||||||
delete[] normalsArray;
|
|
||||||
|
|
||||||
|
|
||||||
// we will track individual dirty sections with these arrays of bools
|
// we will track individual dirty sections with these arrays of bools
|
||||||
|
@ -890,7 +934,7 @@ void VoxelSystem::render(bool texture) {
|
||||||
glVertexPointer(3, GL_FLOAT, 0, 0);
|
glVertexPointer(3, GL_FLOAT, 0, 0);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID);
|
glBindBuffer(GL_ARRAY_BUFFER, _vboNormalsID);
|
||||||
glNormalPointer(GL_FLOAT, 0, 0);
|
glNormalPointer((_useByteNormals ? GL_BYTE : GL_FLOAT), 0, 0);
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID);
|
glBindBuffer(GL_ARRAY_BUFFER, _vboColorsID);
|
||||||
glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
|
glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
|
||||||
|
@ -1769,7 +1813,7 @@ void VoxelSystem::falseColorizeOccludedV2() {
|
||||||
void VoxelSystem::nodeAdded(Node* node) {
|
void VoxelSystem::nodeAdded(Node* node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
uint16_t nodeID = node->getNodeID();
|
uint16_t nodeID = node->getNodeID();
|
||||||
printf("VoxelSystem... voxel server %u added...\n", nodeID);
|
qDebug("VoxelSystem... voxel server %u added...\n", nodeID);
|
||||||
_voxelServerCount++;
|
_voxelServerCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1792,7 +1836,7 @@ void VoxelSystem::nodeKilled(Node* node) {
|
||||||
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
if (node->getType() == NODE_TYPE_VOXEL_SERVER) {
|
||||||
_voxelServerCount--;
|
_voxelServerCount--;
|
||||||
uint16_t nodeID = node->getNodeID();
|
uint16_t nodeID = node->getNodeID();
|
||||||
printf("VoxelSystem... voxel server %u removed...\n", nodeID);
|
qDebug("VoxelSystem... voxel server %u removed...\n", nodeID);
|
||||||
|
|
||||||
if (_voxelServerCount > 0) {
|
if (_voxelServerCount > 0) {
|
||||||
// Kill any voxels from the local tree that match this nodeID
|
// Kill any voxels from the local tree that match this nodeID
|
||||||
|
|
|
@ -128,6 +128,7 @@ public slots:
|
||||||
void falseColorizeBySource();
|
void falseColorizeBySource();
|
||||||
|
|
||||||
void cancelImport();
|
void cancelImport();
|
||||||
|
void setUseByteNormals(bool useByteNormals);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float _treeScale;
|
float _treeScale;
|
||||||
|
@ -203,10 +204,11 @@ private:
|
||||||
uint64_t _lastViewCulling;
|
uint64_t _lastViewCulling;
|
||||||
int _lastViewCullingElapsed;
|
int _lastViewCullingElapsed;
|
||||||
|
|
||||||
bool getUseVoxelShader();
|
|
||||||
void initVoxelMemory();
|
void initVoxelMemory();
|
||||||
void cleanupVoxelMemory();
|
void cleanupVoxelMemory();
|
||||||
|
|
||||||
|
bool _useByteNormals;
|
||||||
|
|
||||||
bool _useVoxelShader;
|
bool _useVoxelShader;
|
||||||
GLuint _vboVoxelsID; /// when using voxel shader, we'll use this VBO
|
GLuint _vboVoxelsID; /// when using voxel shader, we'll use this VBO
|
||||||
GLuint _vboVoxelsIndicesID; /// when using voxel shader, we'll use this VBO for our indexes
|
GLuint _vboVoxelsIndicesID; /// when using voxel shader, we'll use this VBO for our indexes
|
||||||
|
|
Loading…
Reference in a new issue