3
0
Fork 0
mirror of https://github.com/lubosz/overte.git synced 2025-04-26 11:55:31 +02:00

Merge branch 'master' of github.com:worklist/hifi into assignment

This commit is contained in:
Stephen Birarda 2013-10-08 09:59:52 -07:00
commit 76cecb43cf
17 changed files with 360 additions and 116 deletions

View file

@ -594,8 +594,12 @@ void* animateVoxels(void* args) {
timeval lastSendTime;
bool firstTime = true;
while (true) {
gettimeofday(&lastSendTime, NULL);
int packetsStarting = ::voxelEditPacketSender->packetsToSendCount();
// some animations
//sendVoxelBlinkMessage();
@ -619,12 +623,22 @@ void* animateVoxels(void* args) {
if (::buildStreet) {
doBuildStreet();
}
::voxelEditPacketSender->releaseQueuedMessages();
int packetsEnding = ::voxelEditPacketSender->packetsToSendCount();
if (::voxelEditPacketSender) {
::voxelEditPacketSender->releaseQueuedMessages();
if (::nonThreadedPacketSender) {
::voxelEditPacketSender->process();
}
if (firstTime) {
int packetsPerSecond = (packetsEnding - packetsStarting) * (ACTUAL_FPS);
std::cout << "Setting PPS to " << packetsPerSecond << "\n";
::voxelEditPacketSender->setPacketsPerSecond(packetsPerSecond);
firstTime = false;
}
if (::nonThreadedPacketSender) {
::voxelEditPacketSender->process();
}
uint64_t end = usecTimestampNow();
@ -715,14 +729,13 @@ int main(int argc, const char * argv[])
// Create out VoxelEditPacketSender
::voxelEditPacketSender = new VoxelEditPacketSender;
if (::voxelEditPacketSender) {
::voxelEditPacketSender->initialize(!::nonThreadedPacketSender);
if (::jurisdictionListener) {
::voxelEditPacketSender->setVoxelServerJurisdictions(::jurisdictionListener->getJurisdictions());
}
if (::nonThreadedPacketSender) {
::voxelEditPacketSender->setProcessCallIntervalHint(ANIMATE_VOXELS_INTERVAL_USECS);
}
::voxelEditPacketSender->initialize(!::nonThreadedPacketSender);
if (::jurisdictionListener) {
::voxelEditPacketSender->setVoxelServerJurisdictions(::jurisdictionListener->getJurisdictions());
}
if (::nonThreadedPacketSender) {
::voxelEditPacketSender->setProcessCallIntervalHint(ANIMATE_VOXELS_INTERVAL_USECS);
}
srand((unsigned)time(0));

View file

@ -324,6 +324,8 @@ void Application::initializeGL() {
}
void Application::paintGL() {
PerformanceWarning::setSuppressShortTimings(Menu::getInstance()->isOptionChecked(MenuOption::SuppressShortTimings));
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::paintGL()");
PerfStat("display");
glEnable(GL_LINE_SMOOTH);
@ -1181,6 +1183,7 @@ void Application::idle() {
double timeSinceLastUpdate = diffclock(&_lastTimeUpdated, &check);
if (timeSinceLastUpdate > IDLE_SIMULATE_MSECS) {
const float BIGGEST_DELTA_TIME_SECS = 0.25f;
update(glm::clamp((float)timeSinceLastUpdate / 1000.f, 0.f, BIGGEST_DELTA_TIME_SECS));
_glWidget->updateGL();
@ -1586,6 +1589,7 @@ void Application::init() {
// Set up VoxelSystem after loading preferences so we can get the desired max voxel count
_voxels.setMaxVoxels(Menu::getInstance()->getMaxVoxels());
_voxels.setUseVoxelShader(Menu::getInstance()->isOptionChecked(MenuOption::UseVoxelShader));
_voxels.setVoxelsAsPoints(Menu::getInstance()->isOptionChecked(MenuOption::VoxelsAsPoints));
_voxels.setUseFastVoxelPipeline(Menu::getInstance()->isOptionChecked(MenuOption::FastVoxelPipeline));
_voxels.init();
@ -2379,6 +2383,7 @@ void Application::computeOffAxisFrustum(float& left, float& right, float& bottom
}
void Application::displaySide(Camera& whichCamera) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displaySide()");
// transform by eye offset
// flip x if in mirror mode (also requires reversing winding order for backface culling)
@ -2410,6 +2415,8 @@ void Application::displaySide(Camera& whichCamera) {
setupWorldLight(whichCamera);
if (Menu::getInstance()->isOptionChecked(MenuOption::Stars)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... stars...");
if (!_stars.getFileLoaded()) {
_stars.readInput(STAR_FILE, STAR_CACHE_FILE, 0);
}
@ -2435,6 +2442,8 @@ void Application::displaySide(Camera& whichCamera) {
// draw the sky dome
if (Menu::getInstance()->isOptionChecked(MenuOption::Atmosphere)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... atmosphere...");
_environment.renderAtmospheres(whichCamera);
}
@ -2457,6 +2466,9 @@ void Application::displaySide(Camera& whichCamera) {
//draw a grid ground plane....
if (Menu::getInstance()->isOptionChecked(MenuOption::GroundPlane)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... ground plane...");
// draw grass plane with fog
glEnable(GL_FOG);
glEnable(GL_NORMALIZE);
@ -2480,7 +2492,11 @@ void Application::displaySide(Camera& whichCamera) {
}
// Draw voxels
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
_voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxels...");
if (!Menu::getInstance()->isOptionChecked(MenuOption::DontRenderVoxels)) {
_voxels.render(Menu::getInstance()->isOptionChecked(MenuOption::VoxelTextures));
}
}
// restore default, white specular
@ -2488,6 +2504,9 @@ void Application::displaySide(Camera& whichCamera) {
// indicate what we'll be adding/removing in mouse mode, if anything
if (_mouseVoxel.s != 0) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxels TOOLS UX...");
glDisable(GL_LIGHTING);
glPushMatrix();
glScalef(TREE_SCALE, TREE_SCALE, TREE_SCALE);
@ -2533,6 +2552,9 @@ void Application::displaySide(Camera& whichCamera) {
}
if (Menu::getInstance()->isOptionChecked(MenuOption::VoxelSelectMode) && _pasteMode) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... PASTE Preview...");
glPushMatrix();
glTranslatef(_mouseVoxel.x * TREE_SCALE,
_mouseVoxel.y * TREE_SCALE,
@ -2548,6 +2570,10 @@ void Application::displaySide(Camera& whichCamera) {
_myAvatar.renderScreenTint(SCREEN_TINT_BEFORE_AVATARS, whichCamera);
if (Menu::getInstance()->isOptionChecked(MenuOption::Avatars)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... Avatars...");
// Render avatars of other nodes
NodeList* nodeList = NodeList::getInstance();
@ -2592,16 +2618,22 @@ void Application::displaySide(Camera& whichCamera) {
// render the ambient occlusion effect if enabled
if (Menu::getInstance()->isOptionChecked(MenuOption::AmbientOcclusion)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... AmbientOcclusion...");
_ambientOcclusionEffect.render();
}
// brad's frustum for debugging
if (Menu::getInstance()->isOptionChecked(MenuOption::DisplayFrustum)) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... renderViewFrustum...");
renderViewFrustum(_viewFrustum);
}
// render voxel fades if they exist
if (_voxelFades.size() > 0) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... voxel fades...");
for(std::vector<VoxelFade>::iterator fade = _voxelFades.begin(); fade != _voxelFades.end();) {
fade->render();
if(fade->isDone()) {
@ -2611,11 +2643,18 @@ void Application::displaySide(Camera& whichCamera) {
}
}
}
renderFollowIndicator();
{
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... renderFollowIndicator...");
renderFollowIndicator();
}
// render transmitter pick ray, if non-empty
if (_transmitterPickStart != _transmitterPickEnd) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"Application::displaySide() ... transmitter pick ray...");
Glower glower;
const float TRANSMITTER_PICK_COLOR[] = { 1.0f, 1.0f, 0.0f };
glColor3fv(TRANSMITTER_PICK_COLOR);
@ -2637,6 +2676,8 @@ void Application::displaySide(Camera& whichCamera) {
}
void Application::displayOverlay() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "Application::displayOverlay()");
// Render 2D overlay: I/O level bar graphs and text
glMatrixMode(GL_PROJECTION);
glPushMatrix();

View file

@ -239,12 +239,19 @@ Menu::Menu() :
true,
appInstance,
SLOT(setRenderVoxels(bool)));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0,
false, this, SLOT(switchVoxelShader()));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontRenderVoxels);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::DontCallOpenGLForVoxels);
_useVoxelShader = addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::UseVoxelShader, 0,
false, appInstance->getVoxels(), SLOT(setUseVoxelShader(bool)));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelsAsPoints, 0,
false, appInstance->getVoxels(), SLOT(setVoxelsAsPoints(bool)));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::FastVoxelPipeline, 0,
false, appInstance->getVoxels(), SLOT(setUseFastVoxelPipeline(bool)));
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::VoxelTextures);
addCheckableActionToQMenuAndActionHash(voxelOptionsMenu, MenuOption::AmbientOcclusion);
QMenu* avatarOptionsMenu = developerMenu->addMenu("Avatar Options");
@ -346,6 +353,7 @@ Menu::Menu() :
QMenu* renderDebugMenu = developerMenu->addMenu("Render Debugging Tools");
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings);
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings);
addActionToQMenuAndActionHash(renderDebugMenu,
MenuOption::KillLocalVoxels,
@ -1003,7 +1011,4 @@ void Menu::updateFrustumRenderModeAction() {
}
}
void Menu::switchVoxelShader() {
Application::getInstance()->getVoxels()->setUseVoxelShader(isOptionChecked(MenuOption::UseVoxelShader));
}

View file

@ -54,6 +54,7 @@ public:
ViewFrustumOffset getViewFrustumOffset() const { return _viewFrustumOffset; }
VoxelStatsDialog* getVoxelStatsDialog() const { return _voxelStatsDialog; }
int getMaxVoxels() const { return _maxVoxels; }
QAction* getUseVoxelShader() const { return _useVoxelShader; }
void handleViewFrustumOffsetKeyModifier(int key);
@ -78,7 +79,6 @@ private slots:
void chooseVoxelPaintColor();
void runTests();
void resetSwatchColors();
void switchVoxelShader();
private:
static Menu* _instance;
@ -116,6 +116,7 @@ private:
QActionGroup* _voxelModeActionsGroup;
VoxelStatsDialog* _voxelStatsDialog;
int _maxVoxels;
QAction* _useVoxelShader;
};
namespace MenuOption {
@ -138,6 +139,8 @@ namespace MenuOption {
const QString DestructiveAddVoxel = "Create Voxel is Destructive";
const QString DeltaSending = "Delta Sending";
const QString DisplayFrustum = "Display Frustum";
const QString DontRenderVoxels = "Don't call _voxels.render()";
const QString DontCallOpenGLForVoxels = "Don't call glDrawElements()/glDrawRangeElementsEXT() for Voxels";
const QString EchoAudio = "Echo Audio";
const QString ExportVoxels = "Export Voxels";
const QString HeadMouse = "Head Mouse";
@ -193,6 +196,7 @@ namespace MenuOption {
const QString ShowTrueColors = "Show TRUE Colors";
const QString SimulateLeapHand = "Simulate Leap Hand";
const QString SkeletonTracking = "Skeleton Tracking";
const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
const QString LEDTracking = "LED Tracking";
const QString Stars = "Stars";
const QString Stats = "Stats";
@ -203,8 +207,7 @@ namespace MenuOption {
const QString UsePerlinFace = "Use Perlin's Face";
const QString Quit = "Quit";
const QString UseVoxelShader = "Use Voxel Shader";
const QString UseByteNormals = "Use Byte Normals";
const QString UseGlobalNormals = "Use Global Normals";
const QString VoxelsAsPoints = "Draw Voxels as Points";
const QString Voxels = "Voxels";
const QString VoxelAddMode = "Add Voxel Mode";
const QString VoxelColorMode = "Color Voxel Mode";

View file

@ -47,15 +47,14 @@ void VoxelPacketProcessor::processPacket(sockaddr& senderAddress, unsigned char*
if (Menu::getInstance()->isOptionChecked(MenuOption::Voxels)) {
Node* voxelServer = NodeList::getInstance()->nodeWithAddress(&senderAddress);
if (voxelServer && socketMatch(voxelServer->getActiveSocket(), &senderAddress)) {
voxelServer->lock();
int nodeID = voxelServer->getNodeID();
if (packetData[0] == PACKET_TYPE_ENVIRONMENT_DATA) {
app->_environment.parseData(&senderAddress, packetData, messageLength);
} else {
app->_voxels.setDataSourceID(voxelServer->getNodeID());
app->_voxels.setDataSourceID(nodeID);
app->_voxels.parseData(packetData, messageLength);
app->_voxels.setDataSourceID(UNKNOWN_NODE_ID);
}
voxelServer->unlock();
}
}
}

View file

@ -90,6 +90,8 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
connect(_tree, SIGNAL(importProgress(int)), SIGNAL(importProgress(int)));
_useVoxelShader = false;
_voxelsAsPoints = false;
_voxelShaderModeWhenVoxelsAsPointsEnabled = false;
_writeVoxelShaderData = NULL;
_readVoxelShaderData = NULL;
@ -191,6 +193,8 @@ void VoxelSystem::freeBufferIndex(glBufferIndex index) {
// This will run through the list of _freeIndexes and reset their VBO array values to be "invisible".
void VoxelSystem::clearFreeBufferIndexes() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "###### clearFreeBufferIndexes()");
for (int i = 0; i < _freeIndexes.size(); i++) {
glBufferIndex nodeIndex = _freeIndexes[i];
glm::vec3 startVertex(FLT_MAX, FLT_MAX, FLT_MAX);
@ -217,7 +221,6 @@ void VoxelSystem::setMaxVoxels(int maxVoxels) {
if (maxVoxels == _maxVoxels) {
return;
}
pthread_mutex_lock(&_bufferWriteLock);
bool wasInitialized = _initialized;
if (wasInitialized) {
clearAllNodesBufferIndex();
@ -225,9 +228,8 @@ void VoxelSystem::setMaxVoxels(int maxVoxels) {
}
_maxVoxels = maxVoxels;
if (wasInitialized) {
init();
initVoxelMemory();
}
pthread_mutex_unlock(&_bufferWriteLock);
if (wasInitialized) {
forceRedrawEntireTree();
}
@ -238,7 +240,6 @@ void VoxelSystem::setUseVoxelShader(bool useVoxelShader) {
return;
}
pthread_mutex_lock(&_bufferWriteLock);
bool wasInitialized = _initialized;
if (wasInitialized) {
clearAllNodesBufferIndex();
@ -246,17 +247,59 @@ void VoxelSystem::setUseVoxelShader(bool useVoxelShader) {
}
_useVoxelShader = useVoxelShader;
if (wasInitialized) {
init();
initVoxelMemory();
}
pthread_mutex_unlock(&_bufferWriteLock);
if (wasInitialized) {
forceRedrawEntireTree();
}
}
void VoxelSystem::setVoxelsAsPoints(bool voxelsAsPoints) {
if (_voxelsAsPoints == voxelsAsPoints) {
return;
}
bool wasInitialized = _initialized;
// If we're "turning on" Voxels as points, we need to double check that we're in voxel shader mode.
// Voxels as points uses the VoxelShader memory model, so if we're not in voxel shader mode,
// then set it to voxel shader mode.
if (voxelsAsPoints) {
Menu::getInstance()->getUseVoxelShader()->setEnabled(false);
// If enabling this... then do it before checking voxel shader status, that way, if voxel
// shader is already enabled, we just start drawing as points.
_voxelsAsPoints = true;
if (!_useVoxelShader) {
setUseVoxelShader(true);
_voxelShaderModeWhenVoxelsAsPointsEnabled = false;
} else {
_voxelShaderModeWhenVoxelsAsPointsEnabled = true;
}
} else {
Menu::getInstance()->getUseVoxelShader()->setEnabled(true);
// if we're turning OFF voxels as point mode, then we check what the state of voxel shader was when we enabled
// voxels as points, if it was OFF, then we return it to that value.
if (_voxelShaderModeWhenVoxelsAsPointsEnabled == false) {
setUseVoxelShader(false);
}
// If disabling this... then do it AFTER checking previous voxel shader status, that way, if voxel
// shader is was not enabled, we switch back to normal mode before turning off points.
_voxelsAsPoints = false;
}
// Set our voxels as points
if (wasInitialized) {
forceRedrawEntireTree();
}
}
void VoxelSystem::cleanupVoxelMemory() {
if (_initialized) {
pthread_mutex_lock(&_bufferWriteLock);
_initialized = false; // no longer initialized
if (_useVoxelShader) {
// these are used when in VoxelShader mode.
glDeleteBuffers(1, &_vboVoxelsID);
@ -264,6 +307,9 @@ void VoxelSystem::cleanupVoxelMemory() {
delete[] _writeVoxelShaderData;
delete[] _readVoxelShaderData;
_writeVoxelShaderData = _readVoxelShaderData = NULL;
} else {
// Destroy glBuffers
glDeleteBuffers(1, &_vboVerticesID);
@ -280,11 +326,18 @@ void VoxelSystem::cleanupVoxelMemory() {
delete[] _writeVerticesArray;
delete[] _readColorsArray;
delete[] _writeColorsArray;
_readVerticesArray = NULL;
_writeVerticesArray = NULL;
_readColorsArray = NULL;
_writeColorsArray = NULL;
}
delete[] _writeVoxelDirtyArray;
delete[] _readVoxelDirtyArray;
_writeVoxelDirtyArray = _readVoxelDirtyArray = NULL;
pthread_mutex_unlock(&_bufferWriteLock);
}
_initialized = false; // no longer initialized
}
void VoxelSystem::setupFaceIndices(GLuint& faceVBOID, GLubyte faceIdentityIndices[]) {
@ -316,11 +369,11 @@ void VoxelSystem::setupFaceIndices(GLuint& faceVBOID, GLubyte faceIdentityIndice
}
void VoxelSystem::initVoxelMemory() {
_initialMemoryUsageGPU = getFreeMemoryGPU();
pthread_mutex_lock(&_bufferWriteLock);
_memoryUsageRAM = 0;
_memoryUsageVBO = 0; // our VBO allocations as we know them
if (_useVoxelShader) {
qDebug("Using Voxel Shader...\n");
GLuint* indicesArray = new GLuint[_maxVoxels];
// populate the indicesArray
@ -416,6 +469,10 @@ void VoxelSystem::initVoxelMemory() {
_perlinModulateProgram.release();
}
}
_initialized = true;
pthread_mutex_unlock(&_bufferWriteLock);
}
void VoxelSystem::loadVoxelsFile(const char* fileName, bool wantColorRandomizer) {
@ -481,15 +538,15 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
int numBytesPacketHeader = numBytesForPacketHeader(sourceBuffer);
unsigned char* voxelData = sourceBuffer + numBytesPacketHeader;
pthread_mutex_lock(&_treeLock);
switch(command) {
case PACKET_TYPE_VOXEL_DATA: {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"readBitstreamToTree()");
// ask the VoxelTree to read the bitstream into the tree
ReadBitstreamToTreeParams args(WANT_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
pthread_mutex_lock(&_treeLock);
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
pthread_mutex_unlock(&_treeLock);
}
break;
case PACKET_TYPE_VOXEL_DATA_MONOCHROME: {
@ -497,7 +554,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
"readBitstreamToTree()");
// ask the VoxelTree to read the MONOCHROME bitstream into the tree
ReadBitstreamToTreeParams args(NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceID());
pthread_mutex_lock(&_treeLock);
_tree->readBitstreamToTree(voxelData, numBytes - numBytesPacketHeader, args);
pthread_mutex_unlock(&_treeLock);
}
break;
case PACKET_TYPE_Z_COMMAND:
@ -515,7 +574,9 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
while (totalLength <= numBytes) {
if (0==strcmp(command,(char*)"erase all")) {
qDebug("got Z message == erase all\n");
pthread_mutex_lock(&_treeLock);
_tree->eraseAllVoxels();
pthread_mutex_unlock(&_treeLock);
_voxelsInReadArrays = _voxelsInWriteArrays = 0; // better way to do this??
}
if (0==strcmp(command,(char*)"add scene")) {
@ -533,8 +594,6 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
setupNewVoxelsForDrawingSingleNode(DONT_BAIL_EARLY);
}
pthread_mutex_unlock(&_treeLock);
Application::getInstance()->getBandwidthMeter()->inputStream(BandwidthMeter::VOXELS).updateValue(numBytes);
return numBytes;
@ -542,7 +601,12 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
void VoxelSystem::setupNewVoxelsForDrawing() {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"setupNewVoxelsForDrawing()"); // would like to include _voxelsInArrays, _voxelsUpdated
"setupNewVoxelsForDrawing()");
if (!_initialized) {
return; // bail early if we're not initialized
}
uint64_t start = usecTimestampNow();
uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
@ -606,7 +670,7 @@ void VoxelSystem::setupNewVoxelsForDrawing() {
void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"setupNewVoxelsForDrawingSingleNode()"); // would like to include _voxelsInArrays, _voxelsUpdated
"setupNewVoxelsForDrawingSingleNode() xxxxx");
uint64_t start = usecTimestampNow();
uint64_t sinceLastTime = (start - _setupNewVoxelsForDrawingLastFinished) / 1000;
@ -623,7 +687,11 @@ void VoxelSystem::setupNewVoxelsForDrawingSingleNode(bool allowBailEarly) {
checkForCulling(); // check for out of view and deleted voxels...
// lock on the buffer write lock so we can't modify the data when the GPU is reading it
pthread_mutex_lock(&_bufferWriteLock);
{
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"setupNewVoxelsForDrawingSingleNode()... pthread_mutex_lock(&_bufferWriteLock);");
pthread_mutex_lock(&_bufferWriteLock);
}
_voxelsDirty = true; // if we got this far, then we can assume some voxels are dirty
@ -951,14 +1019,13 @@ void VoxelSystem::init() {
_setupNewVoxelsForDrawingLastElapsed = 0;
_lastViewCullingElapsed = _lastViewCulling = 0;
// When we change voxels representations in the arrays, we'll update this
_voxelsDirty = false;
_voxelsInWriteArrays = 0;
_voxelsInReadArrays = 0;
// VBO for the verticesArray
_initialMemoryUsageGPU = getFreeMemoryGPU();
initVoxelMemory();
_initialized = true;
// our own _removedVoxels doesn't need to be notified of voxel deletes
VoxelNode::removeDeleteHook(&_removedVoxels);
@ -1065,14 +1132,14 @@ void VoxelSystem::render(bool texture) {
return;
}
// get the lock so that the update thread won't change anything
pthread_mutex_lock(&_bufferWriteLock);
updateVBOs();
if (_useVoxelShader) {
Application::getInstance()->getVoxelShader().begin();
bool dontCallOpenGLDraw = Menu::getInstance()->isOptionChecked(MenuOption::DontCallOpenGLForVoxels);
// if not don't... then do...
if (_useVoxelShader) {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
"render().. _useVoxelShader openGL..");
//Define this somewhere in your header file
#define BUFFER_OFFSET(i) ((void*)(i))
@ -1080,14 +1147,29 @@ void VoxelSystem::render(bool texture) {
glBindBuffer(GL_ARRAY_BUFFER, _vboVoxelsID);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(VoxelShaderVBOData), BUFFER_OFFSET(0)); //The starting point of the VBO, for the vertices
int loc = Application::getInstance()->getVoxelShader().attributeLocation("voxelSizeIn");
glEnableVertexAttribArray(loc);
glVertexAttribPointer(loc, 1, GL_FLOAT, false, sizeof(VoxelShaderVBOData), BUFFER_OFFSET(3*sizeof(float)));
int attributeLocation;
if (!_voxelsAsPoints) {
Application::getInstance()->getVoxelShader().begin();
attributeLocation = Application::getInstance()->getVoxelShader().attributeLocation("voxelSizeIn");
glEnableVertexAttribArray(attributeLocation);
glVertexAttribPointer(attributeLocation, 1, GL_FLOAT, false, sizeof(VoxelShaderVBOData), BUFFER_OFFSET(3*sizeof(float)));
} else {
const float POINT_SIZE = 4.0;
glPointSize(POINT_SIZE);
}
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(3, GL_UNSIGNED_BYTE, sizeof(VoxelShaderVBOData), BUFFER_OFFSET(4*sizeof(float)));//The starting point of colors
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboVoxelsIndicesID);
glDrawElements(GL_POINTS, _voxelsInReadArrays, GL_UNSIGNED_INT, BUFFER_OFFSET(0)); //The starting point of the IBO
if (!dontCallOpenGLDraw) {
glDrawElements(GL_POINTS, _voxelsInReadArrays, GL_UNSIGNED_INT, BUFFER_OFFSET(0)); //The starting point of the IBO
}
// deactivate vertex and color arrays after drawing
glDisableClientState(GL_VERTEX_ARRAY);
@ -1097,9 +1179,13 @@ void VoxelSystem::render(bool texture) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
Application::getInstance()->getVoxelShader().end();
if (!_voxelsAsPoints) {
Application::getInstance()->getVoxelShader().end();
glDisableVertexAttribArray(attributeLocation);
}
} else {
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "render().. openGL...");
// tell OpenGL where to find vertex and color information
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
@ -1111,47 +1197,48 @@ void VoxelSystem::render(bool texture) {
glColorPointer(3, GL_UNSIGNED_BYTE, 0, 0);
applyScaleAndBindProgram(texture);
// for performance, enable backface culling
glEnable(GL_CULL_FACE);
// draw voxels in 6 passes
glNormal3f(0,1.0f,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesTop);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
if (!dontCallOpenGLDraw) {
glNormal3f(0,1.0f,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesTop);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,-1.0f,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBottom);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,-1.0f,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBottom);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(-1.0f,0,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesLeft);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(-1.0f,0,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesLeft);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(1.0f,0,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesRight);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(1.0f,0,0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesRight);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,0,-1.0f);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesFront);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,0,1.0f);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBack);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,0,-1.0f);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesFront);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
glNormal3f(0,0,1.0f);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _vboIndicesBack);
glDrawRangeElementsEXT(GL_TRIANGLES, 0, INDICES_PER_FACE * _voxelsInReadArrays - 1,
INDICES_PER_FACE * _voxelsInReadArrays, GL_UNSIGNED_INT, 0);
}
glDisable(GL_CULL_FACE);
removeScaleAndReleaseProgram(texture);
// deactivate vertex and color arrays after drawing
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
@ -1160,8 +1247,6 @@ void VoxelSystem::render(bool texture) {
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
}
pthread_mutex_unlock(&_bufferWriteLock);
}
void VoxelSystem::applyScaleAndBindProgram(bool texture) {
@ -1416,7 +1501,7 @@ void VoxelSystem::falseColorizeDistanceFromView() {
class removeOutOfViewArgs {
public:
VoxelSystem* thisVoxelSystem;
ViewFrustum* thisViewFrustum;
ViewFrustum thisViewFrustum;
VoxelNodeBag dontRecurseBag;
unsigned long nodesScanned;
unsigned long nodesRemoved;
@ -1426,14 +1511,20 @@ public:
removeOutOfViewArgs(VoxelSystem* voxelSystem) :
thisVoxelSystem(voxelSystem),
thisViewFrustum(voxelSystem->getViewFrustum()),
thisViewFrustum(*voxelSystem->getViewFrustum()),
dontRecurseBag(),
nodesScanned(0),
nodesRemoved(0),
nodesInside(0),
nodesIntersect(0),
nodesOutside(0)
{ }
{
// Widen the FOV for trimming
float originalFOV = thisViewFrustum.getFieldOfView();
float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND;
thisViewFrustum.setFieldOfView(wideFOV);
thisViewFrustum.calculate();
}
};
void VoxelSystem::cancelImport() {
@ -1459,7 +1550,7 @@ bool VoxelSystem::removeOutOfViewOperation(VoxelNode* node, void* extraData) {
for (int i = 0; i < NUMBER_OF_CHILDREN; i++) {
VoxelNode* childNode = node->getChildAtIndex(i);
if (childNode) {
ViewFrustum::location inFrustum = childNode->inFrustum(*args->thisViewFrustum);
ViewFrustum::location inFrustum = childNode->inFrustum(args->thisViewFrustum);
switch (inFrustum) {
case ViewFrustum::OUTSIDE: {
args->nodesOutside++;
@ -1731,13 +1822,13 @@ VoxelNode* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
void VoxelSystem::createVoxel(float x, float y, float z, float s,
unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
pthread_mutex_lock(&_treeLock);
//qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s);
pthread_mutex_lock(&_treeLock);
_tree->createVoxel(x, y, z, s, red, green, blue, destructive);
setupNewVoxelsForDrawing();
pthread_mutex_unlock(&_treeLock);
setupNewVoxelsForDrawing();
};
void VoxelSystem::createLine(glm::vec3 point1, glm::vec3 point2, float unitSize, rgbColor color, bool destructive) {

View file

@ -65,8 +65,6 @@ public:
bool readFromSquareARGB32Pixels(const char* filename);
bool readFromSchematicFile(const char* filename);
void setUseVoxelShader(bool useVoxelShader);
void setMaxVoxels(int maxVoxels);
long int getMaxVoxels() const { return _maxVoxels; }
unsigned long getVoxelMemoryUsageRAM() const { return _memoryUsageRAM; }
@ -137,6 +135,8 @@ public slots:
void cancelImport();
void setUseFastVoxelPipeline(bool useFastVoxelPipeline);
void setUseVoxelShader(bool useVoxelShader);
void setVoxelsAsPoints(bool voxelsAsPoints);
protected:
float _treeScale;
@ -224,6 +224,9 @@ private:
void cleanupVoxelMemory();
bool _useVoxelShader;
bool _voxelsAsPoints;
bool _voxelShaderModeWhenVoxelsAsPointsEnabled;
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
VoxelShaderVBOData* _writeVoxelShaderData;

View file

@ -88,8 +88,7 @@ bool BlendFace::render(float alpha) {
// enable normalization under the expectation that the GPU can do it faster
glEnable(GL_NORMALIZE);
glEnable(GL_TEXTURE_2D);
glColor4f(_owningHead->getSkinColor().r, _owningHead->getSkinColor().g, _owningHead->getSkinColor().b, alpha);
glDisable(GL_COLOR_MATERIAL);
for (int i = 0; i < networkMeshes.size(); i++) {
const NetworkMesh& networkMesh = networkMeshes.at(i);
@ -118,12 +117,15 @@ bool BlendFace::render(float alpha) {
}
}
glMultMatrixf((const GLfloat*)&mesh.transform);
// apply material properties
glm::vec4 diffuse = glm::vec4(mesh.diffuseColor, alpha);
glm::vec4 specular = glm::vec4(mesh.specularColor, alpha);
glMaterialfv(GL_FRONT, GL_AMBIENT, (const float*)&diffuse);
glMaterialfv(GL_FRONT, GL_DIFFUSE, (const float*)&diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, (const float*)&specular);
glMaterialf(GL_FRONT, GL_SHININESS, mesh.shininess);
// all meshes after the first are white
if (i == 1) {
glColor4f(1.0f, 1.0f, 1.0f, alpha);
}
glMultMatrixf((const GLfloat*)&mesh.transform);
glBindTexture(GL_TEXTURE_2D, texture == NULL ? 0 : texture->getID());
@ -191,6 +193,9 @@ bool BlendFace::render(float alpha) {
glPopMatrix();
// restore all the default material settings
Application::getInstance()->setupWorldLight(*Application::getInstance()->getCamera());
return true;
}

View file

@ -313,6 +313,9 @@ void Head::render(float alpha, bool isMine) {
}
void Head::setScale (float scale) {
if (_scale == scale) {
return;
}
_scale = scale;
createMohawk();

View file

@ -346,6 +346,13 @@ void printNode(const FBXNode& node, int indent) {
}
}
class Material {
public:
glm::vec3 diffuse;
glm::vec3 specular;
float shininess;
};
FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping) {
QHash<qint64, FBXMesh> meshes;
QVector<ExtractedBlendshape> blendshapes;
@ -354,6 +361,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
QHash<qint64, Transform> localTransforms;
QHash<qint64, glm::mat4> transformLinkMatrices;
QHash<qint64, QByteArray> textureFilenames;
QHash<qint64, Material> materials;
QHash<qint64, qint64> diffuseTextures;
QHash<qint64, qint64> bumpTextures;
@ -374,6 +382,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
}
QList<QVariant> mappings = blendshapeMappings.values(blendshapeName);
if (mappings.isEmpty()) {
blendshapeIndices.insert(blendshapeName, QPair<int, float>(i, 1.0f));
blendshapeIndices.insert("ExpressionBlendshapes." + blendshapeName, QPair<int, float>(i, 1.0f));
} else {
foreach (const QVariant& mapping, mappings) {
@ -394,6 +403,7 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
QVector<int> polygonIndices;
QVector<glm::vec3> normals;
QVector<int> normalIndices;
QVector<glm::vec2> texCoords;
QVector<int> texCoordIndices;
foreach (const FBXNode& data, object.children) {
@ -409,6 +419,9 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
if (subdata.name == "Normals") {
normals = createVec3Vector(subdata.properties.at(0).value<QVector<double> >());
} else if (subdata.name == "NormalsIndex") {
normalIndices = subdata.properties.at(0).value<QVector<int> >();
} else if (subdata.name == "MappingInformationType" &&
subdata.properties.at(0) == "ByVertice") {
byVertex = true;
@ -432,10 +445,20 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
// convert normals from per-index to per-vertex if necessary
if (mesh.normals.isEmpty()) {
mesh.normals.resize(mesh.vertices.size());
for (int i = 0, n = polygonIndices.size(); i < n; i++) {
int index = polygonIndices.at(i);
mesh.normals[index < 0 ? (-index - 1) : index] = normals.at(i);
}
if (normalIndices.isEmpty()) {
for (int i = 0, n = polygonIndices.size(); i < n; i++) {
int index = polygonIndices.at(i);
mesh.normals[index < 0 ? (-index - 1) : index] = normals.at(i);
}
} else {
for (int i = 0, n = polygonIndices.size(); i < n; i++) {
int index = polygonIndices.at(i);
int normalIndex = normalIndices.at(i);
if (normalIndex >= 0) {
mesh.normals[index < 0 ? (-index - 1) : index] = normals.at(normalIndex);
}
}
}
}
// same with the tex coords
@ -578,6 +601,31 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
textureFilenames.insert(object.properties.at(0).value<qint64>(), filename);
}
}
} else if (object.name == "Material") {
Material material = { glm::vec3(1.0f, 1.0f, 1.0f), glm::vec3(1.0f, 1.0f, 1.0f), 96.0f };
foreach (const FBXNode& subobject, object.children) {
if (subobject.name == "Properties70") {
foreach (const FBXNode& property, subobject.children) {
if (property.name == "P") {
if (property.properties.at(0) == "DiffuseColor") {
material.diffuse = glm::vec3(property.properties.at(4).value<double>(),
property.properties.at(5).value<double>(),
property.properties.at(6).value<double>());
} else if (property.properties.at(0) == "SpecularColor") {
material.specular = glm::vec3(property.properties.at(4).value<double>(),
property.properties.at(5).value<double>(),
property.properties.at(6).value<double>());
} else if (property.properties.at(0) == "Shininess") {
material.shininess = property.properties.at(4).value<double>();
}
}
}
}
}
materials.insert(object.properties.at(0).value<qint64>(), material);
} else if (object.name == "Deformer") {
if (object.properties.at(2) == "Cluster") {
foreach (const FBXNode& subobject, object.children) {
@ -641,8 +689,15 @@ FBXGeometry extractFBXGeometry(const FBXNode& node, const QVariantHash& mapping)
qint64 modelID = parentMap.value(it.key());
glm::mat4 modelTransform = getGlobalTransform(parentMap, localTransforms, modelID);
// look for textures
// look for textures, material properties
foreach (qint64 childID, childMap.values(modelID)) {
if (!materials.contains(childID)) {
continue;
}
Material material = materials.value(childID);
mesh.diffuseColor = material.diffuse;
mesh.specularColor = material.specular;
mesh.shininess = material.shininess;
qint64 diffuseTextureID = diffuseTextures.value(childID);
if (diffuseTextureID != 0) {
mesh.diffuseFilename = textureFilenames.value(diffuseTextureID);

View file

@ -51,6 +51,10 @@ public:
bool isEye;
glm::vec3 diffuseColor;
glm::vec3 specularColor;
float shininess;
QByteArray diffuseFilename;
QByteArray normalFilename;

View file

@ -85,7 +85,8 @@ bool PacketSender::process() {
int packetsLeft = _packets.size();
bool keepGoing = packetsLeft > 0;
while (keepGoing) {
uint64_t SEND_INTERVAL_USECS = (_packetsPerSecond == 0) ? USECS_PER_SECOND : (USECS_PER_SECOND / _packetsPerSecond);
NetworkPacket& packet = _packets.front();
// send the packet through the NodeList...
@ -93,7 +94,7 @@ bool PacketSender::process() {
nodeSocket->send(&packet.getAddress(), packet.getData(), packet.getLength());
packetsThisCall++;
if (_notify) {
_notify->packetSentNotification(packet.getLength());
}
@ -110,11 +111,15 @@ bool PacketSender::process() {
// dynamically sleep until we need to fire off the next set of voxels we only sleep in threaded mode
if (keepGoing) {
now = usecTimestampNow();
uint64_t elapsed = now - _lastSendTime;
int usecToSleep = std::max(SEND_INTERVAL_USECS, SEND_INTERVAL_USECS - elapsed);
int usecToSleep = SEND_INTERVAL_USECS - elapsed;
// we only sleep in non-threaded mode
if (usecToSleep > 0) {
if (usecToSleep > SEND_INTERVAL_USECS) {
usecToSleep = SEND_INTERVAL_USECS;
}
usleep(usecToSleep);
}
}

View file

@ -36,7 +36,7 @@ public:
/// \thread any thread, typically the application thread
void queuePacketForSending(sockaddr& address, unsigned char* packetData, ssize_t packetLength);
void setPacketsPerSecond(int packetsPerSecond) { _packetsPerSecond = std::min(MINIMUM_PACKETS_PER_SECOND, packetsPerSecond); }
void setPacketsPerSecond(int packetsPerSecond) { _packetsPerSecond = std::max(MINIMUM_PACKETS_PER_SECOND, packetsPerSecond); }
int getPacketsPerSecond() const { return _packetsPerSecond; }
void setPacketSenderNotify(PacketSenderNotify* notify) { _notify = notify; }

View file

@ -103,6 +103,7 @@ int PerfStat::DumpStats(char** array) {
return lineCount;
}
bool PerformanceWarning::_suppressShortTimings = false;
// Destructor handles recording all of our stats
PerformanceWarning::~PerformanceWarning() {
@ -111,9 +112,17 @@ PerformanceWarning::~PerformanceWarning() {
if ((_alwaysDisplay || _renderWarningsOn) && elapsedmsec > 1) {
if (elapsedmsec > 1000) {
double elapsedsec = (end - _start) / 1000000.0;
qDebug("%s%s took %lf seconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedsec);
qDebug("%s took %lf seconds %s\n", _message, elapsedsec, (_alwaysDisplay ? "" : "WARNING!") );
} else {
qDebug("%s%s took %lf milliseconds\n", (_alwaysDisplay ? "" : "WARNING!"), _message, elapsedmsec);
if (_suppressShortTimings) {
if (elapsedmsec > 10) {
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
}
} else {
qDebug("%s took %lf milliseconds %s\n", _message, elapsedmsec,
(_alwaysDisplay || (elapsedmsec < 10) ? "" : "WARNING!"));
}
}
} else if (_alwaysDisplay) {
qDebug("%s took %lf milliseconds\n", _message, elapsedmsec);

View file

@ -89,6 +89,7 @@ private:
const char* _message;
bool _renderWarningsOn;
bool _alwaysDisplay;
static bool _suppressShortTimings;
public:
PerformanceWarning(bool renderWarnings, const char* message, bool alwaysDisplay = false) :
_start(usecTimestampNow()),
@ -97,6 +98,8 @@ public:
_alwaysDisplay(alwaysDisplay) { }
~PerformanceWarning();
static void setSuppressShortTimings(bool suppressShortTimings) { _suppressShortTimings = suppressShortTimings; }
};

View file

@ -74,7 +74,10 @@ bool VoxelNodeData::updateCurrentViewFrustum() {
newestViewFrustum.setOrientation(getCameraOrientation());
// Also make sure it's got the correct lens details from the camera
newestViewFrustum.setFieldOfView(getCameraFov());
float originalFOV = getCameraFov();
float wideFOV = originalFOV + VIEW_FRUSTUM_FOV_OVERSEND;
newestViewFrustum.setFieldOfView(wideFOV); // hack
newestViewFrustum.setAspectRatio(getCameraAspectRatio());
newestViewFrustum.setNearClip(getCameraNearClip());
newestViewFrustum.setFarClip(getCameraFarClip());

View file

@ -52,4 +52,6 @@ const float VIEW_CULLING_RATE_IN_MILLISECONDS = 1000.0f; // once a second is fin
const uint64_t CLIENT_TO_SERVER_VOXEL_SEND_INTERVAL_USECS = 1000 * 5; // 1 packet every 50 milliseconds
const float VIEW_FRUSTUM_FOV_OVERSEND = 60.0f;
#endif