From 1c7a593517ab87f7fe57a316c07aa6db4f6adfe3 Mon Sep 17 00:00:00 2001 From: Cinders Date: Thu, 12 Sep 2013 19:58:11 -0600 Subject: [PATCH] FIRE-11593: Opensim "4096 Bug" proposed fix generously contributed by Latif Khalifa --- indra/llmath/lloctree.h | 4 ++-- indra/newview/llviewermessage.cpp | 19 +++++++++++++++++++ indra/newview/llviewerpartsim.cpp | 8 ++++++-- indra/newview/llviewerregion.cpp | 14 ++++++++++++++ indra/newview/llviewerregion.h | 2 ++ 5 files changed, 43 insertions(+), 4 deletions(-) diff --git a/indra/llmath/lloctree.h b/indra/llmath/lloctree.h index ebcf9651ec..97bd7f98b3 100755 --- a/indra/llmath/lloctree.h +++ b/indra/llmath/lloctree.h @@ -396,6 +396,7 @@ public: child->insert(data); } } +#ifndef OPENSIM // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa else { //it's not in here, give it to the root @@ -411,6 +412,7 @@ public: node->insert(data); } +#endif // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa return false; } @@ -734,7 +736,6 @@ public: return false; } -#ifndef OPENSIM // FIRE-11593; Don't limit center of octree to 2^20, otherwise we end with the famous longjump bug (cannot TP further than 4095 regions [4096*256 = 2^20] LLVector4a MAX_MAG; MAX_MAG.splat(1024.f*1024.f); @@ -750,7 +751,6 @@ public: //OCT_ERRS << "!!! ELEMENT EXCEEDS RANGE OF SPATIAL PARTITION !!!" << llendl; return false; } -#endif // FIRE-11593 if (this->getSize()[0] > data->getBinRadius() && this->isInside(data->getPositionGroup())) { diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index a28544aa13..063c2e43cb 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5066,6 +5066,25 @@ void process_agent_movement_complete(LLMessageSystem* msg, void**) gAgent.getRegion()->getOriginGlobal()); gAgent.setRegion(regionp); gObjectList.shiftObjects(shift_vector); +// FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa +#ifdef OPENSIM + // Is this a really long jump? + if (shift_vector.length() > 2048.f * 256.f) + { + regionp->reInitPartitions(); + gAgent.setRegion(regionp); + // Kill objects in the regions we left behind + for (LLWorld::region_list_t::const_iterator r = LLWorld::getInstance()->getRegionList().begin(); + r != LLWorld::getInstance()->getRegionList().end(); ++r) + { + if (*r != regionp) + { + gObjectList.killObjects(*r); + } + } + } +#endif +// gAssetStorage->setUpstream(msg->getSender()); gCacheName->setUpstream(msg->getSender()); gViewerThrottle.sendToSim(); diff --git a/indra/newview/llviewerpartsim.cpp b/indra/newview/llviewerpartsim.cpp index d5849e0b1e..ede800a405 100755 --- a/indra/newview/llviewerpartsim.cpp +++ b/indra/newview/llviewerpartsim.cpp @@ -705,7 +705,9 @@ void LLViewerPartSim::updateSimulation() LLViewerObject* vobj = mViewerPartGroups[i]->mVOPartGroupp; S32 visirate = 1; - if (vobj) + // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa + //if (vobj) + if (vobj && vobj->mDrawable) { LLSpatialGroup* group = vobj->mDrawable->getSpatialGroup(); if (group && !group->isVisible()) // && !group->isState(LLSpatialGroup::OBJECT_DIRTY)) @@ -716,7 +718,9 @@ void LLViewerPartSim::updateSimulation() if ((LLDrawable::getCurrentFrame()+mViewerPartGroups[i]->mID)%visirate == 0) { - if (vobj) + // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa + // mDrawable) { gPipeline.markRebuild(vobj->mDrawable, LLDrawable::REBUILD_ALL, TRUE); } diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp index ab0944ae6d..d3dc8a1041 100755 --- a/indra/newview/llviewerregion.cpp +++ b/indra/newview/llviewerregion.cpp @@ -396,6 +396,12 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, // Create the object lists initStats(); +// FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa + initPartitions(); +} +void LLViewerRegion::initPartitions() +{ +// //create object partitions //MUST MATCH declaration of eObjectPartitions @@ -412,6 +418,14 @@ LLViewerRegion::LLViewerRegion(const U64 &handle, mImpl->mObjectPartition.push_back(NULL); //PARTITION_NONE } +// FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa +void LLViewerRegion::reInitPartitions() +{ + std::for_each(mImpl->mObjectPartition.begin(), mImpl->mObjectPartition.end(), DeletePointer()); + mImpl->mObjectPartition.clear(); + initPartitions(); +} +// void LLViewerRegion::initStats() { diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h index 13073b4aeb..b3c9c25da7 100755 --- a/indra/newview/llviewerregion.h +++ b/indra/newview/llviewerregion.h @@ -388,10 +388,12 @@ public: }; void showReleaseNotes(); + void reInitPartitions(); // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa protected: void disconnectAllNeighbors(); void initStats(); + void initPartitions(); // FIRE-11593: Opensim "4096 Bug" Fix by Latif Khalifa public: LLWind mWind;