mirror of
https://github.com/overte-org/overte.git
synced 2025-08-24 13:37:05 +02:00
more work on LOD slider
This commit is contained in:
parent
75721eb7ba
commit
580102bb38
11 changed files with 176 additions and 28 deletions
|
@ -2369,6 +2369,8 @@ void Application::queryVoxels() {
|
|||
_voxelQuery.setCameraNearClip(_viewFrustum.getNearClip());
|
||||
_voxelQuery.setCameraFarClip(_viewFrustum.getFarClip());
|
||||
_voxelQuery.setCameraEyeOffsetPosition(_viewFrustum.getEyeOffsetPosition());
|
||||
_voxelQuery.setVoxelSizeScale(Menu::getInstance()->getVoxelSizeScale());
|
||||
_voxelQuery.setBoundaryLevelAdjust(Menu::getInstance()->getBoundaryLevelAdjust());
|
||||
|
||||
unsigned char voxelQueryPacket[MAX_PACKET_SIZE];
|
||||
|
||||
|
|
|
@ -54,7 +54,9 @@ Menu::Menu() :
|
|||
_voxelModeActionsGroup(NULL),
|
||||
_voxelStatsDialog(NULL),
|
||||
_lodToolsDialog(NULL),
|
||||
_maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM)
|
||||
_maxVoxels(DEFAULT_MAX_VOXELS_PER_SYSTEM),
|
||||
_voxelSizeScale(DEFAULT_VOXEL_SIZE_SCALE),
|
||||
_boundaryLevelAdjust(0)
|
||||
{
|
||||
Application *appInstance = Application::getInstance();
|
||||
|
||||
|
@ -520,6 +522,8 @@ void Menu::loadSettings(QSettings* settings) {
|
|||
_audioJitterBufferSamples = loadSetting(settings, "audioJitterBufferSamples", 0);
|
||||
_fieldOfView = loadSetting(settings, "fieldOfView", DEFAULT_FIELD_OF_VIEW_DEGREES);
|
||||
_maxVoxels = loadSetting(settings, "maxVoxels", DEFAULT_MAX_VOXELS_PER_SYSTEM);
|
||||
_voxelSizeScale = loadSetting(settings, "voxelSizeScale", DEFAULT_VOXEL_SIZE_SCALE);
|
||||
_boundaryLevelAdjust = loadSetting(settings, "boundaryLevelAdjust", 0);
|
||||
|
||||
settings->beginGroup("View Frustum Offset Camera");
|
||||
// in case settings is corrupt or missing loadSetting() will check for NaN
|
||||
|
@ -546,6 +550,8 @@ void Menu::saveSettings(QSettings* settings) {
|
|||
settings->setValue("audioJitterBufferSamples", _audioJitterBufferSamples);
|
||||
settings->setValue("fieldOfView", _fieldOfView);
|
||||
settings->setValue("maxVoxels", _maxVoxels);
|
||||
settings->setValue("voxelSizeScale", _voxelSizeScale);
|
||||
settings->setValue("boundaryLevelAdjust", _boundaryLevelAdjust);
|
||||
settings->beginGroup("View Frustum Offset Camera");
|
||||
settings->setValue("viewFrustumOffsetYaw", _viewFrustumOffset.yaw);
|
||||
settings->setValue("viewFrustumOffsetPitch", _viewFrustumOffset.pitch);
|
||||
|
@ -1059,11 +1065,14 @@ void Menu::voxelStatsDetailsClosed() {
|
|||
}
|
||||
}
|
||||
|
||||
float Menu::getVoxelSizeScale() {
|
||||
if (_lodToolsDialog) {
|
||||
return _lodToolsDialog->getVoxelSizeScale();
|
||||
}
|
||||
return DEFAULT_FIELD_OF_VIEW_DEGREES;
|
||||
void Menu::setVoxelSizeScale(float sizeScale) {
|
||||
_voxelSizeScale = sizeScale;
|
||||
Application::getInstance()->getVoxels()->redrawInViewVoxels();
|
||||
}
|
||||
|
||||
void Menu::setBoundaryLevelAdjust(int boundaryLevelAdjust) {
|
||||
_boundaryLevelAdjust = boundaryLevelAdjust;
|
||||
Application::getInstance()->getVoxels()->redrawInViewVoxels();
|
||||
}
|
||||
|
||||
void Menu::lodTools() {
|
||||
|
|
|
@ -61,7 +61,11 @@ public:
|
|||
|
||||
void handleViewFrustumOffsetKeyModifier(int key);
|
||||
|
||||
float getVoxelSizeScale();
|
||||
// User Tweakable LOD Items
|
||||
void setVoxelSizeScale(float sizeScale);
|
||||
float getVoxelSizeScale() const { return _voxelSizeScale; }
|
||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust);
|
||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||
|
||||
public slots:
|
||||
void bandwidthDetails();
|
||||
|
@ -128,6 +132,8 @@ private:
|
|||
VoxelStatsDialog* _voxelStatsDialog;
|
||||
LodToolsDialog* _lodToolsDialog;
|
||||
int _maxVoxels;
|
||||
float _voxelSizeScale;
|
||||
int _boundaryLevelAdjust;
|
||||
QAction* _useVoxelShader;
|
||||
};
|
||||
|
||||
|
|
|
@ -139,8 +139,9 @@ void VoxelSystem::voxelUpdated(VoxelNode* node) {
|
|||
if (node->getVoxelSystem() == this) {
|
||||
bool shouldRender = false; // assume we don't need to render it
|
||||
// if it's colored, we might need to render it!
|
||||
float voxelSizeScale = DEFAULT_VOXEL_SIZE_SCALE;
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale);
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
|
||||
|
||||
if (node->getShouldRender() != shouldRender) {
|
||||
node->setShouldRender(shouldRender);
|
||||
|
@ -924,8 +925,9 @@ int VoxelSystem::newTreeToArrays(VoxelNode* node) {
|
|||
int voxelsUpdated = 0;
|
||||
bool shouldRender = false; // assume we don't need to render it
|
||||
// if it's colored, we might need to render it!
|
||||
float voxelSizeScale = DEFAULT_VOXEL_SIZE_SCALE;
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale);
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
shouldRender = node->calculateShouldRender(_viewFrustum, voxelSizeScale, boundaryLevelAdjust);
|
||||
|
||||
node->setShouldRender(shouldRender);
|
||||
// let children figure out their renderness
|
||||
|
@ -1386,6 +1388,10 @@ void VoxelSystem::killLocalVoxels() {
|
|||
setupNewVoxelsForDrawing();
|
||||
}
|
||||
|
||||
void VoxelSystem::redrawInViewVoxels() {
|
||||
hideOutOfView(true);
|
||||
}
|
||||
|
||||
|
||||
bool VoxelSystem::clearAllNodesBufferIndexOperation(VoxelNode* node, void* extraData) {
|
||||
_nodeCount++;
|
||||
|
@ -1773,8 +1779,9 @@ bool VoxelSystem::showAllLocalVoxelsOperation(VoxelNode* node, void* extraData)
|
|||
|
||||
args->nodesScanned++;
|
||||
|
||||
float voxelSizeScale = DEFAULT_VOXEL_SIZE_SCALE;
|
||||
bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale);
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();;
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
|
||||
node->setShouldRender(shouldRender);
|
||||
|
||||
if (shouldRender) {
|
||||
|
@ -1950,8 +1957,9 @@ bool VoxelSystem::showAllSubTreeOperation(VoxelNode* node, void* extraData) {
|
|||
|
||||
args->nodesInside++;
|
||||
|
||||
float voxelSizeScale = DEFAULT_VOXEL_SIZE_SCALE;
|
||||
bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale);
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
bool shouldRender = node->calculateShouldRender(&args->thisViewFrustum, voxelSizeScale, boundaryLevelAdjust);
|
||||
node->setShouldRender(shouldRender);
|
||||
|
||||
if (shouldRender && !node->isKnownBufferIndex()) {
|
||||
|
|
|
@ -83,6 +83,7 @@ public:
|
|||
float getVoxelsBytesReadPerSecondAverage();
|
||||
|
||||
void killLocalVoxels();
|
||||
void redrawInViewVoxels();
|
||||
|
||||
virtual void removeOutOfView();
|
||||
virtual void hideOutOfView(bool forceFullFrustum = false);
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
#include <QPalette>
|
||||
#include <QColor>
|
||||
#include <QSlider>
|
||||
#include <QPushButton>
|
||||
#include <QString>
|
||||
|
||||
#include <VoxelConstants.h>
|
||||
|
||||
#include "Menu.h"
|
||||
#include "ui/LodToolsDialog.h"
|
||||
|
||||
|
||||
|
@ -26,23 +29,118 @@ LodToolsDialog::LodToolsDialog(QWidget* parent) :
|
|||
// Create layouter
|
||||
QFormLayout* form = new QFormLayout();
|
||||
|
||||
QSlider* lodSize = new QSlider(Qt::Horizontal);
|
||||
lodSize->setValue(0);
|
||||
form->addRow("LOD Size Scale:", lodSize);
|
||||
_lodSize = new QSlider(Qt::Horizontal);
|
||||
const int MAX_LOD_SIZE = MAX_LOD_SIZE_MULTIPLIER;
|
||||
const int MIN_LOD_SIZE = 0;
|
||||
const int STEP_LOD_SIZE = 1;
|
||||
const int PAGE_STEP_LOD_SIZE = 100;
|
||||
const int SLIDER_WIDTH = 300;
|
||||
_lodSize->setMaximum(MAX_LOD_SIZE);
|
||||
_lodSize->setMinimum(MIN_LOD_SIZE);
|
||||
_lodSize->setSingleStep(STEP_LOD_SIZE);
|
||||
_lodSize->setTickInterval(PAGE_STEP_LOD_SIZE);
|
||||
_lodSize->setTickPosition(QSlider::TicksBelow);
|
||||
_lodSize->setFixedWidth(SLIDER_WIDTH);
|
||||
_lodSize->setPageStep(PAGE_STEP_LOD_SIZE);
|
||||
int sliderValue = Menu::getInstance()->getVoxelSizeScale() / TREE_SCALE;
|
||||
_lodSize->setValue(sliderValue);
|
||||
form->addRow("LOD Size Scale:", _lodSize);
|
||||
connect(_lodSize,SIGNAL(valueChanged(int)),this,SLOT(sizeScaleValueChanged(int)));
|
||||
|
||||
_boundaryLevelAdjust = new QSlider(Qt::Horizontal);
|
||||
const int MAX_ADJUST = 10;
|
||||
const int MIN_ADJUST = 0;
|
||||
const int STEP_ADJUST = 1;
|
||||
_boundaryLevelAdjust->setMaximum(MAX_ADJUST);
|
||||
_boundaryLevelAdjust->setMinimum(MIN_ADJUST);
|
||||
_boundaryLevelAdjust->setSingleStep(STEP_ADJUST);
|
||||
_boundaryLevelAdjust->setTickInterval(STEP_ADJUST);
|
||||
_boundaryLevelAdjust->setTickPosition(QSlider::TicksBelow);
|
||||
_boundaryLevelAdjust->setFixedWidth(SLIDER_WIDTH);
|
||||
sliderValue = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
_boundaryLevelAdjust->setValue(sliderValue);
|
||||
form->addRow("Boundary Level Adjust:", _boundaryLevelAdjust);
|
||||
connect(_boundaryLevelAdjust,SIGNAL(valueChanged(int)),this,SLOT(boundaryLevelValueChanged(int)));
|
||||
|
||||
// Create a label with feedback...
|
||||
_feedback = new QLabel();
|
||||
QPalette palette = _feedback->palette();
|
||||
const unsigned redish = 0xfff00000;
|
||||
palette.setColor(QPalette::WindowText, QColor::fromRgb(redish));
|
||||
_feedback->setPalette(palette);
|
||||
_feedback->setText(getFeedbackText());
|
||||
const int FEEDBACK_WIDTH = 350;
|
||||
_feedback->setFixedWidth(FEEDBACK_WIDTH);
|
||||
form->addRow("You can see... ", _feedback);
|
||||
|
||||
// Add a button to reset
|
||||
QPushButton* resetButton = new QPushButton("Reset");
|
||||
form->addRow("", resetButton);
|
||||
connect(resetButton,SIGNAL(clicked(bool)),this,SLOT(resetClicked(bool)));
|
||||
|
||||
this->QDialog::setLayout(form);
|
||||
//int width = 600;
|
||||
//int height = 200;
|
||||
//this->setFixedSize(width, height);
|
||||
}
|
||||
|
||||
QString LodToolsDialog::getFeedbackText() {
|
||||
// determine granularity feedback
|
||||
int boundaryLevelAdjust = Menu::getInstance()->getBoundaryLevelAdjust();
|
||||
QString granularityFeedback;
|
||||
|
||||
switch (boundaryLevelAdjust) {
|
||||
case 0: {
|
||||
granularityFeedback = QString("at standard granularity.");
|
||||
} break;
|
||||
case 1: {
|
||||
granularityFeedback = QString("at half of standard granularity.");
|
||||
} break;
|
||||
case 2: {
|
||||
granularityFeedback = QString("at a third of standard granularity.");
|
||||
} break;
|
||||
default: {
|
||||
granularityFeedback = QString("at 1/%1th of standard granularity.").arg(boundaryLevelAdjust + 1);
|
||||
} break;
|
||||
}
|
||||
|
||||
// distance feedback
|
||||
float voxelSizeScale = Menu::getInstance()->getVoxelSizeScale();
|
||||
float relativeToDefault = voxelSizeScale / DEFAULT_VOXEL_SIZE_SCALE;
|
||||
QString result;
|
||||
if (relativeToDefault > 1.01) {
|
||||
result = QString("%1 further %2").arg(relativeToDefault,8,'f',2).arg(granularityFeedback);
|
||||
} else if (relativeToDefault > 0.99) {
|
||||
result = QString("the default distance %1").arg(granularityFeedback);
|
||||
} else {
|
||||
result = QString("%1 of default %2").arg(relativeToDefault,8,'f',3).arg(granularityFeedback);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
LodToolsDialog::~LodToolsDialog() {
|
||||
delete _feedback;
|
||||
delete _lodSize;
|
||||
delete _boundaryLevelAdjust;
|
||||
}
|
||||
|
||||
float LodToolsDialog::getVoxelSizeScale() {
|
||||
return DEFAULT_VOXEL_SIZE_SCALE;
|
||||
void LodToolsDialog::sizeScaleValueChanged(int value) {
|
||||
float realValue = value * TREE_SCALE;
|
||||
Menu::getInstance()->setVoxelSizeScale(realValue);
|
||||
|
||||
_feedback->setText(getFeedbackText());
|
||||
}
|
||||
|
||||
void LodToolsDialog::paintEvent(QPaintEvent* event) {
|
||||
this->QDialog::paintEvent(event);
|
||||
this->setFixedSize(this->width(), this->height());
|
||||
void LodToolsDialog::boundaryLevelValueChanged(int value) {
|
||||
Menu::getInstance()->setBoundaryLevelAdjust(value);
|
||||
_feedback->setText(getFeedbackText());
|
||||
}
|
||||
|
||||
void LodToolsDialog::resetClicked(bool checked) {
|
||||
int sliderValue = DEFAULT_VOXEL_SIZE_SCALE / TREE_SCALE;
|
||||
//sizeScaleValueChanged(sliderValue);
|
||||
_lodSize->setValue(sliderValue);
|
||||
_boundaryLevelAdjust->setValue(0);
|
||||
}
|
||||
|
||||
void LodToolsDialog::reject() {
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <QDialog>
|
||||
#include <QLabel>
|
||||
#include <QSlider>
|
||||
|
||||
#include <VoxelSceneStats.h>
|
||||
|
||||
|
@ -21,21 +22,26 @@ public:
|
|||
LodToolsDialog(QWidget* parent);
|
||||
~LodToolsDialog();
|
||||
|
||||
float getVoxelSizeScale();
|
||||
|
||||
signals:
|
||||
void closed();
|
||||
|
||||
public slots:
|
||||
void reject();
|
||||
void sizeScaleValueChanged(int value);
|
||||
void boundaryLevelValueChanged(int value);
|
||||
void resetClicked(bool checked);
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
// Emits a 'closed' signal when this dialog is closed.
|
||||
void closeEvent(QCloseEvent*);
|
||||
|
||||
private:
|
||||
QString getFeedbackText();
|
||||
|
||||
QSlider* _lodSize;
|
||||
QSlider* _boundaryLevelAdjust;
|
||||
QLabel* _feedback;
|
||||
};
|
||||
|
||||
#endif /* defined(__interface__LodToolsDialog__) */
|
||||
|
|
|
@ -250,10 +250,16 @@ void VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* no
|
|||
VoxelNode* subTree = nodeData->nodeBag.extract();
|
||||
bool wantOcclusionCulling = nodeData->getWantOcclusionCulling();
|
||||
CoverageMap* coverageMap = wantOcclusionCulling ? &nodeData->map : IGNORE_COVERAGE_MAP;
|
||||
int boundaryLevelAdjust = viewFrustumChanged && nodeData->getWantLowResMoving()
|
||||
? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST;
|
||||
|
||||
float voxelSizeScale = nodeData->getVoxelSizeScale();
|
||||
int boundaryLevelAdjustClient = nodeData->getBoundaryLevelAdjust();
|
||||
|
||||
int boundaryLevelAdjust = boundaryLevelAdjustClient + (viewFrustumChanged && nodeData->getWantLowResMoving()
|
||||
? LOW_RES_MOVING_ADJUST : NO_BOUNDARY_ADJUST);
|
||||
|
||||
|
||||
printf("packetLoop() voxelSizeScale=%f boundaryLevelAdjustClient=%d boundaryLevelAdjust=%d\n",
|
||||
voxelSizeScale, boundaryLevelAdjustClient, boundaryLevelAdjust);
|
||||
|
||||
bool isFullScene = (!viewFrustumChanged || !nodeData->getWantDelta()) &&
|
||||
nodeData->getViewFrustumJustStoppedChanging();
|
||||
|
|
|
@ -28,6 +28,7 @@ const int TREE_SCALE = 16384; // ~10 miles.. This is the number of meters of t
|
|||
|
||||
// This controls the LOD. Larger number will make smaller voxels visible at greater distance.
|
||||
const float DEFAULT_VOXEL_SIZE_SCALE = TREE_SCALE * 400.0f;
|
||||
const float MAX_LOD_SIZE_MULTIPLIER = 2000.0f;
|
||||
|
||||
const int NUMBER_OF_CHILDREN = 8;
|
||||
const int MAX_VOXEL_PACKET_SIZE = 1492;
|
||||
|
|
|
@ -83,6 +83,10 @@ int VoxelQuery::getBroadcastData(unsigned char* destinationBuffer) {
|
|||
// desired voxelSizeScale
|
||||
memcpy(destinationBuffer, &_voxelSizeScale, sizeof(_voxelSizeScale));
|
||||
destinationBuffer += sizeof(_voxelSizeScale);
|
||||
|
||||
// desired boundaryLevelAdjust
|
||||
memcpy(destinationBuffer, &_boundaryLevelAdjust, sizeof(_boundaryLevelAdjust));
|
||||
destinationBuffer += sizeof(_boundaryLevelAdjust);
|
||||
|
||||
return destinationBuffer - bufferStart;
|
||||
}
|
||||
|
@ -130,6 +134,10 @@ int VoxelQuery::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
memcpy(&_voxelSizeScale, sourceBuffer, sizeof(_voxelSizeScale));
|
||||
sourceBuffer += sizeof(_voxelSizeScale);
|
||||
|
||||
// desired boundaryLevelAdjust
|
||||
memcpy(&_boundaryLevelAdjust, sourceBuffer, sizeof(_boundaryLevelAdjust));
|
||||
sourceBuffer += sizeof(_boundaryLevelAdjust);
|
||||
|
||||
return sourceBuffer - startPosition;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@ public:
|
|||
bool getWantOcclusionCulling() const { return _wantOcclusionCulling; }
|
||||
int getMaxVoxelPacketsPerSecond() const { return _maxVoxelPPS; }
|
||||
float getVoxelSizeScale() const { return _voxelSizeScale; }
|
||||
int getBoundaryLevelAdjust() const { return _boundaryLevelAdjust; }
|
||||
|
||||
public slots:
|
||||
void setWantLowResMoving(bool wantLowResMoving) { _wantLowResMoving = wantLowResMoving; }
|
||||
|
@ -78,6 +79,7 @@ public slots:
|
|||
void setWantOcclusionCulling(bool wantOcclusionCulling) { _wantOcclusionCulling = wantOcclusionCulling; }
|
||||
void setMaxVoxelPacketsPerSecond(int maxVoxelPPS) { _maxVoxelPPS = maxVoxelPPS; }
|
||||
void setVoxelSizeScale(float voxelSizeScale) { _voxelSizeScale = voxelSizeScale; }
|
||||
void setBoundaryLevelAdjust(int boundaryLevelAdjust) { _boundaryLevelAdjust = boundaryLevelAdjust; }
|
||||
|
||||
protected:
|
||||
QUuid _uuid;
|
||||
|
@ -98,6 +100,7 @@ protected:
|
|||
bool _wantOcclusionCulling;
|
||||
int _maxVoxelPPS;
|
||||
float _voxelSizeScale; /// used for LOD calculations
|
||||
int _boundaryLevelAdjust; /// used for LOD calculations
|
||||
|
||||
private:
|
||||
// privatize the copy constructor and assignment operator so they cannot be called
|
||||
|
|
Loading…
Reference in a new issue