Workaround for import / export in opensim.

This commit is contained in:
phr0z3nt04st
2010-06-19 23:33:00 -05:00
parent 543a04fd81
commit 2f3a1c9f52
2 changed files with 34 additions and 43 deletions

View File

@@ -1,3 +1,4 @@
// <edit> // <edit>
/** /**
* @file llimportobject.cpp * @file llimportobject.cpp
@@ -35,6 +36,7 @@ int LLXmlImport::sPrimIndex = 0;
int LLXmlImport::sAttachmentsDone = 0; int LLXmlImport::sAttachmentsDone = 0;
std::map<std::string, U32> LLXmlImport::sId2localid; std::map<std::string, U32> LLXmlImport::sId2localid;
std::map<U32, LLVector3> LLXmlImport::sRootpositions; std::map<U32, LLVector3> LLXmlImport::sRootpositions;
std::map<U32, LLQuaternion> LLXmlImport::sRootrotations;
LLXmlImportOptions* LLXmlImport::sXmlImportOptions; LLXmlImportOptions* LLXmlImport::sXmlImportOptions;
LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options) LLXmlImportOptions::LLXmlImportOptions(LLXmlImportOptions* options)
@@ -514,12 +516,13 @@ void LLXmlImport::onNewPrim(LLViewerObject* object)
flags = flags & (~FLAGS_USE_PHYSICS); flags = flags & (~FLAGS_USE_PHYSICS);
object->setFlags(flags, TRUE); object->setFlags(flags, TRUE);
object->setFlags(~flags, FALSE); // Can I improve this lol? object->setFlags(~flags, FALSE); // Can I improve this lol?
bool root = (from->mParentId == "");
if(from->mParentId == "") if(root)
{ {
// this will be a root // this will be a root
sId2localid[from->mId] = object->getLocalID(); sId2localid[from->mId] = object->getLocalID();
sRootpositions[object->getLocalID()] = from->getPosition(); sRootpositions[object->getLocalID()] = from->getPosition();
sRootrotations[object->getLocalID()] = from->getRotation();
// If it's an attachment, set description // If it's an attachment, set description
if(from->importIsAttachment) if(from->importIsAttachment)
{ {
@@ -535,36 +538,10 @@ void LLXmlImport::onNewPrim(LLViewerObject* object)
} }
else else
{ {
// Move it to its root before linking //make positions and rotations offset from the root prim.
U32 parentlocalid = sId2localid[from->mParentId]; U32 parentlocalid = sId2localid[from->mParentId];
LLVector3 rootpos = sRootpositions[parentlocalid]; from->setPosition((from->getPosition() * sRootrotations[parentlocalid]) + sRootpositions[parentlocalid]);
from->setRotation(from->getRotation() * sRootrotations[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());
} }
// Volume params // Volume params
LLVolumeParams params = from->getVolume()->getParams(); LLVolumeParams params = from->getVolume()->getParams();
@@ -673,8 +650,33 @@ void LLXmlImport::onNewPrim(LLViewerObject* object)
gMessageSystem->addStringFast(_PREHASH_Name, from->mPrimName); gMessageSystem->addStringFast(_PREHASH_Name, from->mPrimName);
gMessageSystem->sendReliable(gAgent.getRegionHost()); 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()) 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) if(sId2attachpt.size() == 0)
{ {
sImportInProgress = false; sImportInProgress = false;
@@ -715,18 +717,6 @@ void LLXmlImport::onNewPrim(LLViewerObject* object)
gMessageSystem->sendReliable(gAgent.getRegionHost()); 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(); LLFloaterImportProgress::update();
rez_supply(); rez_supply();

View File

@@ -77,6 +77,7 @@ public:
static int sAttachmentsDone; static int sAttachmentsDone;
static std::map<std::string, U32> sId2localid; static std::map<std::string, U32> sId2localid;
static std::map<U32, LLVector3> sRootpositions; static std::map<U32, LLVector3> sRootpositions;
static std::map<U32, LLQuaternion> sRootrotations;
static LLXmlImportOptions* sXmlImportOptions; static LLXmlImportOptions* sXmlImportOptions;
}; };