mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 03:17:02 +02:00
added occlusion tests to debug menu
This commit is contained in:
parent
ab365202c8
commit
ac7fbc6320
4 changed files with 90 additions and 46 deletions
|
@ -964,6 +964,11 @@ void Application::doFalseColorizeInView() {
|
||||||
_voxels.falseColorizeInView(&_viewFrustum);
|
_voxels.falseColorizeInView(&_viewFrustum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Application::doFalseColorizeOccluded() {
|
||||||
|
_debugShowVirtualOccluders->setChecked(true);
|
||||||
|
_voxels.falseColorizeOccluded();
|
||||||
|
}
|
||||||
|
|
||||||
void Application::doTrueVoxelColors() {
|
void Application::doTrueVoxelColors() {
|
||||||
_voxels.trueColorize();
|
_voxels.trueColorize();
|
||||||
}
|
}
|
||||||
|
@ -1316,7 +1321,9 @@ void Application::initMenu() {
|
||||||
renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors()));
|
renderDebugMenu->addAction("FALSE Color Voxel Every Other Randomly", this, SLOT(doFalseRandomizeEveryOtherVoxelColors()));
|
||||||
renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance()));
|
renderDebugMenu->addAction("FALSE Color Voxels by Distance", this, SLOT(doFalseColorizeByDistance()));
|
||||||
renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
|
renderDebugMenu->addAction("FALSE Color Voxel Out of View", this, SLOT(doFalseColorizeInView()));
|
||||||
renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()));
|
renderDebugMenu->addAction("FALSE Color Occluded Voxels", this, SLOT(doFalseColorizeOccluded()), Qt::CTRL | Qt::Key_O);
|
||||||
|
renderDebugMenu->addAction("Show TRUE Colors", this, SLOT(doTrueVoxelColors()), Qt::CTRL | Qt::Key_T);
|
||||||
|
(_debugShowVirtualOccluders = renderDebugMenu->addAction("Show Virtual Occluders"))->setCheckable(true);
|
||||||
|
|
||||||
debugMenu->addAction("Wants Res-In", this, SLOT(setWantsResIn(bool)))->setCheckable(true);
|
debugMenu->addAction("Wants Res-In", this, SLOT(setWantsResIn(bool)))->setCheckable(true);
|
||||||
debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
|
debugMenu->addAction("Wants Monochrome", this, SLOT(setWantsMonochrome(bool)))->setCheckable(true);
|
||||||
|
@ -1902,59 +1909,62 @@ glm::vec2 Application::getScreenPoint(glm::vec3 voxelPoint) {
|
||||||
return getScaledScreenPoint(projectedPoint);
|
return getScaledScreenPoint(projectedPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::render2DTests() {
|
void Application::renderVirtualOccluders() {
|
||||||
glLineWidth(2.0);
|
|
||||||
glBegin(GL_LINES);
|
|
||||||
glColor3f(1,0,0);
|
|
||||||
|
|
||||||
AABox boxA(glm::vec3(0,0,0), 0.0125);
|
if (_debugShowVirtualOccluders->isChecked()) {
|
||||||
boxA.scale(TREE_SCALE);
|
glLineWidth(2.0);
|
||||||
VoxelProjectedShadow shadowA = _viewFrustum.getProjectedShadow(boxA);
|
glBegin(GL_LINES);
|
||||||
|
glColor3f(0,0,1);
|
||||||
|
|
||||||
AABox boxB(glm::vec3(0.0125,0,0.025), 0.0125);
|
AABox boxA(glm::vec3(0,0,0), 0.0125);
|
||||||
boxB.scale(TREE_SCALE);
|
boxA.scale(TREE_SCALE);
|
||||||
VoxelProjectedShadow shadowB = _viewFrustum.getProjectedShadow(boxB);
|
VoxelProjectedShadow shadowA = _viewFrustum.getProjectedShadow(boxA);
|
||||||
|
|
||||||
bool shadowAoccludesB = shadowA.occludes(shadowB);
|
AABox boxB(glm::vec3(0.0125,0,0.025), 0.0125);
|
||||||
bool shadowBoccludesA = shadowB.occludes(shadowA);
|
boxB.scale(TREE_SCALE);
|
||||||
|
VoxelProjectedShadow shadowB = _viewFrustum.getProjectedShadow(boxB);
|
||||||
|
|
||||||
|
bool shadowAoccludesB = shadowA.occludes(shadowB);
|
||||||
|
bool shadowBoccludesA = shadowB.occludes(shadowA);
|
||||||
|
|
||||||
if (shadowA.getVertexCount()) {
|
if (shadowA.getVertexCount()) {
|
||||||
if (shadowBoccludesA) {
|
if (shadowBoccludesA) {
|
||||||
glColor3f(0,1,1);
|
glColor3f(1,0,0);
|
||||||
} else {
|
} else {
|
||||||
glColor3f(1,0,0);
|
glColor3f(0,0,1);
|
||||||
}
|
}
|
||||||
glm::vec2 firstPoint = getScaledScreenPoint(shadowA.getVertex(0));
|
glm::vec2 firstPoint = getScaledScreenPoint(shadowA.getVertex(0));
|
||||||
glm::vec2 lastPoint(firstPoint);
|
glm::vec2 lastPoint(firstPoint);
|
||||||
for (int i = 1; i < shadowA.getVertexCount(); i++) {
|
for (int i = 1; i < shadowA.getVertexCount(); i++) {
|
||||||
glm::vec2 thisPoint = getScaledScreenPoint(shadowA.getVertex(i));
|
glm::vec2 thisPoint = getScaledScreenPoint(shadowA.getVertex(i));
|
||||||
|
glVertex2f(lastPoint.x, lastPoint.y);
|
||||||
|
glVertex2f(thisPoint.x, thisPoint.y);
|
||||||
|
lastPoint = thisPoint;
|
||||||
|
}
|
||||||
glVertex2f(lastPoint.x, lastPoint.y);
|
glVertex2f(lastPoint.x, lastPoint.y);
|
||||||
glVertex2f(thisPoint.x, thisPoint.y);
|
glVertex2f(firstPoint.x, firstPoint.y);
|
||||||
lastPoint = thisPoint;
|
|
||||||
}
|
}
|
||||||
glVertex2f(lastPoint.x, lastPoint.y);
|
|
||||||
glVertex2f(firstPoint.x, firstPoint.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shadowB.getVertexCount()) {
|
if (shadowB.getVertexCount()) {
|
||||||
if (shadowAoccludesB) {
|
if (shadowAoccludesB) {
|
||||||
glColor3f(0,1,0);
|
glColor3f(0,1,0);
|
||||||
} else {
|
} else {
|
||||||
glColor3f(1,0,0);
|
glColor3f(1,0,0);
|
||||||
}
|
}
|
||||||
glm::vec2 firstPoint = getScaledScreenPoint(shadowB.getVertex(0));
|
glm::vec2 firstPoint = getScaledScreenPoint(shadowB.getVertex(0));
|
||||||
glm::vec2 lastPoint(firstPoint);
|
glm::vec2 lastPoint(firstPoint);
|
||||||
for (int i = 1; i < shadowB.getVertexCount(); i++) {
|
for (int i = 1; i < shadowB.getVertexCount(); i++) {
|
||||||
glm::vec2 thisPoint = getScaledScreenPoint(shadowB.getVertex(i));
|
glm::vec2 thisPoint = getScaledScreenPoint(shadowB.getVertex(i));
|
||||||
|
glVertex2f(lastPoint.x, lastPoint.y);
|
||||||
|
glVertex2f(thisPoint.x, thisPoint.y);
|
||||||
|
lastPoint = thisPoint;
|
||||||
|
}
|
||||||
glVertex2f(lastPoint.x, lastPoint.y);
|
glVertex2f(lastPoint.x, lastPoint.y);
|
||||||
glVertex2f(thisPoint.x, thisPoint.y);
|
glVertex2f(firstPoint.x, firstPoint.y);
|
||||||
lastPoint = thisPoint;
|
|
||||||
}
|
}
|
||||||
glVertex2f(lastPoint.x, lastPoint.y);
|
|
||||||
glVertex2f(firstPoint.x, firstPoint.y);
|
|
||||||
}
|
|
||||||
|
|
||||||
glEnd();
|
glEnd();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::displaySide(Camera& whichCamera) {
|
void Application::displaySide(Camera& whichCamera) {
|
||||||
|
@ -2240,7 +2250,7 @@ void Application::displayStats() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// testing....
|
// testing....
|
||||||
render2DTests();
|
renderVirtualOccluders();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,6 +102,7 @@ private slots:
|
||||||
void doFalseRandomizeVoxelColors();
|
void doFalseRandomizeVoxelColors();
|
||||||
void doFalseRandomizeEveryOtherVoxelColors();
|
void doFalseRandomizeEveryOtherVoxelColors();
|
||||||
void doFalseColorizeByDistance();
|
void doFalseColorizeByDistance();
|
||||||
|
void doFalseColorizeOccluded();
|
||||||
void doFalseColorizeInView();
|
void doFalseColorizeInView();
|
||||||
void doTrueVoxelColors();
|
void doTrueVoxelColors();
|
||||||
void doTreeStats();
|
void doTreeStats();
|
||||||
|
@ -141,7 +142,7 @@ private:
|
||||||
void displayStats();
|
void displayStats();
|
||||||
|
|
||||||
// Couple of debug routines for use in debuggin/developing Occlusion Culling. Will be removed eventually
|
// Couple of debug routines for use in debuggin/developing Occlusion Culling. Will be removed eventually
|
||||||
void render2DTests();
|
void renderVirtualOccluders();
|
||||||
glm::vec2 getScreenPoint(glm::vec3 voxelPoint);
|
glm::vec2 getScreenPoint(glm::vec3 voxelPoint);
|
||||||
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
glm::vec2 getScaledScreenPoint(glm::vec2 projectedPoint);
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ private:
|
||||||
QAction* _fullScreenMode; // whether we are in full screen mode
|
QAction* _fullScreenMode; // whether we are in full screen mode
|
||||||
QAction* _frustumRenderModeAction;
|
QAction* _frustumRenderModeAction;
|
||||||
QAction* _settingsAutosave; // Whether settings are saved automatically
|
QAction* _settingsAutosave; // Whether settings are saved automatically
|
||||||
|
QAction* _debugShowVirtualOccluders;
|
||||||
|
|
||||||
SerialInterface _serialHeadSensor;
|
SerialInterface _serialHeadSensor;
|
||||||
QNetworkAccessManager* _networkAccessManager;
|
QNetworkAccessManager* _networkAccessManager;
|
||||||
|
|
|
@ -1156,3 +1156,33 @@ void VoxelSystem::copyFromTreeIntoSubTree(VoxelTree* sourceTree, VoxelNode* dest
|
||||||
_tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);
|
_tree->copyFromTreeIntoSubTree(sourceTree, destinationNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct FalseColorizeOccludedArgs {
|
||||||
|
VoxelProjectedShadow occluder;
|
||||||
|
ViewFrustum* viewFrustum;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool VoxelSystem::falseColorizeOccludedOperation(VoxelNode* node, void* extraData) {
|
||||||
|
FalseColorizeOccludedArgs* args = (FalseColorizeOccludedArgs*) extraData;
|
||||||
|
if (node->isColored()) {
|
||||||
|
AABox voxelBox = node->getAABox();
|
||||||
|
voxelBox.scale(TREE_SCALE);
|
||||||
|
VoxelProjectedShadow voxelShadow = args->viewFrustum->getProjectedShadow(voxelBox);
|
||||||
|
if (args->occluder.occludes(voxelShadow)) {
|
||||||
|
node->setFalseColor(255, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true; // keep going!
|
||||||
|
}
|
||||||
|
|
||||||
|
void VoxelSystem::falseColorizeOccluded() {
|
||||||
|
FalseColorizeOccludedArgs args;
|
||||||
|
args.viewFrustum = Application::getInstance()->getViewFrustum();
|
||||||
|
|
||||||
|
AABox box(glm::vec3(0.0125,0,0.025), 0.0125);
|
||||||
|
box.scale(TREE_SCALE);
|
||||||
|
args.occluder = args.viewFrustum->getProjectedShadow(box);
|
||||||
|
|
||||||
|
_tree->recurseTreeWithOperation(falseColorizeOccludedOperation,(void*)&args);
|
||||||
|
setupNewVoxelsForDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
void falseColorizeInView(ViewFrustum* viewFrustum);
|
void falseColorizeInView(ViewFrustum* viewFrustum);
|
||||||
void falseColorizeDistanceFromView(ViewFrustum* viewFrustum);
|
void falseColorizeDistanceFromView(ViewFrustum* viewFrustum);
|
||||||
void falseColorizeRandomEveryOther();
|
void falseColorizeRandomEveryOther();
|
||||||
|
void falseColorizeOccluded();
|
||||||
|
|
||||||
void killLocalVoxels();
|
void killLocalVoxels();
|
||||||
void setRenderPipelineWarnings(bool on) { _renderWarningsOn = on; };
|
void setRenderPipelineWarnings(bool on) { _renderWarningsOn = on; };
|
||||||
|
@ -120,6 +121,7 @@ private:
|
||||||
static bool removeOutOfViewOperation(VoxelNode* node, void* extraData);
|
static bool removeOutOfViewOperation(VoxelNode* node, void* extraData);
|
||||||
static bool falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* extraData);
|
static bool falseColorizeRandomEveryOtherOperation(VoxelNode* node, void* extraData);
|
||||||
static bool collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* extraData);
|
static bool collectStatsForTreesAndVBOsOperation(VoxelNode* node, void* extraData);
|
||||||
|
static bool falseColorizeOccludedOperation(VoxelNode* node, void* extraData);
|
||||||
|
|
||||||
int updateNodeInArraysAsFullVBO(VoxelNode* node);
|
int updateNodeInArraysAsFullVBO(VoxelNode* node);
|
||||||
int updateNodeInArraysAsPartialVBO(VoxelNode* node);
|
int updateNodeInArraysAsPartialVBO(VoxelNode* node);
|
||||||
|
|
Loading…
Reference in a new issue