mirror of
https://github.com/lubosz/overte.git
synced 2025-04-24 03:53:52 +02:00
removed a bunch of cruft from VoxelSystem
This commit is contained in:
parent
8a6e22bdb0
commit
c5197b390e
13 changed files with 40 additions and 1069 deletions
|
@ -742,9 +742,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
break;
|
||||
|
||||
case Qt::Key_S:
|
||||
if (isShifted && !isMeta) {
|
||||
_voxels.collectStatsForTreesAndVBOs();
|
||||
} else if (isShifted && isMeta) {
|
||||
if (isShifted && isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::SuppressShortTimings);
|
||||
} else if (!isShifted && isMeta) {
|
||||
takeSnapshot();
|
||||
|
@ -2518,15 +2516,6 @@ void Application::displayOverlay() {
|
|||
}
|
||||
}
|
||||
|
||||
// testing rendering coverage map
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMapV2)) {
|
||||
renderCoverageMapV2();
|
||||
}
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::CoverageMap)) {
|
||||
renderCoverageMap();
|
||||
}
|
||||
|
||||
// Show chat entry field
|
||||
if (_chatEntryOn) {
|
||||
_chatEntry.render(_glWidget->width(), _glWidget->height());
|
||||
|
@ -2968,115 +2957,6 @@ glm::vec2 Application::getScaledScreenPoint(glm::vec2 projectedPoint) {
|
|||
return screenPoint;
|
||||
}
|
||||
|
||||
// render the coverage map on screen
|
||||
void Application::renderCoverageMapV2() {
|
||||
glDisable(GL_LIGHTING);
|
||||
glLineWidth(2.0);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(0,1,1);
|
||||
|
||||
renderCoverageMapsV2Recursively(&_voxels.myCoverageMapV2);
|
||||
|
||||
glEnd();
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void Application::renderCoverageMapsV2Recursively(CoverageMapV2* map) {
|
||||
// render ourselves...
|
||||
if (map->isCovered()) {
|
||||
BoundingBox box = map->getBoundingBox();
|
||||
|
||||
glm::vec2 firstPoint = getScaledScreenPoint(box.getVertex(0));
|
||||
glm::vec2 lastPoint(firstPoint);
|
||||
|
||||
for (int i = 1; i < box.getVertexCount(); i++) {
|
||||
glm::vec2 thisPoint = getScaledScreenPoint(box.getVertex(i));
|
||||
|
||||
glVertex2f(lastPoint.x, lastPoint.y);
|
||||
glVertex2f(thisPoint.x, thisPoint.y);
|
||||
lastPoint = thisPoint;
|
||||
}
|
||||
|
||||
glVertex2f(lastPoint.x, lastPoint.y);
|
||||
glVertex2f(firstPoint.x, firstPoint.y);
|
||||
} else {
|
||||
// iterate our children and call render on them.
|
||||
for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) {
|
||||
CoverageMapV2* childMap = map->getChild(i);
|
||||
if (childMap) {
|
||||
renderCoverageMapsV2Recursively(childMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// render the coverage map on screen
|
||||
void Application::renderCoverageMap() {
|
||||
|
||||
glDisable(GL_LIGHTING);
|
||||
glLineWidth(2.0);
|
||||
glBegin(GL_LINES);
|
||||
glColor3f(0,0,1);
|
||||
|
||||
renderCoverageMapsRecursively(&_voxels.myCoverageMap);
|
||||
|
||||
glEnd();
|
||||
glEnable(GL_LIGHTING);
|
||||
}
|
||||
|
||||
void Application::renderCoverageMapsRecursively(CoverageMap* map) {
|
||||
for (int i = 0; i < map->getPolygonCount(); i++) {
|
||||
|
||||
OctreeProjectedPolygon* polygon = map->getPolygon(i);
|
||||
|
||||
if (polygon->getProjectionType() == (PROJECTION_RIGHT | PROJECTION_NEAR | PROJECTION_BOTTOM)) {
|
||||
glColor3f(.5,0,0); // dark red
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT)) {
|
||||
glColor3f(.5,.5,0); // dark yellow
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT)) {
|
||||
glColor3f(.5,.5,.5); // gray
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_BOTTOM)) {
|
||||
glColor3f(.5,0,.5); // dark magenta
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_BOTTOM)) {
|
||||
glColor3f(.75,0,0); // red
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_TOP)) {
|
||||
glColor3f(1,0,1); // magenta
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_LEFT | PROJECTION_TOP)) {
|
||||
glColor3f(0,0,1); // Blue
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR | PROJECTION_RIGHT | PROJECTION_TOP)) {
|
||||
glColor3f(0,1,0); // green
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_NEAR)) {
|
||||
glColor3f(1,1,0); // yellow
|
||||
} else if (polygon->getProjectionType() == (PROJECTION_FAR | PROJECTION_RIGHT | PROJECTION_BOTTOM)) {
|
||||
glColor3f(0,.5,.5); // dark cyan
|
||||
} else {
|
||||
glColor3f(1,0,0);
|
||||
}
|
||||
|
||||
glm::vec2 firstPoint = getScaledScreenPoint(polygon->getVertex(0));
|
||||
glm::vec2 lastPoint(firstPoint);
|
||||
|
||||
for (int i = 1; i < polygon->getVertexCount(); i++) {
|
||||
glm::vec2 thisPoint = getScaledScreenPoint(polygon->getVertex(i));
|
||||
|
||||
glVertex2f(lastPoint.x, lastPoint.y);
|
||||
glVertex2f(thisPoint.x, thisPoint.y);
|
||||
lastPoint = thisPoint;
|
||||
}
|
||||
|
||||
glVertex2f(lastPoint.x, lastPoint.y);
|
||||
glVertex2f(firstPoint.x, firstPoint.y);
|
||||
}
|
||||
|
||||
// iterate our children and call render on them.
|
||||
for (int i = 0; i < CoverageMapV2::NUMBER_OF_CHILDREN; i++) {
|
||||
CoverageMap* childMap = map->getChild(i);
|
||||
if (childMap) {
|
||||
renderCoverageMapsRecursively(childMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Application::renderRearViewMirror(const QRect& region, bool billboard) {
|
||||
bool eyeRelativeCamera = false;
|
||||
if (billboard) {
|
||||
|
|
|
@ -34,12 +34,16 @@
|
|||
#include "BandwidthMeter.h"
|
||||
#include "BuckyBalls.h"
|
||||
#include "Camera.h"
|
||||
#include "ControllerScriptingInterface.h"
|
||||
#include "DatagramProcessor.h"
|
||||
#include "Environment.h"
|
||||
#include "ExperimentalVoxelTreeRenderer.h"
|
||||
#include "FileLogger.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "Menu.h"
|
||||
#include "MetavoxelSystem.h"
|
||||
#include "PacketHeaders.h"
|
||||
#include "ParticleTreeRenderer.h"
|
||||
#include "PieMenu.h"
|
||||
#include "Stars.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
@ -68,9 +72,6 @@
|
|||
#include "ui/LodToolsDialog.h"
|
||||
#include "ui/LogDialog.h"
|
||||
#include "ui/UpdateDialog.h"
|
||||
#include "FileLogger.h"
|
||||
#include "ParticleTreeRenderer.h"
|
||||
#include "ControllerScriptingInterface.h"
|
||||
#include "ui/Overlays.h"
|
||||
|
||||
|
||||
|
@ -261,12 +262,6 @@ private slots:
|
|||
void setEnable3DTVMode(bool enable3DTVMode);
|
||||
void cameraMenuChanged();
|
||||
|
||||
void renderCoverageMap();
|
||||
void renderCoverageMapsRecursively(CoverageMap* map);
|
||||
|
||||
void renderCoverageMapV2();
|
||||
void renderCoverageMapsV2Recursively(CoverageMapV2* map);
|
||||
|
||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||
|
||||
void closeMirrorView();
|
||||
|
|
|
@ -282,11 +282,6 @@ Menu::Menu() :
|
|||
addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::TestPing, 0, true);
|
||||
addCheckableActionToQMenuAndActionHash(timingMenu, MenuOption::FrameTimer);
|
||||
addActionToQMenuAndActionHash(timingMenu, MenuOption::RunTimingTests, 0, this, SLOT(runTests()));
|
||||
addActionToQMenuAndActionHash(timingMenu,
|
||||
MenuOption::TreeStats,
|
||||
Qt::SHIFT | Qt::Key_S,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(collectStatsForTreesAndVBOs()));
|
||||
|
||||
QMenu* frustumMenu = developerMenu->addMenu("View Frustum Debugging Tools");
|
||||
addCheckableActionToQMenuAndActionHash(frustumMenu, MenuOption::DisplayFrustum, Qt::SHIFT | Qt::Key_F);
|
||||
|
@ -302,62 +297,6 @@ Menu::Menu() :
|
|||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::PipelineWarnings, Qt::CTRL | Qt::SHIFT | Qt::Key_P);
|
||||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::SuppressShortTimings, Qt::CTRL | Qt::SHIFT | Qt::Key_S);
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::AutomaticallyAuditTree);
|
||||
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::ShowAllLocalVoxels,
|
||||
Qt::CTRL | Qt::Key_A,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(showAllLocalVoxels()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::KillLocalVoxels,
|
||||
Qt::CTRL | Qt::Key_K,
|
||||
appInstance, SLOT(doKillLocalVoxels()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::RandomizeVoxelColors,
|
||||
Qt::CTRL | Qt::Key_R,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(randomizeVoxelColors()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorRandomly,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeRandom()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorEveryOtherVoxel,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeRandomEveryOther()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorByDistance,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeDistanceFromView()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorOutOfView,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeInView()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorBySource,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeBySource()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::ShowTrueColors,
|
||||
Qt::CTRL | Qt::Key_T,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(trueColorize()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::CullSharedFaces,
|
||||
Qt::CTRL | Qt::SHIFT | Qt::Key_C,
|
||||
|
@ -372,22 +311,6 @@ Menu::Menu() :
|
|||
appInstance->getVoxels(),
|
||||
SLOT(showCulledSharedFaces()));
|
||||
|
||||
addDisabledActionAndSeparator(renderDebugMenu, "Coverage Maps");
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorOccluded,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeOccluded()));
|
||||
|
||||
addActionToQMenuAndActionHash(renderDebugMenu,
|
||||
MenuOption::FalseColorOccludedV2,
|
||||
0,
|
||||
appInstance->getVoxels(),
|
||||
SLOT(falseColorizeOccludedV2()));
|
||||
|
||||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::CoverageMap, Qt::SHIFT | Qt::CTRL | Qt::Key_O);
|
||||
addCheckableActionToQMenuAndActionHash(renderDebugMenu, MenuOption::CoverageMapV2, Qt::SHIFT | Qt::CTRL | Qt::Key_P);
|
||||
|
||||
QMenu* audioDebugMenu = developerMenu->addMenu("Audio Debugging Tools");
|
||||
addCheckableActionToQMenuAndActionHash(audioDebugMenu, MenuOption::AudioNoiseReduction,
|
||||
0,
|
||||
|
|
|
@ -203,7 +203,6 @@ namespace MenuOption {
|
|||
const QString Avatars = "Avatars";
|
||||
const QString Atmosphere = "Atmosphere";
|
||||
const QString DisableAutoAdjustLOD = "Disable Automatically Adjusting LOD";
|
||||
const QString AutomaticallyAuditTree = "Automatically Audit Tree Stats";
|
||||
const QString Bandwidth = "Bandwidth Display";
|
||||
const QString BandwidthDetails = "Bandwidth Details";
|
||||
const QString BuckyBalls = "Bucky Balls";
|
||||
|
@ -213,8 +212,6 @@ namespace MenuOption {
|
|||
const QString CollideWithParticles = "Collide With Particles";
|
||||
const QString CollideWithVoxels = "Collide With Voxels";
|
||||
const QString CollideWithEnvironment = "Collide With World Boundaries";
|
||||
const QString CoverageMap = "Render Coverage Map";
|
||||
const QString CoverageMapV2 = "Render Coverage Map V2";
|
||||
const QString CullSharedFaces = "Cull Shared Voxel Faces";
|
||||
const QString DecreaseAvatarSize = "Decrease Avatar Size";
|
||||
const QString DecreaseVoxelSize = "Decrease Voxel Size";
|
||||
|
@ -231,13 +228,6 @@ namespace MenuOption {
|
|||
const QString HeadMouse = "Head Mouse";
|
||||
const QString HandsCollideWithSelf = "Collide With Self";
|
||||
const QString FaceshiftTCP = "Faceshift (TCP)";
|
||||
const QString FalseColorByDistance = "FALSE Color By Distance";
|
||||
const QString FalseColorBySource = "FALSE Color By Source";
|
||||
const QString FalseColorEveryOtherVoxel = "FALSE Color Every Other Randomly";
|
||||
const QString FalseColorOccluded = "FALSE Color Occluded Voxels";
|
||||
const QString FalseColorOccludedV2 = "FALSE Color Occluded V2 Voxels";
|
||||
const QString FalseColorOutOfView = "FALSE Color Voxel Out of View";
|
||||
const QString FalseColorRandomly = "FALSE Color Voxels Randomly";
|
||||
const QString FirstPerson = "First Person";
|
||||
const QString FrameTimer = "Show Timer";
|
||||
const QString FrustumRenderMode = "Render Mode";
|
||||
|
@ -249,7 +239,6 @@ namespace MenuOption {
|
|||
const QString GoTo = "Go To...";
|
||||
const QString IncreaseAvatarSize = "Increase Avatar Size";
|
||||
const QString IncreaseVoxelSize = "Increase Voxel Size";
|
||||
const QString KillLocalVoxels = "Kill Local Voxels";
|
||||
const QString GoHome = "Go Home";
|
||||
const QString Gravity = "Use Gravity";
|
||||
const QString LodTools = "LOD Tools";
|
||||
|
@ -274,7 +263,6 @@ namespace MenuOption {
|
|||
const QString PipelineWarnings = "Show Render Pipeline Warnings";
|
||||
const QString PlaySlaps = "Play Slaps";
|
||||
const QString Preferences = "Preferences...";
|
||||
const QString RandomizeVoxelColors = "Randomize Voxel TRUE Colors";
|
||||
const QString ReloadAllScripts = "Reload All Scripts";
|
||||
const QString RenderSkeletonCollisionProxies = "Skeleton Collision Proxies";
|
||||
const QString RenderHeadCollisionProxies = "Head Collision Proxies";
|
||||
|
@ -283,15 +271,12 @@ namespace MenuOption {
|
|||
const QString SettingsImport = "Import Settings";
|
||||
const QString Shadows = "Shadows";
|
||||
const QString SettingsExport = "Export Settings";
|
||||
const QString ShowAllLocalVoxels = "Show All Local Voxels";
|
||||
const QString ShowCulledSharedFaces = "Show Culled Shared Voxel Faces";
|
||||
const QString ShowTrueColors = "Show TRUE Colors";
|
||||
const QString SuppressShortTimings = "Suppress Timings Less than 10ms";
|
||||
const QString Stars = "Stars";
|
||||
const QString Stats = "Stats";
|
||||
const QString StopAllScripts = "Stop All Scripts";
|
||||
const QString TestPing = "Test Ping";
|
||||
const QString TreeStats = "Calculate Tree Stats";
|
||||
const QString TransmitterDrive = "Transmitter Drive";
|
||||
const QString Quit = "Quit";
|
||||
const QString Voxels = "Voxels";
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include <NodeList.h>
|
||||
|
||||
#include "Application.h"
|
||||
#include "CoverageMap.h"
|
||||
#include "CoverageMapV2.h"
|
||||
#include "InterfaceConfig.h"
|
||||
#include "Menu.h"
|
||||
#include "renderer/ProgramObject.h"
|
||||
|
@ -206,31 +204,16 @@ void VoxelSystem::freeBufferIndex(glBufferIndex index) {
|
|||
qDebug() << "freeBufferIndex() called when _voxelsInWriteArrays == 0!";
|
||||
}
|
||||
|
||||
// if the "freed" index was our max index, then just drop the _voxelsInWriteArrays down one...
|
||||
bool inList = false;
|
||||
// make the index available for next node that needs to be drawn
|
||||
_freeIndexLock.lock();
|
||||
_freeIndexes.push_back(index);
|
||||
_freeIndexLock.unlock();
|
||||
|
||||
// make sure the index isn't already in the free list..., this is a debugging measure only done if you've enabled audits
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AutomaticallyAuditTree)) {
|
||||
for (unsigned long i = 0; i < _freeIndexes.size(); i++) {
|
||||
if (_freeIndexes[i] == index) {
|
||||
printf("freeBufferIndex(glBufferIndex index)... index=%ld already in free list!", index);
|
||||
inList = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!inList) {
|
||||
// make the index available for next node that needs to be drawn
|
||||
_freeIndexLock.lock();
|
||||
_freeIndexes.push_back(index);
|
||||
_freeIndexLock.unlock();
|
||||
|
||||
// make the VBO slot "invisible" in case this slot is not used
|
||||
const glm::vec3 startVertex(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
const float voxelScale = 0;
|
||||
const nodeColor BLACK = {0, 0, 0, 0};
|
||||
updateArraysDetails(index, startVertex, voxelScale, BLACK);
|
||||
}
|
||||
// make the VBO slot "invisible" in case this slot is not used
|
||||
const glm::vec3 startVertex(FLT_MAX, FLT_MAX, FLT_MAX);
|
||||
const float voxelScale = 0;
|
||||
const nodeColor BLACK = {0, 0, 0, 0};
|
||||
updateArraysDetails(index, startVertex, voxelScale, BLACK);
|
||||
}
|
||||
|
||||
// This will run through the list of _freeIndexes and reset their VBO array values to be "invisible".
|
||||
|
@ -618,7 +601,7 @@ int VoxelSystem::parseData(const QByteArray& packet) {
|
|||
// ask the VoxelTree to read the bitstream into the tree
|
||||
ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());
|
||||
_tree->lockForWrite();
|
||||
VoxelPacketData packetData(packetIsCompressed);
|
||||
OctreePacketData packetData(packetIsCompressed);
|
||||
packetData.loadFinalizedContent(dataAt, sectionLength);
|
||||
if (Application::getInstance()->getLogger()->extraDebugging()) {
|
||||
qDebug("VoxelSystem::parseData() ... Got Packet Section"
|
||||
|
@ -886,15 +869,6 @@ void VoxelSystem::checkForCulling() {
|
|||
// we should consider putting this someplace else... as this might be able to occur less frequently, and save us on
|
||||
// VBO reubuilding. Possibly we should do this only if our actual VBO usage crosses some lower boundary.
|
||||
cleanupRemovedVoxels();
|
||||
|
||||
quint64 sinceLastAudit = (start - _lastAudit) / 1000;
|
||||
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::AutomaticallyAuditTree)) {
|
||||
if (sinceLastAudit >= std::max((float) _lastViewCullingElapsed, VIEW_CULLING_RATE_IN_MILLISECONDS)) {
|
||||
_lastAudit = start;
|
||||
collectStatsForTreesAndVBOs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void VoxelSystem::cleanupRemovedVoxels() {
|
||||
|
@ -1830,79 +1804,6 @@ void VoxelSystem::forceRedrawEntireTree() {
|
|||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
bool VoxelSystem::randomColorOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
_nodeCount++;
|
||||
if (voxel->isColored()) {
|
||||
nodeColor newColor = { 255, randomColorValue(150), randomColorValue(150), 1 };
|
||||
voxel->setColor(newColor);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void VoxelSystem::randomizeVoxelColors() {
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(randomColorOperation);
|
||||
qDebug("setting randomized true color for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
bool VoxelSystem::falseColorizeRandomOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
_nodeCount++;
|
||||
// always false colorize
|
||||
voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeRandom() {
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeRandomOperation);
|
||||
qDebug("setting randomized false color for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
bool VoxelSystem::trueColorizeOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
_nodeCount++;
|
||||
voxel->setFalseColored(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void VoxelSystem::trueColorize() {
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"trueColorize()",true);
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(trueColorizeOperation);
|
||||
qDebug("setting true color for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
// Will false colorize voxels that are not in view
|
||||
bool VoxelSystem::falseColorizeInViewOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
const ViewFrustum* viewFrustum = (const ViewFrustum*) extraData;
|
||||
_nodeCount++;
|
||||
if (voxel->isColored()) {
|
||||
if (!voxel->isInView(*viewFrustum)) {
|
||||
// Out of view voxels are colored RED
|
||||
voxel->setFalseColor(255, 0, 0);
|
||||
}
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeInView() {
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeInViewOperation,(void*)_viewFrustum);
|
||||
qDebug("setting in view false color for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
class VoxelAndPoint {
|
||||
public:
|
||||
VoxelTreeElement* voxel;
|
||||
|
@ -1935,135 +1836,6 @@ VoxelTreeElement* VoxelSystem::getVoxelEnclosing(const glm::vec3& point) {
|
|||
return voxelAndPoint.voxel;
|
||||
}
|
||||
|
||||
|
||||
// helper classes and args for falseColorizeBySource
|
||||
class groupColor {
|
||||
public:
|
||||
unsigned char red, green, blue;
|
||||
groupColor(unsigned char red, unsigned char green, unsigned char blue) :
|
||||
red(red), green(green), blue(blue) { }
|
||||
|
||||
groupColor() :
|
||||
red(0), green(0), blue(0) { }
|
||||
};
|
||||
|
||||
class colorizeBySourceArgs {
|
||||
public:
|
||||
std::map<uint16_t, groupColor> colors;
|
||||
};
|
||||
|
||||
// Will false colorize voxels that are not in view
|
||||
bool VoxelSystem::falseColorizeBySourceOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
colorizeBySourceArgs* args = (colorizeBySourceArgs*)extraData;
|
||||
_nodeCount++;
|
||||
if (voxel->isColored()) {
|
||||
// pick a color based on the source - we want each source to be obviously different
|
||||
uint16_t nodeIDKey = voxel->getSourceUUIDKey();
|
||||
voxel->setFalseColor(args->colors[nodeIDKey].red, args->colors[nodeIDKey].green, args->colors[nodeIDKey].blue);
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeBySource() {
|
||||
_nodeCount = 0;
|
||||
colorizeBySourceArgs args;
|
||||
const int NUMBER_OF_COLOR_GROUPS = 6;
|
||||
const unsigned char MIN_COLOR = 128;
|
||||
int voxelServerCount = 0;
|
||||
groupColor groupColors[NUMBER_OF_COLOR_GROUPS] = {
|
||||
groupColor(255, 0, 0),
|
||||
groupColor( 0, 255, 0),
|
||||
groupColor( 0, 0, 255),
|
||||
groupColor(255, 0, 255),
|
||||
groupColor( 0, 255, 255),
|
||||
groupColor(255, 255, 255)
|
||||
};
|
||||
|
||||
// create a bunch of colors we'll use during colorization
|
||||
|
||||
foreach (const SharedNodePointer& node, NodeList::getInstance()->getNodeHash()) {
|
||||
if (node->getType() == NodeType::VoxelServer) {
|
||||
uint16_t nodeID = VoxelTreeElement::getSourceNodeUUIDKey(node->getUUID());
|
||||
int groupColor = voxelServerCount % NUMBER_OF_COLOR_GROUPS;
|
||||
args.colors[nodeID] = groupColors[groupColor];
|
||||
|
||||
if (groupColors[groupColor].red > 0) {
|
||||
groupColors[groupColor].red = ((groupColors[groupColor].red - MIN_COLOR)/2) + MIN_COLOR;
|
||||
}
|
||||
if (groupColors[groupColor].green > 0) {
|
||||
groupColors[groupColor].green = ((groupColors[groupColor].green - MIN_COLOR)/2) + MIN_COLOR;
|
||||
}
|
||||
if (groupColors[groupColor].blue > 0) {
|
||||
groupColors[groupColor].blue = ((groupColors[groupColor].blue - MIN_COLOR)/2) + MIN_COLOR;
|
||||
}
|
||||
|
||||
voxelServerCount++;
|
||||
}
|
||||
}
|
||||
|
||||
_tree->recurseTreeWithOperation(falseColorizeBySourceOperation, &args);
|
||||
qDebug("setting false color by source for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
// Will false colorize voxels based on distance from view
|
||||
bool VoxelSystem::falseColorizeDistanceFromViewOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
|
||||
if (voxel->isColored()) {
|
||||
float distance = voxel->distanceToCamera(*viewFrustum);
|
||||
_nodeCount++;
|
||||
float distanceRatio = (_minDistance == _maxDistance) ? 1 : (distance - _minDistance) / (_maxDistance - _minDistance);
|
||||
|
||||
// We want to colorize this in 16 bug chunks of color
|
||||
const unsigned char maxColor = 255;
|
||||
const unsigned char colorBands = 16;
|
||||
const unsigned char gradientOver = 128;
|
||||
unsigned char colorBand = (colorBands * distanceRatio);
|
||||
voxel->setFalseColor((colorBand * (gradientOver / colorBands)) + (maxColor - gradientOver), 0, 0);
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
float VoxelSystem::_maxDistance = 0.0;
|
||||
float VoxelSystem::_minDistance = FLT_MAX;
|
||||
|
||||
// Helper function will get the distance from view range, would be nice if you could just keep track
|
||||
// of this as voxels are created and/or colored... seems like some transform math could do that so
|
||||
// we wouldn't need to do two passes of the tree
|
||||
bool VoxelSystem::getDistanceFromViewRangeOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
ViewFrustum* viewFrustum = (ViewFrustum*) extraData;
|
||||
// only do this for truly colored voxels...
|
||||
if (voxel->isColored()) {
|
||||
float distance = voxel->distanceToCamera(*viewFrustum);
|
||||
// calculate the range of distances
|
||||
if (distance > _maxDistance) {
|
||||
_maxDistance = distance;
|
||||
}
|
||||
if (distance < _minDistance) {
|
||||
_minDistance = distance;
|
||||
}
|
||||
_nodeCount++;
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeDistanceFromView() {
|
||||
_nodeCount = 0;
|
||||
_maxDistance = 0.0;
|
||||
_minDistance = FLT_MAX;
|
||||
_tree->recurseTreeWithOperation(getDistanceFromViewRangeOperation, (void*) _viewFrustum);
|
||||
qDebug("determining distance range for %d nodes", _nodeCount);
|
||||
_nodeCount = 0;
|
||||
_tree->recurseTreeWithOperation(falseColorizeDistanceFromViewOperation, (void*) _viewFrustum);
|
||||
qDebug("setting in distance false color for %d nodes", _nodeCount);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
// combines the removeOutOfView args into a single class
|
||||
class removeOutOfViewArgs {
|
||||
public:
|
||||
|
@ -2197,57 +1969,6 @@ void VoxelSystem::removeOutOfView() {
|
|||
}
|
||||
}
|
||||
|
||||
// combines the removeOutOfView args into a single class
|
||||
class showAllLocalVoxelsArgs {
|
||||
public:
|
||||
VoxelSystem* thisVoxelSystem;
|
||||
ViewFrustum thisViewFrustum;
|
||||
unsigned long nodesScanned;
|
||||
|
||||
showAllLocalVoxelsArgs(VoxelSystem* voxelSystem) :
|
||||
thisVoxelSystem(voxelSystem),
|
||||
thisViewFrustum(*voxelSystem->getViewFrustum()),
|
||||
nodesScanned(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
void VoxelSystem::showAllLocalVoxels() {
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings), "showAllLocalVoxels()");
|
||||
showAllLocalVoxelsArgs args(this);
|
||||
_tree->recurseTreeWithOperation(showAllLocalVoxelsOperation,(void*)&args);
|
||||
|
||||
bool showRemoveDebugDetails = Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings);
|
||||
if (showRemoveDebugDetails) {
|
||||
qDebug("showAllLocalVoxels() scanned=%ld",args.nodesScanned );
|
||||
}
|
||||
}
|
||||
|
||||
bool VoxelSystem::showAllLocalVoxelsOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
showAllLocalVoxelsArgs* args = (showAllLocalVoxelsArgs*)extraData;
|
||||
|
||||
args->nodesScanned++;
|
||||
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
bool shouldRender = voxel->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
|
||||
voxel->setShouldRender(shouldRender);
|
||||
|
||||
if (shouldRender) {
|
||||
bool falseColorize = false;
|
||||
if (falseColorize) {
|
||||
voxel->setFalseColor(0,0,255); // false colorize
|
||||
}
|
||||
// These are both needed to force redraw...
|
||||
voxel->setDirtyBit();
|
||||
voxel->markWithChangedTime();
|
||||
}
|
||||
|
||||
return true; // keep recursing!
|
||||
}
|
||||
|
||||
|
||||
// combines the removeOutOfView args into a single class
|
||||
class hideOutOfViewArgs {
|
||||
public:
|
||||
|
@ -2598,209 +2319,6 @@ bool VoxelSystem::findCapsulePenetration(const glm::vec3& start, const glm::vec3
|
|||
return result;
|
||||
}
|
||||
|
||||
class falseColorizeRandomEveryOtherArgs {
|
||||
public:
|
||||
falseColorizeRandomEveryOtherArgs() : totalNodes(0), colorableNodes(0), coloredNodes(0), colorThis(true) {};
|
||||
unsigned long totalNodes;
|
||||
unsigned long colorableNodes;
|
||||
unsigned long coloredNodes;
|
||||
bool colorThis;
|
||||
};
|
||||
|
||||
bool VoxelSystem::falseColorizeRandomEveryOtherOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
falseColorizeRandomEveryOtherArgs* args = (falseColorizeRandomEveryOtherArgs*)extraData;
|
||||
args->totalNodes++;
|
||||
if (voxel->isColored()) {
|
||||
args->colorableNodes++;
|
||||
if (args->colorThis) {
|
||||
args->coloredNodes++;
|
||||
voxel->setFalseColor(255, randomColorValue(150), randomColorValue(150));
|
||||
}
|
||||
args->colorThis = !args->colorThis;
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeRandomEveryOther() {
|
||||
falseColorizeRandomEveryOtherArgs args;
|
||||
_tree->recurseTreeWithOperation(falseColorizeRandomEveryOtherOperation,&args);
|
||||
qDebug("randomized false color for every other node: total %ld, colorable %ld, colored %ld",
|
||||
args.totalNodes, args.colorableNodes, args.coloredNodes);
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
class collectStatsForTreesAndVBOsArgs {
|
||||
public:
|
||||
collectStatsForTreesAndVBOsArgs(int maxVoxels) :
|
||||
totalNodes(0),
|
||||
dirtyNodes(0),
|
||||
shouldRenderNodes(0),
|
||||
coloredNodes(0),
|
||||
nodesInVBO(0),
|
||||
nodesInVBONotShouldRender(0),
|
||||
nodesInVBOOverExpectedMax(0),
|
||||
duplicateVBOIndex(0),
|
||||
leafNodes(0),
|
||||
culledLeafNodes(0),
|
||||
nodesInPrimitiveRenderer(0)
|
||||
{
|
||||
hasIndexFound = new bool[maxVoxels];
|
||||
memset(hasIndexFound, false, maxVoxels * sizeof(bool));
|
||||
};
|
||||
|
||||
~collectStatsForTreesAndVBOsArgs() {
|
||||
delete[] hasIndexFound;
|
||||
}
|
||||
|
||||
unsigned long totalNodes;
|
||||
unsigned long dirtyNodes;
|
||||
unsigned long shouldRenderNodes;
|
||||
unsigned long coloredNodes;
|
||||
unsigned long nodesInVBO;
|
||||
unsigned long nodesInVBONotShouldRender;
|
||||
unsigned long nodesInVBOOverExpectedMax;
|
||||
unsigned long duplicateVBOIndex;
|
||||
unsigned long leafNodes;
|
||||
unsigned long culledLeafNodes; ///< Number of completely culled nodes because of face sharing
|
||||
unsigned long nodesInPrimitiveRenderer;
|
||||
|
||||
unsigned long expectedMax;
|
||||
|
||||
bool* hasIndexFound;
|
||||
};
|
||||
|
||||
bool VoxelSystem::collectStatsForTreesAndVBOsOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
|
||||
collectStatsForTreesAndVBOsArgs* args = (collectStatsForTreesAndVBOsArgs*)extraData;
|
||||
args->totalNodes++;
|
||||
|
||||
if (voxel->isLeaf()) {
|
||||
args->leafNodes++;
|
||||
if (voxel->getInteriorOcclusions() == OctreeElement::HalfSpace::All) {
|
||||
args->culledLeafNodes++;
|
||||
}
|
||||
}
|
||||
|
||||
if (voxel->isColored()) {
|
||||
args->coloredNodes++;
|
||||
}
|
||||
|
||||
if (voxel->getShouldRender()) {
|
||||
args->shouldRenderNodes++;
|
||||
}
|
||||
|
||||
if (voxel->isDirty()) {
|
||||
args->dirtyNodes++;
|
||||
}
|
||||
|
||||
unsigned long nodeIndex = 0;
|
||||
if (voxel->getBufferIndex()) {
|
||||
args->nodesInPrimitiveRenderer++;
|
||||
nodeIndex = voxel->getBufferIndex();
|
||||
|
||||
const bool extraDebugging = false; // enable for extra debugging
|
||||
if (extraDebugging) {
|
||||
qDebug("node In Renderer... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s, culledFaces=0x%02x \n",
|
||||
voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(),
|
||||
nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()),
|
||||
voxel->getInteriorOcclusions());
|
||||
}
|
||||
}
|
||||
|
||||
if (voxel->isKnownBufferIndex()) {
|
||||
args->nodesInVBO++;
|
||||
nodeIndex = voxel->getBufferIndex();
|
||||
|
||||
const bool extraDebugging = false; // enable for extra debugging
|
||||
if (extraDebugging) {
|
||||
qDebug("node In VBO... [%f,%f,%f] %f ... index=%ld, isDirty=%s, shouldRender=%s \n",
|
||||
voxel->getCorner().x, voxel->getCorner().y, voxel->getCorner().z, voxel->getScale(),
|
||||
nodeIndex, debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()));
|
||||
}
|
||||
|
||||
if (args->hasIndexFound[nodeIndex]) {
|
||||
args->duplicateVBOIndex++;
|
||||
qDebug("duplicateVBO found... index=%ld, isDirty=%s, shouldRender=%s", nodeIndex,
|
||||
debug::valueOf(voxel->isDirty()), debug::valueOf(voxel->getShouldRender()));
|
||||
} else {
|
||||
args->hasIndexFound[nodeIndex] = true;
|
||||
}
|
||||
if (nodeIndex > args->expectedMax) {
|
||||
args->nodesInVBOOverExpectedMax++;
|
||||
}
|
||||
|
||||
// if it's in VBO but not-shouldRender, track that also...
|
||||
if (!voxel->getShouldRender()) {
|
||||
args->nodesInVBONotShouldRender++;
|
||||
}
|
||||
}
|
||||
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::collectStatsForTreesAndVBOs() {
|
||||
PerformanceWarning warn(true, "collectStatsForTreesAndVBOs()", true);
|
||||
|
||||
glBufferIndex minDirty = GLBUFFER_INDEX_UNKNOWN;
|
||||
glBufferIndex maxDirty = 0;
|
||||
|
||||
if (!_usePrimitiveRenderer) {
|
||||
for (glBufferIndex i = 0; i < _voxelsInWriteArrays; i++) {
|
||||
if (_writeVoxelDirtyArray[i]) {
|
||||
minDirty = std::min(minDirty,i);
|
||||
maxDirty = std::max(maxDirty,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
collectStatsForTreesAndVBOsArgs args(_maxVoxels);
|
||||
args.expectedMax = _voxelsInWriteArrays;
|
||||
|
||||
qDebug("CALCULATING Local Voxel Tree Statistics >>>>>>>>>>>>");
|
||||
|
||||
_tree->recurseTreeWithOperation(collectStatsForTreesAndVBOsOperation,&args);
|
||||
|
||||
qDebug("Local Voxel Tree Statistics:\n total nodes %ld \n leaves %ld \n dirty %ld \n colored %ld \n shouldRender %ld \n",
|
||||
args.totalNodes, args.leafNodes, args.dirtyNodes, args.coloredNodes, args.shouldRenderNodes);
|
||||
|
||||
if (!_usePrimitiveRenderer) {
|
||||
qDebug(" _voxelsDirty=%s \n _voxelsInWriteArrays=%ld \n minDirty=%ld \n maxDirty=%ld", debug::valueOf(_voxelsDirty),
|
||||
_voxelsInWriteArrays, minDirty, maxDirty);
|
||||
|
||||
qDebug(" inVBO %ld \n nodesInVBOOverExpectedMax %ld \n duplicateVBOIndex %ld \n nodesInVBONotShouldRender %ld",
|
||||
args.nodesInVBO, args.nodesInVBOOverExpectedMax, args.duplicateVBOIndex, args.nodesInVBONotShouldRender);
|
||||
|
||||
qDebug(" memory usage %ld \n gpu memory usage %ld \n", _memoryUsageRAM, _memoryUsageVBO);
|
||||
|
||||
glBufferIndex minInVBO = GLBUFFER_INDEX_UNKNOWN;
|
||||
glBufferIndex maxInVBO = 0;
|
||||
|
||||
for (glBufferIndex i = 0; i < _maxVoxels; i++) {
|
||||
if (args.hasIndexFound[i]) {
|
||||
minInVBO = std::min(minInVBO,i);
|
||||
maxInVBO = std::max(maxInVBO,i);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug(" minInVBO=%ld \n maxInVBO=%ld \n _voxelsInWriteArrays=%ld \n _voxelsInReadArrays=%ld",
|
||||
minInVBO, maxInVBO, _voxelsInWriteArrays, _voxelsInReadArrays);
|
||||
|
||||
qDebug(" _freeIndexes.size()=%ld",
|
||||
_freeIndexes.size());
|
||||
} else {
|
||||
qDebug(" PrimitiveRenderer nodes %ld \n completely culled nodes %ld \n",
|
||||
args.nodesInPrimitiveRenderer, args.culledLeafNodes);
|
||||
|
||||
qDebug(" memory usage %ld \n gpu memory usage %ld \n",
|
||||
_renderer->getMemoryUsage(), _renderer->getMemoryUsageGPU());
|
||||
}
|
||||
qDebug("DONE WITH Local Voxel Tree Statistics >>>>>>>>>>>>");
|
||||
}
|
||||
|
||||
|
||||
void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) {
|
||||
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||
"VoxelSystem::deleteVoxelAt()");
|
||||
|
@ -2851,268 +2369,6 @@ void VoxelSystem::recurseTreeWithOperation(RecurseOctreeOperation operation, voi
|
|||
_tree->recurseTreeWithOperation(operation, extraData);
|
||||
}
|
||||
|
||||
struct FalseColorizeOccludedArgs {
|
||||
ViewFrustum* viewFrustum;
|
||||
CoverageMap* map;
|
||||
CoverageMapV2* mapV2;
|
||||
VoxelTree* tree;
|
||||
long totalVoxels;
|
||||
long coloredVoxels;
|
||||
long occludedVoxels;
|
||||
long notOccludedVoxels;
|
||||
long outOfView;
|
||||
long subtreeVoxelsSkipped;
|
||||
long nonLeaves;
|
||||
long nonLeavesOutOfView;
|
||||
long nonLeavesOccluded;
|
||||
};
|
||||
|
||||
struct FalseColorizeSubTreeOperationArgs {
|
||||
unsigned char color[NUMBER_OF_COLORS];
|
||||
long voxelsTouched;
|
||||
};
|
||||
|
||||
bool VoxelSystem::falseColorizeSubTreeOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
if (voxel->getShouldRender()) {
|
||||
FalseColorizeSubTreeOperationArgs* args = (FalseColorizeSubTreeOperationArgs*) extraData;
|
||||
voxel->setFalseColor(args->color[0], args->color[1], args->color[2]);
|
||||
args->voxelsTouched++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VoxelSystem::falseColorizeOccludedOperation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
|
||||
FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
|
||||
args->totalVoxels++;
|
||||
|
||||
// If we are a parent, let's see if we're completely occluded.
|
||||
if (!voxel->isLeaf()) {
|
||||
args->nonLeaves++;
|
||||
|
||||
AABox voxelBox = voxel->getAABox();
|
||||
voxelBox.scale(TREE_SCALE);
|
||||
OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
|
||||
|
||||
// If we're not all in view, then ignore it, and just return. But keep searching...
|
||||
if (!voxelPolygon->getAllInView()) {
|
||||
args->nonLeavesOutOfView++;
|
||||
delete voxelPolygon;
|
||||
return true;
|
||||
}
|
||||
|
||||
CoverageMapStorageResult result = args->map->checkMap(voxelPolygon, false);
|
||||
if (result == OCCLUDED) {
|
||||
args->nonLeavesOccluded++;
|
||||
delete voxelPolygon;
|
||||
|
||||
FalseColorizeSubTreeOperationArgs subArgs;
|
||||
subArgs.color[0] = 0;
|
||||
subArgs.color[1] = 255;
|
||||
subArgs.color[2] = 0;
|
||||
subArgs.voxelsTouched = 0;
|
||||
|
||||
args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
|
||||
|
||||
args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
|
||||
args->totalVoxels += (subArgs.voxelsTouched - 1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete voxelPolygon;
|
||||
return true; // keep looking...
|
||||
}
|
||||
|
||||
if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
|
||||
args->coloredVoxels++;
|
||||
|
||||
AABox voxelBox = voxel->getAABox();
|
||||
voxelBox.scale(TREE_SCALE);
|
||||
OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
|
||||
|
||||
// If we're not all in view, then ignore it, and just return. But keep searching...
|
||||
if (!voxelPolygon->getAllInView()) {
|
||||
args->outOfView++;
|
||||
delete voxelPolygon;
|
||||
return true;
|
||||
}
|
||||
|
||||
CoverageMapStorageResult result = args->map->checkMap(voxelPolygon, true);
|
||||
if (result == OCCLUDED) {
|
||||
voxel->setFalseColor(255, 0, 0);
|
||||
args->occludedVoxels++;
|
||||
} else if (result == STORED) {
|
||||
args->notOccludedVoxels++;
|
||||
//qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n");
|
||||
} else if (result == DOESNT_FIT) {
|
||||
//qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n");
|
||||
}
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
void VoxelSystem::falseColorizeOccluded() {
|
||||
PerformanceWarning warn(true, "falseColorizeOccluded()",true);
|
||||
myCoverageMap.erase();
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.map = &myCoverageMap;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
args.occludedVoxels = 0;
|
||||
args.notOccludedVoxels = 0;
|
||||
args.outOfView = 0;
|
||||
args.subtreeVoxelsSkipped = 0;
|
||||
args.nonLeaves = 0;
|
||||
args.nonLeavesOutOfView = 0;
|
||||
args.nonLeavesOccluded = 0;
|
||||
args.tree = _tree;
|
||||
|
||||
OctreeProjectedPolygon::pointInside_calls = 0;
|
||||
OctreeProjectedPolygon::occludes_calls = 0;
|
||||
OctreeProjectedPolygon::intersects_calls = 0;
|
||||
|
||||
glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
|
||||
|
||||
_tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedOperation, position, (void*)&args);
|
||||
|
||||
qDebug("falseColorizeOccluded()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld",
|
||||
position.x, position.y,
|
||||
args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
|
||||
args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
|
||||
args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
|
||||
OctreeProjectedPolygon::pointInside_calls,
|
||||
OctreeProjectedPolygon::occludes_calls,
|
||||
OctreeProjectedPolygon::intersects_calls
|
||||
);
|
||||
|
||||
|
||||
//myCoverageMap.erase();
|
||||
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
bool VoxelSystem::falseColorizeOccludedV2Operation(OctreeElement* element, void* extraData) {
|
||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||
|
||||
FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
|
||||
args->totalVoxels++;
|
||||
|
||||
// If we are a parent, let's see if we're completely occluded.
|
||||
if (!voxel->isLeaf()) {
|
||||
args->nonLeaves++;
|
||||
|
||||
AABox voxelBox = voxel->getAABox();
|
||||
voxelBox.scale(TREE_SCALE);
|
||||
OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
|
||||
|
||||
// If we're not all in view, then ignore it, and just return. But keep searching...
|
||||
if (!voxelPolygon->getAllInView()) {
|
||||
args->nonLeavesOutOfView++;
|
||||
delete voxelPolygon;
|
||||
return true;
|
||||
}
|
||||
|
||||
CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, false);
|
||||
if (result == V2_OCCLUDED) {
|
||||
args->nonLeavesOccluded++;
|
||||
delete voxelPolygon;
|
||||
|
||||
FalseColorizeSubTreeOperationArgs subArgs;
|
||||
subArgs.color[0] = 0;
|
||||
subArgs.color[1] = 255;
|
||||
subArgs.color[2] = 0;
|
||||
subArgs.voxelsTouched = 0;
|
||||
|
||||
args->tree->recurseNodeWithOperation(voxel, falseColorizeSubTreeOperation, &subArgs );
|
||||
|
||||
args->subtreeVoxelsSkipped += (subArgs.voxelsTouched - 1);
|
||||
args->totalVoxels += (subArgs.voxelsTouched - 1);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
delete voxelPolygon;
|
||||
return true; // keep looking...
|
||||
}
|
||||
|
||||
if (voxel->isLeaf() && voxel->isColored() && voxel->getShouldRender()) {
|
||||
args->coloredVoxels++;
|
||||
|
||||
AABox voxelBox = voxel->getAABox();
|
||||
voxelBox.scale(TREE_SCALE);
|
||||
OctreeProjectedPolygon* voxelPolygon = new OctreeProjectedPolygon(args->viewFrustum->getProjectedPolygon(voxelBox));
|
||||
|
||||
// If we're not all in view, then ignore it, and just return. But keep searching...
|
||||
if (!voxelPolygon->getAllInView()) {
|
||||
args->outOfView++;
|
||||
delete voxelPolygon;
|
||||
return true;
|
||||
}
|
||||
|
||||
CoverageMapV2StorageResult result = args->mapV2->checkMap(voxelPolygon, true);
|
||||
if (result == V2_OCCLUDED) {
|
||||
voxel->setFalseColor(255, 0, 0);
|
||||
args->occludedVoxels++;
|
||||
} else if (result == V2_STORED) {
|
||||
args->notOccludedVoxels++;
|
||||
//qDebug("***** falseColorizeOccludedOperation() NODE is STORED *****\n");
|
||||
} else if (result == V2_DOESNT_FIT) {
|
||||
//qDebug("***** falseColorizeOccludedOperation() NODE DOESNT_FIT???? *****\n");
|
||||
}
|
||||
delete voxelPolygon; // V2 maps don't store polygons, so we're always in charge of freeing
|
||||
}
|
||||
return true; // keep going!
|
||||
}
|
||||
|
||||
|
||||
void VoxelSystem::falseColorizeOccludedV2() {
|
||||
PerformanceWarning warn(true, "falseColorizeOccludedV2()",true);
|
||||
myCoverageMapV2.erase();
|
||||
|
||||
CoverageMapV2::wantDebugging = true;
|
||||
|
||||
OctreeProjectedPolygon::pointInside_calls = 0;
|
||||
OctreeProjectedPolygon::occludes_calls = 0;
|
||||
OctreeProjectedPolygon::intersects_calls = 0;
|
||||
|
||||
FalseColorizeOccludedArgs args;
|
||||
args.viewFrustum = _viewFrustum;
|
||||
args.mapV2 = &myCoverageMapV2;
|
||||
args.totalVoxels = 0;
|
||||
args.coloredVoxels = 0;
|
||||
args.occludedVoxels = 0;
|
||||
args.notOccludedVoxels = 0;
|
||||
args.outOfView = 0;
|
||||
args.subtreeVoxelsSkipped = 0;
|
||||
args.nonLeaves = 0;
|
||||
args.nonLeavesOutOfView = 0;
|
||||
args.nonLeavesOccluded = 0;
|
||||
args.tree = _tree;
|
||||
|
||||
glm::vec3 position = args.viewFrustum->getPosition() * (1.0f/TREE_SCALE);
|
||||
|
||||
_tree->recurseTreeWithOperationDistanceSorted(falseColorizeOccludedV2Operation, position, (void*)&args);
|
||||
|
||||
qDebug("falseColorizeOccludedV2()\n position=(%f,%f)\n total=%ld\n colored=%ld\n occluded=%ld\n notOccluded=%ld\n outOfView=%ld\n subtreeVoxelsSkipped=%ld\n nonLeaves=%ld\n nonLeavesOutOfView=%ld\n nonLeavesOccluded=%ld\n pointInside_calls=%ld\n occludes_calls=%ld\n intersects_calls=%ld\n",
|
||||
position.x, position.y,
|
||||
args.totalVoxels, args.coloredVoxels, args.occludedVoxels,
|
||||
args.notOccludedVoxels, args.outOfView, args.subtreeVoxelsSkipped,
|
||||
args.nonLeaves, args.nonLeavesOutOfView, args.nonLeavesOccluded,
|
||||
OctreeProjectedPolygon::pointInside_calls,
|
||||
OctreeProjectedPolygon::occludes_calls,
|
||||
OctreeProjectedPolygon::intersects_calls
|
||||
);
|
||||
//myCoverageMapV2.erase();
|
||||
_tree->setDirtyBit();
|
||||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
void VoxelSystem::nodeAdded(SharedNodePointer node) {
|
||||
if (node->getType() == NodeType::VoxelServer) {
|
||||
qDebug("VoxelSystem... voxel server %s added...", node->getUUID().toString().toLocal8Bit().constData());
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include <CoverageMapV2.h>
|
||||
#include <NodeData.h>
|
||||
#include <ViewFrustum.h>
|
||||
#include <VoxelTree.h>
|
||||
|
@ -106,9 +105,6 @@ public:
|
|||
|
||||
void recurseTreeWithOperation(RecurseOctreeOperation operation, void* extraData=NULL);
|
||||
|
||||
CoverageMapV2 myCoverageMapV2;
|
||||
CoverageMap myCoverageMap;
|
||||
|
||||
virtual void elementDeleted(OctreeElement* element);
|
||||
virtual void elementUpdated(OctreeElement* element);
|
||||
|
||||
|
@ -122,19 +118,8 @@ public slots:
|
|||
void nodeAdded(SharedNodePointer node);
|
||||
void nodeKilled(SharedNodePointer node);
|
||||
|
||||
void collectStatsForTreesAndVBOs();
|
||||
|
||||
// Methods that recurse tree
|
||||
void showAllLocalVoxels();
|
||||
void randomizeVoxelColors();
|
||||
void falseColorizeRandom();
|
||||
void trueColorize();
|
||||
void falseColorizeInView();
|
||||
void falseColorizeDistanceFromView();
|
||||
void falseColorizeRandomEveryOther();
|
||||
void falseColorizeOccluded();
|
||||
void falseColorizeOccludedV2();
|
||||
void falseColorizeBySource();
|
||||
void forceRedrawEntireTree();
|
||||
void clearAllNodesBufferIndex();
|
||||
void cullSharedFaces();
|
||||
|
@ -178,19 +163,7 @@ private:
|
|||
|
||||
// Operation functions for tree recursion methods
|
||||
static int _nodeCount;
|
||||
static bool randomColorOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeRandomOperation(OctreeElement* element, void* extraData);
|
||||
static bool trueColorizeOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeInViewOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeDistanceFromViewOperation(OctreeElement* element, void* extraData);
|
||||
static bool getDistanceFromViewRangeOperation(OctreeElement* element, void* extraData);
|
||||
static bool removeOutOfViewOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeRandomEveryOtherOperation(OctreeElement* element, void* extraData);
|
||||
static bool collectStatsForTreesAndVBOsOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeOccludedOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeSubTreeOperation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeOccludedV2Operation(OctreeElement* element, void* extraData);
|
||||
static bool falseColorizeBySourceOperation(OctreeElement* element, void* extraData);
|
||||
static bool killSourceVoxelsOperation(OctreeElement* element, void* extraData);
|
||||
static bool forceRedrawEntireTreeOperation(OctreeElement* element, void* extraData);
|
||||
static bool clearAllNodesBufferIndexOperation(OctreeElement* element, void* extraData);
|
||||
|
@ -199,7 +172,6 @@ private:
|
|||
static bool hideOutOfViewOperation(OctreeElement* element, void* extraData);
|
||||
static bool hideAllSubTreeOperation(OctreeElement* element, void* extraData);
|
||||
static bool showAllSubTreeOperation(OctreeElement* element, void* extraData);
|
||||
static bool showAllLocalVoxelsOperation(OctreeElement* element, void* extraData);
|
||||
static bool getVoxelEnclosingOperation(OctreeElement* element, void* extraData);
|
||||
static bool recreateVoxelGeometryInViewOperation(OctreeElement* element, void* extraData);
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <set>
|
||||
#include <SimpleMovingAverage.h>
|
||||
|
||||
//#include "CoverageMap.h"
|
||||
class CoverageMap;
|
||||
class ReadBitstreamToTreeParams;
|
||||
class Octree;
|
||||
|
|
|
@ -14,16 +14,32 @@
|
|||
#include <PerfStat.h>
|
||||
#include "OctreeRenderer.h"
|
||||
|
||||
OctreeRenderer::OctreeRenderer() {
|
||||
_tree = NULL;
|
||||
_viewFrustum = NULL;
|
||||
OctreeRenderer::OctreeRenderer() :
|
||||
_tree(NULL),
|
||||
_managedTree(false),
|
||||
_viewFrustum(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
void OctreeRenderer::init() {
|
||||
_tree = createTree();
|
||||
if (!_tree) {
|
||||
_tree = createTree();
|
||||
_managedTree = true;
|
||||
}
|
||||
}
|
||||
|
||||
OctreeRenderer::~OctreeRenderer() {
|
||||
if (_tree && _managedTree) {
|
||||
delete _tree;
|
||||
}
|
||||
}
|
||||
|
||||
void OctreeRenderer::setTree(Octree* newTree) {
|
||||
if (_tree && _managedTree) {
|
||||
delete _tree;
|
||||
_managedTree = false;
|
||||
}
|
||||
_tree = newTree;
|
||||
}
|
||||
|
||||
void OctreeRenderer::processDatagram(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode) {
|
||||
|
|
|
@ -44,6 +44,8 @@ public:
|
|||
virtual PacketType getMyQueryMessageType() const = 0;
|
||||
virtual PacketType getExpectedPacketType() const = 0;
|
||||
virtual void renderElement(OctreeElement* element, RenderArgs* args) = 0;
|
||||
|
||||
virtual void setTree(Octree* newTree);
|
||||
|
||||
/// process incoming data
|
||||
virtual void processDatagram(const QByteArray& dataByteArray, const SharedNodePointer& sourceNode);
|
||||
|
@ -63,6 +65,7 @@ public:
|
|||
void clear();
|
||||
protected:
|
||||
Octree* _tree;
|
||||
bool _managedTree;
|
||||
ViewFrustum* _viewFrustum;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
//#include "CoverageMap.h"
|
||||
#include "GeometryUtil.h"
|
||||
#include "SharedUtil.h"
|
||||
#include "ViewFrustum.h"
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
//
|
||||
// VoxelPacketData.cpp
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 11/19/2013.
|
||||
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
|
||||
//
|
||||
|
||||
#include <PerfStat.h>
|
||||
#include "VoxelPacketData.h"
|
||||
|
||||
// currently just an alias for OctreePacketData
|
||||
|
||||
VoxelPacketData::VoxelPacketData(bool enableCompression, int maxFinalizedSize) :
|
||||
OctreePacketData(enableCompression, maxFinalizedSize) {
|
||||
};
|
|
@ -1,35 +0,0 @@
|
|||
//
|
||||
// VoxelPacketData.h
|
||||
// hifi
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 11/19/2013
|
||||
//
|
||||
// TO DO:
|
||||
//
|
||||
// * add stats tracking for number of unique colors and consecutive identical colors.
|
||||
// (as research for color dictionaries and RLE)
|
||||
//
|
||||
// * further testing of compression to determine optimal configuration for performance and compression
|
||||
//
|
||||
// * improve semantics for "reshuffle" - current approach will work for now and with compression
|
||||
// but wouldn't work with RLE because the colors in the levels would get reordered and RLE would need
|
||||
// to be recalculated
|
||||
//
|
||||
|
||||
#ifndef __hifi__VoxelPacketData__
|
||||
#define __hifi__VoxelPacketData__
|
||||
|
||||
#include <SharedUtil.h>
|
||||
|
||||
#include <OctreePacketData.h>
|
||||
|
||||
#include "VoxelConstants.h"
|
||||
#include "VoxelTreeElement.h"
|
||||
|
||||
/// Handles packing of the data portion of PacketType_VOXEL_DATA messages.
|
||||
class VoxelPacketData : public OctreePacketData {
|
||||
public:
|
||||
VoxelPacketData(bool enableCompression = false, int maxFinalizedSize = MAX_OCTREE_PACKET_DATA_SIZE);
|
||||
};
|
||||
|
||||
#endif /* defined(__hifi__VoxelPacketData__) */
|
|
@ -9,17 +9,11 @@
|
|||
#ifndef __hifi__VoxelTree__
|
||||
#define __hifi__VoxelTree__
|
||||
|
||||
#include <set>
|
||||
#include <SimpleMovingAverage.h>
|
||||
#include <OctreeElementBag.h>
|
||||
#include <Octree.h>
|
||||
#include <CoverageMap.h>
|
||||
#include <JurisdictionMap.h>
|
||||
#include <ViewFrustum.h>
|
||||
|
||||
#include "VoxelTreeElement.h"
|
||||
#include "VoxelPacketData.h"
|
||||
#include "VoxelSceneStats.h"
|
||||
//#include "VoxelPacketData.h"
|
||||
//#include "VoxelSceneStats.h"
|
||||
#include "VoxelEditPacketSender.h"
|
||||
|
||||
class ReadCodeColorBufferToTreeArgs;
|
||||
|
|
Loading…
Reference in a new issue