diff --git a/indra/newview/llimportobject.cpp b/indra/newview/llimportobject.cpp index 6e9e9e4a5..e0e93118d 100644 --- a/indra/newview/llimportobject.cpp +++ b/indra/newview/llimportobject.cpp @@ -1,3 +1,4 @@ + // /** * @file llimportobject.cpp @@ -35,6 +36,7 @@ int LLXmlImport::sPrimIndex = 0; int LLXmlImport::sAttachmentsDone = 0; std::map LLXmlImport::sId2localid; std::map LLXmlImport::sRootpositions; +std::map LLXmlImport::sRootrotations; LLXmlImportOptions* LLXmlImport::sXmlImportOptions; LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options) @@ -514,12 +516,13 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) flags = flags & (~FLAGS_USE_PHYSICS); object->setFlags(flags, TRUE); object->setFlags(~flags, FALSE); // Can I improve this lol? - - if(from->mParentId == "") + bool root = (from->mParentId == ""); + if(root) { // this will be a root sId2localid[from->mId] = object->getLocalID(); sRootpositions[object->getLocalID()] = from->getPosition(); + sRootrotations[object->getLocalID()] = from->getRotation(); // If it's an attachment, set description if(from->importIsAttachment) { @@ -535,36 +538,10 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) } else { - // Move it to its root before linking + //make positions and rotations offset from the root prim. U32 parentlocalid = sId2localid[from->mParentId]; - LLVector3 rootpos = sRootpositions[parentlocalid]; - - U8 data[256]; - S32 offset = 0; - gMessageSystem->newMessageFast(_PREHASH_MultipleObjectUpdate); - gMessageSystem->nextBlockFast(_PREHASH_AgentData); - gMessageSystem->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); - gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); - gMessageSystem->nextBlockFast(_PREHASH_ObjectData); - gMessageSystem->addU32Fast(_PREHASH_ObjectLocalID, object->getLocalID()); - gMessageSystem->addU8Fast(_PREHASH_Type, 5); - htonmemcpy(&data[offset], &(rootpos.mV), MVT_LLVector3, 12); - offset += 12; - htonmemcpy(&data[offset], &(from->getScale().mV), MVT_LLVector3, 12); - offset += 12; - gMessageSystem->addBinaryDataFast(_PREHASH_Data, data, offset); - gMessageSystem->sendReliable(gAgent.getRegionHost()); - - // Link it up - 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()); + from->setPosition((from->getPosition() * sRootrotations[parentlocalid]) + sRootpositions[parentlocalid]); + from->setRotation(from->getRotation() * sRootrotations[parentlocalid]); } // Volume params LLVolumeParams params = from->getVolume()->getParams(); @@ -673,8 +650,33 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) gMessageSystem->addStringFast(_PREHASH_Name, from->mPrimName); gMessageSystem->sendReliable(gAgent.getRegionHost()); } + + // Link + 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()) { + // stop the throttle + F32 throttle = gSavedSettings.getF32("OutBandwidth"); + if(throttle != 0.) + { + gMessageSystem->mPacketRing.setOutBandwidth(throttle); + gMessageSystem->mPacketRing.setUseOutThrottle(TRUE); + } + else + { + gMessageSystem->mPacketRing.setOutBandwidth(0.0); + gMessageSystem->mPacketRing.setUseOutThrottle(FALSE); + } + if(sId2attachpt.size() == 0) { sImportInProgress = false; @@ -715,18 +717,6 @@ void LLXmlImport::onNewPrim(LLViewerObject* object) gMessageSystem->sendReliable(gAgent.getRegionHost()); } } - - F32 throttle = gSavedSettings.getF32("OutBandwidth"); - if(throttle != 0.) - { - gMessageSystem->mPacketRing.setOutBandwidth(throttle); - gMessageSystem->mPacketRing.setUseOutThrottle(TRUE); - } - else - { - gMessageSystem->mPacketRing.setOutBandwidth(0.0); - gMessageSystem->mPacketRing.setUseOutThrottle(FALSE); - } } LLFloaterImportProgress::update(); rez_supply(); diff --git a/indra/newview/llimportobject.h b/indra/newview/llimportobject.h index 2769c5bf7..1e1e8897c 100644 --- a/indra/newview/llimportobject.h +++ b/indra/newview/llimportobject.h @@ -77,6 +77,7 @@ public: static int sAttachmentsDone; static std::map sId2localid; static std::map sRootpositions; + static std::map sRootrotations; static LLXmlImportOptions* sXmlImportOptions; };