mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Merge pull request #10888 from jherico/overlay_crashes
Trying to fix overlay crashes again
This commit is contained in:
commit
c058a166d4
3 changed files with 22 additions and 61 deletions
|
@ -67,19 +67,14 @@ void Overlays::init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Overlays::update(float deltatime) {
|
void Overlays::update(float deltatime) {
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysHUD;
|
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysWorld;
|
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
overlaysHUD = _overlaysHUD;
|
foreach(const auto& thisOverlay, _overlaysHUD) {
|
||||||
overlaysWorld = _overlaysWorld;
|
thisOverlay->update(deltatime);
|
||||||
}
|
}
|
||||||
|
foreach(const auto& thisOverlay, _overlaysWorld) {
|
||||||
foreach(const auto& thisOverlay, overlaysHUD) {
|
thisOverlay->update(deltatime);
|
||||||
thisOverlay->update(deltatime);
|
}
|
||||||
}
|
|
||||||
foreach(const auto& thisOverlay, overlaysWorld) {
|
|
||||||
thisOverlay->update(deltatime);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupOverlaysToDelete();
|
cleanupOverlaysToDelete();
|
||||||
|
@ -119,14 +114,8 @@ void Overlays::renderHUD(RenderArgs* renderArgs) {
|
||||||
int height = size.y;
|
int height = size.y;
|
||||||
mat4 legacyProjection = glm::ortho<float>(0, width, height, 0, -1000, 1000);
|
mat4 legacyProjection = glm::ortho<float>(0, width, height, 0, -1000, 1000);
|
||||||
|
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysHUD;
|
QMutexLocker locker(&_mutex);
|
||||||
{
|
foreach(Overlay::Pointer thisOverlay, _overlaysHUD) {
|
||||||
QMutexLocker locker(&_mutex);
|
|
||||||
overlaysHUD = _overlaysHUD;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach(Overlay::Pointer thisOverlay, overlaysHUD) {
|
|
||||||
|
|
||||||
// Reset all batch pipeline settings between overlay
|
// Reset all batch pipeline settings between overlay
|
||||||
geometryCache->useSimpleDrawPipeline(batch);
|
geometryCache->useSimpleDrawPipeline(batch);
|
||||||
|
@ -400,36 +389,22 @@ OverlayID Overlays::getOverlayAtPoint(const glm::vec2& point) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
glm::vec2 pointCopy = point;
|
|
||||||
if (!_enabled) {
|
if (!_enabled) {
|
||||||
return UNKNOWN_OVERLAY_ID;
|
return UNKNOWN_OVERLAY_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysHUD;
|
QMutexLocker locker(&_mutex);
|
||||||
{
|
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysHUD);
|
||||||
QMutexLocker locker(&_mutex);
|
|
||||||
overlaysHUD = _overlaysHUD;
|
|
||||||
}
|
|
||||||
QMapIterator<OverlayID, Overlay::Pointer> i(overlaysHUD);
|
|
||||||
|
|
||||||
const float LARGE_NEGATIVE_FLOAT = -9999999;
|
|
||||||
glm::vec3 origin(pointCopy.x, pointCopy.y, LARGE_NEGATIVE_FLOAT);
|
|
||||||
glm::vec3 direction(0, 0, 1);
|
|
||||||
glm::vec3 thisSurfaceNormal;
|
|
||||||
unsigned int bestStackOrder = 0;
|
unsigned int bestStackOrder = 0;
|
||||||
OverlayID bestOverlayID = UNKNOWN_OVERLAY_ID;
|
OverlayID bestOverlayID = UNKNOWN_OVERLAY_ID;
|
||||||
|
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
OverlayID thisID = i.key();
|
auto thisOverlay = std::dynamic_pointer_cast<Overlay2D>(i.value());
|
||||||
if (!i.value()->is3D()) {
|
if (thisOverlay && thisOverlay->getVisible() && thisOverlay->isLoaded() &&
|
||||||
auto thisOverlay = std::dynamic_pointer_cast<Overlay2D>(i.value());
|
thisOverlay->getBoundingRect().contains(point.x, point.y, false)) {
|
||||||
if (thisOverlay && thisOverlay->getVisible() && thisOverlay->isLoaded() &&
|
if (thisOverlay->getStackOrder() > bestStackOrder) {
|
||||||
thisOverlay->getBoundingRect().contains(pointCopy.x, pointCopy.y, false)) {
|
bestOverlayID = i.key();
|
||||||
if (thisOverlay->getStackOrder() > bestStackOrder) {
|
bestStackOrder = thisOverlay->getStackOrder();
|
||||||
bestOverlayID = thisID;
|
|
||||||
bestStackOrder = thisOverlay->getStackOrder();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -498,14 +473,9 @@ RayToOverlayIntersectionResult Overlays::findRayIntersectionInternal(const PickR
|
||||||
float bestDistance = std::numeric_limits<float>::max();
|
float bestDistance = std::numeric_limits<float>::max();
|
||||||
bool bestIsFront = false;
|
bool bestIsFront = false;
|
||||||
|
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysWorld;
|
QMutexLocker locker(&_mutex);
|
||||||
{
|
|
||||||
QMutexLocker locker(&_mutex);
|
|
||||||
overlaysWorld = _overlaysWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
RayToOverlayIntersectionResult result;
|
RayToOverlayIntersectionResult result;
|
||||||
QMapIterator<OverlayID, Overlay::Pointer> i(overlaysWorld);
|
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysWorld);
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
i.next();
|
i.next();
|
||||||
OverlayID thisID = i.key();
|
OverlayID thisID = i.key();
|
||||||
|
@ -995,13 +965,8 @@ QVector<QUuid> Overlays::findOverlays(const glm::vec3& center, float radius) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMap<OverlayID, Overlay::Pointer> overlaysWorld;
|
QMutexLocker locker(&_mutex);
|
||||||
{
|
QMapIterator<OverlayID, Overlay::Pointer> i(_overlaysWorld);
|
||||||
QMutexLocker locker(&_mutex);
|
|
||||||
overlaysWorld = _overlaysWorld;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMapIterator<OverlayID, Overlay::Pointer> i(overlaysWorld);
|
|
||||||
int checked = 0;
|
int checked = 0;
|
||||||
while (i.hasNext()) {
|
while (i.hasNext()) {
|
||||||
checked++;
|
checked++;
|
||||||
|
|
|
@ -198,11 +198,7 @@ gpu::TexturePointer TextureCache::getTextureByHash(const std::string& hash) {
|
||||||
std::unique_lock<std::mutex> lock(_texturesByHashesMutex);
|
std::unique_lock<std::mutex> lock(_texturesByHashesMutex);
|
||||||
weakPointer = _texturesByHashes[hash];
|
weakPointer = _texturesByHashes[hash];
|
||||||
}
|
}
|
||||||
auto result = weakPointer.lock();
|
return weakPointer.lock();
|
||||||
if (result) {
|
|
||||||
qCWarning(modelnetworking) << "QQQ Returning live texture for hash " << hash.c_str();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gpu::TexturePointer TextureCache::cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture) {
|
gpu::TexturePointer TextureCache::cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture) {
|
||||||
|
|
|
@ -1821,7 +1821,7 @@ void ScriptEngine::include(const QStringList& includeFiles, QScriptValue callbac
|
||||||
clearExceptions();
|
clearExceptions();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
scriptWarningMessage("Script.include() skipping evaluation of previously included url:" + url.toString());
|
scriptPrintedMessage("Script.include() skipping evaluation of previously included url:" + url.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue