mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 00:10:52 +02:00
Merge pull request #1901 from ZappoMan/fix_stutter_on_spin
fix stutter while spinning
This commit is contained in:
commit
c1ab02b79d
3 changed files with 63 additions and 83 deletions
|
@ -2053,7 +2053,7 @@ void Application::updateHoverVoxels(float deltaTime, float& distance, BoxFace& f
|
||||||
glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
|
glm::vec4 oldVoxel(_hoverVoxel.x, _hoverVoxel.y, _hoverVoxel.z, _hoverVoxel.s);
|
||||||
// only do this work if MAKE_SOUND_ON_VOXEL_HOVER or MAKE_SOUND_ON_VOXEL_CLICK is enabled,
|
// only do this work if MAKE_SOUND_ON_VOXEL_HOVER or MAKE_SOUND_ON_VOXEL_CLICK is enabled,
|
||||||
// and make sure the tree is not already busy... because otherwise you'll have to wait.
|
// and make sure the tree is not already busy... because otherwise you'll have to wait.
|
||||||
if (!(_voxels.treeIsBusy() || _mousePressed)) {
|
if (!_mousePressed) {
|
||||||
{
|
{
|
||||||
PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
|
PerformanceWarning warn(showWarnings, "Application::updateHoverVoxels() _voxels.findRayIntersection()");
|
||||||
_isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
|
_isHoverVoxel = _voxels.findRayIntersection(_mouseRayOrigin, _mouseRayDirection, _hoverVoxel, distance, face);
|
||||||
|
|
|
@ -99,8 +99,6 @@ VoxelSystem::VoxelSystem(float treeScale, int maxVoxels)
|
||||||
|
|
||||||
_culledOnce = false;
|
_culledOnce = false;
|
||||||
_inhideOutOfView = false;
|
_inhideOutOfView = false;
|
||||||
_treeIsBusy = false;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::elementDeleted(OctreeElement* element) {
|
void VoxelSystem::elementDeleted(OctreeElement* element) {
|
||||||
|
@ -594,9 +592,10 @@ int VoxelSystem::parseData(const QByteArray& packet) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sectionLength) {
|
if (sectionLength) {
|
||||||
|
PerformanceWarning warn(showTimingDetails, "VoxelSystem::parseData() section");
|
||||||
// ask the VoxelTree to read the bitstream into the tree
|
// ask the VoxelTree to read the bitstream into the tree
|
||||||
ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());
|
ReadBitstreamToTreeParams args(packetIsColored ? WANT_COLOR : NO_COLOR, WANT_EXISTS_BITS, NULL, getDataSourceUUID());
|
||||||
lockTree();
|
_tree->lockForWrite();
|
||||||
VoxelPacketData packetData(packetIsCompressed);
|
VoxelPacketData packetData(packetIsCompressed);
|
||||||
packetData.loadFinalizedContent(dataAt, sectionLength);
|
packetData.loadFinalizedContent(dataAt, sectionLength);
|
||||||
if (Application::getInstance()->getLogger()->extraDebugging()) {
|
if (Application::getInstance()->getLogger()->extraDebugging()) {
|
||||||
|
@ -608,7 +607,7 @@ int VoxelSystem::parseData(const QByteArray& packet) {
|
||||||
packetData.getUncompressedSize());
|
packetData.getUncompressedSize());
|
||||||
}
|
}
|
||||||
_tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
|
_tree->readBitstreamToTree(packetData.getUncompressedData(), packetData.getUncompressedSize(), args);
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
|
|
||||||
dataBytes -= sectionLength;
|
dataBytes -= sectionLength;
|
||||||
dataAt += sectionLength;
|
dataAt += sectionLength;
|
||||||
|
@ -1395,9 +1394,11 @@ void VoxelSystem::removeScaleAndReleaseProgram(bool texture) {
|
||||||
int VoxelSystem::_nodeCount = 0;
|
int VoxelSystem::_nodeCount = 0;
|
||||||
|
|
||||||
void VoxelSystem::killLocalVoxels() {
|
void VoxelSystem::killLocalVoxels() {
|
||||||
lockTree();
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"VoxelSystem::killLocalVoxels()");
|
||||||
|
_tree->lockForWrite();
|
||||||
_tree->eraseAllOctreeElements();
|
_tree->eraseAllOctreeElements();
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
clearFreeBufferIndexes();
|
clearFreeBufferIndexes();
|
||||||
_voxelsInReadArrays = 0; // do we need to do this?
|
_voxelsInReadArrays = 0; // do we need to do this?
|
||||||
setupNewVoxelsForDrawing();
|
setupNewVoxelsForDrawing();
|
||||||
|
@ -1416,10 +1417,12 @@ bool VoxelSystem::clearAllNodesBufferIndexOperation(OctreeElement* element, void
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::clearAllNodesBufferIndex() {
|
void VoxelSystem::clearAllNodesBufferIndex() {
|
||||||
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"VoxelSystem::clearAllNodesBufferIndex()");
|
||||||
_nodeCount = 0;
|
_nodeCount = 0;
|
||||||
lockTree();
|
_tree->lockForRead(); // we won't change the tree so it's ok to treat this as a read
|
||||||
_tree->recurseTreeWithOperation(clearAllNodesBufferIndexOperation);
|
_tree->recurseTreeWithOperation(clearAllNodesBufferIndexOperation);
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
|
if (Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings)) {
|
||||||
qDebug("clearing buffer index of %d nodes", _nodeCount);
|
qDebug("clearing buffer index of %d nodes", _nodeCount);
|
||||||
}
|
}
|
||||||
|
@ -1481,7 +1484,8 @@ bool VoxelSystem::trueColorizeOperation(OctreeElement* element, void* extraData)
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::trueColorize() {
|
void VoxelSystem::trueColorize() {
|
||||||
PerformanceWarning warn(true, "trueColorize()",true);
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"trueColorize()",true);
|
||||||
_nodeCount = 0;
|
_nodeCount = 0;
|
||||||
_tree->recurseTreeWithOperation(trueColorizeOperation);
|
_tree->recurseTreeWithOperation(trueColorizeOperation);
|
||||||
qDebug("setting true color for %d nodes", _nodeCount);
|
qDebug("setting true color for %d nodes", _nodeCount);
|
||||||
|
@ -1951,9 +1955,13 @@ void VoxelSystem::hideOutOfView(bool forceFullFrustum) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
lockTree();
|
{
|
||||||
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"VoxelSystem::... recurseTreeWithOperation(hideOutOfViewOperation)");
|
||||||
|
_tree->lockForRead();
|
||||||
_tree->recurseTreeWithOperation(hideOutOfViewOperation,(void*)&args);
|
_tree->recurseTreeWithOperation(hideOutOfViewOperation,(void*)&args);
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
|
}
|
||||||
_lastCulledViewFrustum = args.thisViewFrustum; // save last stable
|
_lastCulledViewFrustum = args.thisViewFrustum; // save last stable
|
||||||
_culledOnce = true;
|
_culledOnce = true;
|
||||||
|
|
||||||
|
@ -2150,12 +2158,14 @@ bool VoxelSystem::hideOutOfViewOperation(OctreeElement* element, void* extraData
|
||||||
|
|
||||||
bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3& direction,
|
||||||
VoxelDetail& detail, float& distance, BoxFace& face) {
|
VoxelDetail& detail, float& distance, BoxFace& face) {
|
||||||
lockTree();
|
|
||||||
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"VoxelSystem::findRayIntersection()");
|
||||||
|
bool result = false; // assume no intersection
|
||||||
|
if (_tree->tryLockForRead()) {
|
||||||
OctreeElement* element;
|
OctreeElement* element;
|
||||||
if (!_tree->findRayIntersection(origin, direction, element, distance, face)) {
|
result = _tree->findRayIntersection(origin, direction, element, distance, face);
|
||||||
unlockTree();
|
if (result) {
|
||||||
return false;
|
|
||||||
}
|
|
||||||
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
VoxelTreeElement* voxel = (VoxelTreeElement*)element;
|
||||||
detail.x = voxel->getCorner().x;
|
detail.x = voxel->getCorner().x;
|
||||||
detail.y = voxel->getCorner().y;
|
detail.y = voxel->getCorner().y;
|
||||||
|
@ -2164,21 +2174,31 @@ bool VoxelSystem::findRayIntersection(const glm::vec3& origin, const glm::vec3&
|
||||||
detail.red = voxel->getColor()[0];
|
detail.red = voxel->getColor()[0];
|
||||||
detail.green = voxel->getColor()[1];
|
detail.green = voxel->getColor()[1];
|
||||||
detail.blue = voxel->getColor()[2];
|
detail.blue = voxel->getColor()[2];
|
||||||
unlockTree();
|
}
|
||||||
return true;
|
_tree->unlock();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelSystem::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration) {
|
bool VoxelSystem::findSpherePenetration(const glm::vec3& center, float radius, glm::vec3& penetration) {
|
||||||
lockTree();
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
bool result = _tree->findSpherePenetration(center, radius, penetration);
|
"VoxelSystem::findSpherePenetration()");
|
||||||
unlockTree();
|
bool result = false; // assume no penetration
|
||||||
|
if (_tree->tryLockForRead()) {
|
||||||
|
result = _tree->findSpherePenetration(center, radius, penetration);
|
||||||
|
_tree->unlock();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VoxelSystem::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) {
|
bool VoxelSystem::findCapsulePenetration(const glm::vec3& start, const glm::vec3& end, float radius, glm::vec3& penetration) {
|
||||||
lockTree();
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
bool result = _tree->findCapsulePenetration(start, end, radius, penetration);
|
"VoxelSystem::findCapsulePenetration()");
|
||||||
unlockTree();
|
bool result = false; // assume no penetration
|
||||||
|
if (_tree->tryLockForRead()) {
|
||||||
|
result = _tree->findCapsulePenetration(start, end, radius, penetration);
|
||||||
|
_tree->unlock();
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2354,13 +2374,14 @@ void VoxelSystem::collectStatsForTreesAndVBOs() {
|
||||||
|
|
||||||
|
|
||||||
void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) {
|
void VoxelSystem::deleteVoxelAt(float x, float y, float z, float s) {
|
||||||
lockTree();
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
|
"VoxelSystem::deleteVoxelAt()");
|
||||||
|
_tree->lockForWrite();
|
||||||
_tree->deleteVoxelAt(x, y, z, s);
|
_tree->deleteVoxelAt(x, y, z, s);
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
|
|
||||||
// redraw!
|
// redraw!
|
||||||
setupNewVoxelsForDrawing(); // do we even need to do this? Or will the next network receive kick in?
|
setupNewVoxelsForDrawing(); // do we even need to do this? Or will the next network receive kick in?
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
VoxelTreeElement* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
|
VoxelTreeElement* VoxelSystem::getVoxelAt(float x, float y, float z, float s) const {
|
||||||
|
@ -2370,10 +2391,12 @@ VoxelTreeElement* VoxelSystem::getVoxelAt(float x, float y, float z, float s) co
|
||||||
void VoxelSystem::createVoxel(float x, float y, float z, float s,
|
void VoxelSystem::createVoxel(float x, float y, float z, float s,
|
||||||
unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
|
unsigned char red, unsigned char green, unsigned char blue, bool destructive) {
|
||||||
|
|
||||||
//qDebug("VoxelSystem::createVoxel(%f,%f,%f,%f)\n",x,y,z,s);
|
PerformanceWarning warn(Menu::getInstance()->isOptionChecked(MenuOption::PipelineWarnings),
|
||||||
lockTree();
|
"VoxelSystem::createVoxel()");
|
||||||
|
|
||||||
|
_tree->lockForWrite();
|
||||||
_tree->createVoxel(x, y, z, s, red, green, blue, destructive);
|
_tree->createVoxel(x, y, z, s, red, green, blue, destructive);
|
||||||
unlockTree();
|
_tree->unlock();
|
||||||
|
|
||||||
setupNewVoxelsForDrawing();
|
setupNewVoxelsForDrawing();
|
||||||
};
|
};
|
||||||
|
@ -2744,37 +2767,3 @@ unsigned long VoxelSystem::getVoxelMemoryUsageGPU() {
|
||||||
return (_initialMemoryUsageGPU - currentFreeMemory);
|
return (_initialMemoryUsageGPU - currentFreeMemory);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VoxelSystem::lockTree() {
|
|
||||||
_treeLock.lock();
|
|
||||||
_treeIsBusy = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VoxelSystem::unlockTree() {
|
|
||||||
_treeIsBusy = false;
|
|
||||||
_treeLock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void VoxelSystem::localVoxelCacheLoaded() {
|
|
||||||
qDebug() << "localVoxelCacheLoaded()";
|
|
||||||
|
|
||||||
// Make sure that the application has properly set up the view frustum for our loaded state
|
|
||||||
Application::getInstance()->initAvatarAndViewFrustum();
|
|
||||||
|
|
||||||
_tree->setDirtyBit(); // make sure the tree thinks it's dirty
|
|
||||||
_setupNewVoxelsForDrawingLastFinished = 0; // don't allow the setupNewVoxelsForDrawing() shortcuts
|
|
||||||
_writeRenderFullVBO = true; // this will disable individual node updates, was reset by killLocalVoxels()
|
|
||||||
setupNewVoxelsForDrawing();
|
|
||||||
_inhideOutOfView = false; // reenable hideOutOfView behavior
|
|
||||||
}
|
|
||||||
|
|
||||||
void VoxelSystem::beginLoadingLocalVoxelCache() {
|
|
||||||
qDebug() << "beginLoadingLocalVoxelCache()";
|
|
||||||
_writeRenderFullVBO = true; // this will disable individual node updates
|
|
||||||
_inhideOutOfView = true; // this will disable hidOutOfView which we want to do until local cache is loaded
|
|
||||||
killLocalVoxels();
|
|
||||||
qDebug() << "DONE beginLoadingLocalVoxelCache()";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -110,8 +110,6 @@ public:
|
||||||
virtual void elementDeleted(OctreeElement* element);
|
virtual void elementDeleted(OctreeElement* element);
|
||||||
virtual void elementUpdated(OctreeElement* element);
|
virtual void elementUpdated(OctreeElement* element);
|
||||||
|
|
||||||
bool treeIsBusy() const { return _treeIsBusy; }
|
|
||||||
|
|
||||||
VoxelTreeElement* getVoxelEnclosing(const glm::vec3& point);
|
VoxelTreeElement* getVoxelEnclosing(const glm::vec3& point);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -144,9 +142,6 @@ public slots:
|
||||||
void setUseVoxelShader(bool useVoxelShader);
|
void setUseVoxelShader(bool useVoxelShader);
|
||||||
void setVoxelsAsPoints(bool voxelsAsPoints);
|
void setVoxelsAsPoints(bool voxelsAsPoints);
|
||||||
|
|
||||||
void localVoxelCacheLoaded();
|
|
||||||
void beginLoadingLocalVoxelCache();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
float _treeScale;
|
float _treeScale;
|
||||||
unsigned long _maxVoxels;
|
unsigned long _maxVoxels;
|
||||||
|
@ -304,10 +299,6 @@ private:
|
||||||
bool _useFastVoxelPipeline;
|
bool _useFastVoxelPipeline;
|
||||||
|
|
||||||
bool _inhideOutOfView;
|
bool _inhideOutOfView;
|
||||||
bool _treeIsBusy; // is the tree mutex locked? if so, it's busy, and if you can avoid it, don't access the tree
|
|
||||||
|
|
||||||
void lockTree();
|
|
||||||
void unlockTree();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue