diff --git a/indra/newview/llimportobject.cpp b/indra/newview/llimportobject.cpp index db5abc3ea..16b9057c1 100644 --- a/indra/newview/llimportobject.cpp +++ b/indra/newview/llimportobject.cpp @@ -35,6 +35,7 @@ std::map LLXmlImport::sId2attachpt; std::map LLXmlImport::sPt2watch; std::map LLXmlImport::sPt2attachpos; std::map LLXmlImport::sPt2attachrot; +std::map > LLXmlImport::sLinkSets; int LLXmlImport::sPrimIndex = 0; int LLXmlImport::sAttachmentsDone = 0; std::map LLXmlImport::sId2localid; @@ -661,6 +662,8 @@ void LLXmlImport::import(LLXmlImportOptions* import_options) sUploadedAssets = 0; sId2localid.clear(); sRootpositions.clear(); + sRootrotations.clear(); + sLinkSets.clear(); LLFloaterImportProgress::show(); LLFloaterImportProgress::update(); @@ -788,8 +791,7 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) flags = flags & (~FLAGS_USE_PHYSICS); object->setFlags(flags, TRUE); object->setFlags(~flags, FALSE); // Can I improve this lol? - bool root = (from->mParentId == ""); - if(root) + if(from->mParentId == "") { // this will be a root sId2localid[from->mId] = object->getLocalID(); @@ -814,6 +816,8 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) U32 parentlocalid = sId2localid[from->mParentId]; from->setPosition((from->getPosition() * sRootrotations[parentlocalid]) + sRootpositions[parentlocalid]); from->setRotation(from->getRotation() * sRootrotations[parentlocalid]); + sLinkSets[parentlocalid].push(object->getLocalID()); //this is here so we dont get 1 prim objects into the linkset queue + } // Volume params LLVolumeParams params = from->getVolume()->getParams(); @@ -927,22 +931,44 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) gMessageSystem->sendReliable(gAgent.getRegionHost()); } - // Link - if(!root) - { - gMessageSystem->newMessageFast(_PREHASH_ObjectLink); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, sId2localid[from->mParentId]); - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID()); - gMessageSystem->sendReliable(gAgent.getRegionHost()); - } - if(currPrimIndex + 1 >= (int)sPrims.size()) { + // Link time + int packet_len = 0; + for(std::map >::iterator itr = sLinkSets.begin();itr != sLinkSets.end();++itr) + { + std::queue linkset = (*itr).second; + gMessageSystem->newMessageFast(_PREHASH_ObjectLink); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, (*itr).first);//this is the parent prim + while(!linkset.empty()) + { + if(packet_len == 254) //if we have 255 objects, using 254 because root counts as 1 too + { + gMessageSystem->sendReliable(gAgent.getRegionHost()); + packet_len = 0; + gMessageSystem->newMessageFast(_PREHASH_ObjectLink); + gMessageSystem->nextBlockFast(_PREHASH_AgentData); + gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); + gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, (*itr).first);//this is the parent prim + } + gMessageSystem->nextBlockFast(_PREHASH_ObjectData); + gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, linkset.front()); + linkset.pop(); + packet_len++; + } + if(packet_len) //send if it hasnt been yet + { + gMessageSystem->sendReliable(gAgent.getRegionHost()); + packet_len = 0; + } + } + // stop the throttle F32 throttle = gSavedSettings.getF32("OutBandwidth"); if(throttle != 0.) diff --git a/indra/newview/llimportobject.h b/indra/newview/llimportobject.h index 1da236cae..da1d4beb7 100644 --- a/indra/newview/llimportobject.h +++ b/indra/newview/llimportobject.h @@ -97,6 +97,7 @@ public: static std::map sId2attachpt; // attach points of all attachables static std::map sPt2attachpos; // positions of all attachables static std::map sPt2attachrot; // rotations of all attachables + static std::map > sLinkSets;//Linksets to link. static int sPrimIndex; static int sAttachmentsDone; static std::map sId2localid;