summaryrefslogtreecommitdiff
path: root/indra/newview/llviewerobject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewerobject.cpp')
-rwxr-xr-xindra/newview/llviewerobject.cpp259
1 files changed, 244 insertions, 15 deletions
diff --git a/indra/newview/llviewerobject.cpp b/indra/newview/llviewerobject.cpp
index 6f7b2f40e6..6362ccfba6 100755
--- a/indra/newview/llviewerobject.cpp
+++ b/indra/newview/llviewerobject.cpp
@@ -39,6 +39,7 @@
#include "llfloaterreg.h"
#include "llfontgl.h"
#include "llframetimer.h"
+#include "llhudicon.h"
#include "llinventory.h"
#include "llinventorydefines.h"
#include "llmaterialtable.h"
@@ -100,6 +101,7 @@
#include "lltrans.h"
#include "llsdutil.h"
#include "llmediaentry.h"
+#include "llvocache.h"
//#define DEBUG_UPDATE_TYPE
@@ -112,6 +114,9 @@ BOOL LLViewerObject::sMapDebug = TRUE;
LLColor4 LLViewerObject::sEditSelectColor( 1.0f, 1.f, 0.f, 0.3f); // Edit OK
LLColor4 LLViewerObject::sNoEditSelectColor( 1.0f, 0.f, 0.f, 0.3f); // Can't edit
S32 LLViewerObject::sAxisArrowLength(50);
+LLTrace::MemStatHandle LLViewerObject::sMemStat("LLViewerObject");
+
+
BOOL LLViewerObject::sPulseEnabled(FALSE);
BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
@@ -119,6 +124,7 @@ BOOL LLViewerObject::sUseSharedDrawables(FALSE); // TRUE
F64 LLViewerObject::sMaxUpdateInterpolationTime = 3.0; // For motion interpolation: after X seconds with no updates, don't predict object motion
F64 LLViewerObject::sPhaseOutUpdateInterpolationTime = 2.0; // For motion interpolation: after Y seconds with no updates, taper off motion prediction
+std::map<std::string, U32> LLViewerObject::sObjectDataMap;
static LLFastTimer::DeclareTimer FTM_CREATE_OBJECT("Create Object");
@@ -351,6 +357,10 @@ void LLViewerObject::markDead()
// Mark itself as dead
mDead = TRUE;
+ if(mRegionp)
+ {
+ mRegionp->removeFromCreatedList(getLocalID());
+ }
gObjectList.cleanupReferences(this);
LLViewerObject *childp;
@@ -495,6 +505,8 @@ void LLViewerObject::initVOClasses()
LLVOGrass::initClass();
LLVOWater::initClass();
LLVOVolume::initClass();
+
+ initObjectDataMap();
}
void LLViewerObject::cleanupVOClasses()
@@ -504,6 +516,118 @@ void LLViewerObject::cleanupVOClasses()
LLVOTree::cleanupClass();
LLVOAvatar::cleanupClass();
LLVOVolume::cleanupClass();
+
+ sObjectDataMap.clear();
+}
+
+//object data map for compressed && !OUT_TERSE_IMPROVED
+//static
+void LLViewerObject::initObjectDataMap()
+{
+ U32 count = 0;
+
+ sObjectDataMap["ID"] = count; //full id //LLUUID
+ count += sizeof(LLUUID);
+
+ sObjectDataMap["LocalID"] = count; //U32
+ count += sizeof(U32);
+
+ sObjectDataMap["PCode"] = count; //U8
+ count += sizeof(U8);
+
+ sObjectDataMap["State"] = count; //U8
+ count += sizeof(U8);
+
+ sObjectDataMap["CRC"] = count; //U32
+ count += sizeof(U32);
+
+ sObjectDataMap["Material"] = count; //U8
+ count += sizeof(U8);
+
+ sObjectDataMap["ClickAction"] = count; //U8
+ count += sizeof(U8);
+
+ sObjectDataMap["Scale"] = count; //LLVector3
+ count += sizeof(LLVector3);
+
+ sObjectDataMap["Pos"] = count; //LLVector3
+ count += sizeof(LLVector3);
+
+ sObjectDataMap["Rot"] = count; //LLVector3
+ count += sizeof(LLVector3);
+
+ sObjectDataMap["SpecialCode"] = count; //U32
+ count += sizeof(U32);
+
+ sObjectDataMap["Owner"] = count; //LLUUID
+ count += sizeof(LLUUID);
+
+ sObjectDataMap["Omega"] = count; //LLVector3, when SpecialCode & 0x80 is set
+ count += sizeof(LLVector3);
+
+ //ParentID is after Omega if there is Omega, otherwise is after Owner
+ sObjectDataMap["ParentID"] = count;//U32, when SpecialCode & 0x20 is set
+ count += sizeof(U32);
+
+ //-------
+ //The rest items are not included here
+ //-------
+}
+
+//static
+void LLViewerObject::unpackVector3(LLDataPackerBinaryBuffer* dp, LLVector3& value, std::string name)
+{
+ dp->shift(sObjectDataMap[name]);
+ dp->unpackVector3(value, name.c_str());
+ dp->reset();
+}
+
+//static
+void LLViewerObject::unpackUUID(LLDataPackerBinaryBuffer* dp, LLUUID& value, std::string name)
+{
+ dp->shift(sObjectDataMap[name]);
+ dp->unpackUUID(value, name.c_str());
+ dp->reset();
+}
+
+//static
+void LLViewerObject::unpackU32(LLDataPackerBinaryBuffer* dp, U32& value, std::string name)
+{
+ dp->shift(sObjectDataMap[name]);
+ dp->unpackU32(value, name.c_str());
+ dp->reset();
+}
+
+//static
+void LLViewerObject::unpackU8(LLDataPackerBinaryBuffer* dp, U8& value, std::string name)
+{
+ dp->shift(sObjectDataMap[name]);
+ dp->unpackU8(value, name.c_str());
+ dp->reset();
+}
+
+//static
+U32 LLViewerObject::unpackParentID(LLDataPackerBinaryBuffer* dp, U32& parent_id)
+{
+ dp->shift(sObjectDataMap["SpecialCode"]);
+ U32 value;
+ dp->unpackU32(value, "SpecialCode");
+
+ parent_id = 0;
+ if(value & 0x20)
+ {
+ S32 offset = sObjectDataMap["ParentID"];
+ if(!(value & 0x80))
+ {
+ offset -= sizeof(LLVector3);
+ }
+
+ dp->shift(offset);
+ dp->unpackU32(parent_id, "ParentID");
+ }
+ dp->reset();
+
+ return parent_id;
}
// Replaces all name value pairs with data from \n delimited list
@@ -895,6 +1019,29 @@ U32 LLViewerObject::checkMediaURL(const std::string &media_url)
return retval;
}
+//extract spatial information from object update message
+//return parent_id
+//static
+U32 LLViewerObject::extractSpatialExtents(LLDataPackerBinaryBuffer *dp, LLVector3& pos, LLVector3& scale, LLQuaternion& rot)
+{
+ U32 parent_id = 0;
+ LLViewerObject::unpackParentID(dp, parent_id);
+ if(parent_id > 0)
+ {
+ //is a child, no need to decode further.
+ return parent_id;
+ }
+
+ LLViewerObject::unpackVector3(dp, scale, "Scale");
+ LLViewerObject::unpackVector3(dp, pos, "Pos");
+
+ LLVector3 vec;
+ LLViewerObject::unpackVector3(dp, vec, "Rot");
+ rot.unpackFromVector3(vec);
+
+ return parent_id;
+}
+
U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
void **user_data,
U32 block_num,
@@ -911,10 +1058,11 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
}
// Coordinates of objects on simulators are region-local.
- U64 region_handle;
- mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
+ U64 region_handle = 0;
+ if(mesgsys != NULL)
{
+ mesgsys->getU64Fast(_PREHASH_RegionData, _PREHASH_RegionHandle, region_handle);
LLViewerRegion* regionp = LLWorld::getInstance()->getRegionFromHandle(region_handle);
if(regionp != mRegionp && regionp && mRegionp)//region cross
{
@@ -927,6 +1075,17 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
}
else
{
+ if(regionp != mRegionp)
+ {
+ if(mRegionp)
+ {
+ mRegionp->removeFromCreatedList(getLocalID());
+ }
+ if(regionp)
+ {
+ regionp->addToCreatedList(getLocalID());
+ }
+ }
mRegionp = regionp ;
}
}
@@ -940,11 +1099,14 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
return retval;
}
+ if(mesgsys != NULL)
+ {
U16 time_dilation16;
mesgsys->getU16Fast(_PREHASH_RegionData, _PREHASH_TimeDilation, time_dilation16);
F32 time_dilation = ((F32) time_dilation16) / 65535.f;
mTimeDilation = time_dilation;
mRegionp->setTimeDilation(time_dilation);
+ }
// this will be used to determine if we've really changed position
// Use getPosition, not getPositionRegion, since this is what we're comparing directly against.
@@ -1717,13 +1879,12 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
// Preload these five flags for every object.
// Finer shades require the object to be selected, and the selection manager
// stores the extended permission info.
+ if(mesgsys != NULL)
+ {
U32 flags;
mesgsys->getU32Fast(_PREHASH_ObjectData, _PREHASH_UpdateFlags, flags, block_num);
- // keep local flags and overwrite remote-controlled flags
- mFlags = (mFlags & FLAGS_LOCAL) | flags;
-
- // ...new objects that should come in selected need to be added to the selected list
- mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+ loadFlags(flags);
+ }
}
break;
@@ -1751,10 +1912,21 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
{
// No parent now, new parent in message -> attach to that parent if possible
LLUUID parent_uuid;
+
+ if(mesgsys != NULL)
+ {
LLViewerObjectList::getUUIDFromLocal(parent_uuid,
parent_id,
mesgsys->getSenderIP(),
mesgsys->getSenderPort());
+ }
+ else
+ {
+ LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+ parent_id,
+ mRegionp->getHost().getAddress(),
+ mRegionp->getHost().getPort());
+ }
LLViewerObject *sent_parentp = gObjectList.findObject(parent_uuid);
@@ -1830,9 +2002,18 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
//
//parent_id
- U32 ip = mesgsys->getSenderIP();
- U32 port = mesgsys->getSenderPort();
+ U32 ip, port;
+ if(mesgsys != NULL)
+ {
+ ip = mesgsys->getSenderIP();
+ port = mesgsys->getSenderPort();
+ }
+ else
+ {
+ ip = mRegionp->getHost().getAddress();
+ port = mRegionp->getHost().getPort();
+ }
gObjectList.orphanize(this, parent_id, ip, port);
// Hide particles, icon and HUD
@@ -1870,10 +2051,21 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
else
{
LLUUID parent_uuid;
+
+ if(mesgsys != NULL)
+ {
LLViewerObjectList::getUUIDFromLocal(parent_uuid,
parent_id,
gMessageSystem->getSenderIP(),
gMessageSystem->getSenderPort());
+ }
+ else
+ {
+ LLViewerObjectList::getUUIDFromLocal(parent_uuid,
+ parent_id,
+ mRegionp->getHost().getAddress(),
+ mRegionp->getHost().getPort());
+ }
sent_parentp = gObjectList.findObject(parent_uuid);
if (isAvatar())
@@ -1894,8 +2086,18 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
//
// Switching parents, but we don't know the new parent.
//
- U32 ip = mesgsys->getSenderIP();
- U32 port = mesgsys->getSenderPort();
+ U32 ip, port;
+
+ if(mesgsys != NULL)
+ {
+ ip = mesgsys->getSenderIP();
+ port = mesgsys->getSenderPort();
+ }
+ else
+ {
+ ip = mRegionp->getHost().getAddress();
+ port = mRegionp->getHost().getPort();
+ }
// We're an orphan, flag things appropriately.
gObjectList.orphanize(this, parent_id, ip, port);
@@ -1979,7 +2181,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
new_rot.normQuat();
- if (sPingInterpolate)
+ if (sPingInterpolate && mesgsys != NULL)
{
LLCircuitData *cdp = gMessageSystem->mCircuitInfo.findCircuit(mesgsys->getSender());
if (cdp)
@@ -2002,6 +2204,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
// If we're going to skip this message, why are we
// doing all the parenting, etc above?
+ if(mesgsys != NULL)
+ {
U32 packet_id = mesgsys->getCurrentRecvPacketID();
if (packet_id < mLatestRecvPacketID &&
mLatestRecvPacketID - packet_id < 65536)
@@ -2009,8 +2213,8 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
//skip application of this message, it's old
return retval;
}
-
mLatestRecvPacketID = packet_id;
+ }
// Set the change flags for scale
if (new_scale != getScale())
@@ -2058,7 +2262,7 @@ U32 LLViewerObject::processUpdateMessage(LLMessageSystem *mesgsys,
// If we're snapping the position by more than 0.5m, update LLViewerStats::mAgentPositionSnaps
if ( asAvatar() && asAvatar()->isSelf() && (mag_sqr > 0.25f) )
{
- LLViewerStats::getInstance()->mAgentPositionSnaps.push( diff.length() );
+ record(LLStatViewer::AGENT_POSITION_SNAP, LLTrace::Meters(diff.length()));
}
}
@@ -2181,7 +2385,21 @@ BOOL LLViewerObject::isActive() const
return TRUE;
}
+//load flags from cache or from message
+void LLViewerObject::loadFlags(U32 flags)
+{
+ if(flags == (U32)(-1))
+ {
+ return; //invalid
+ }
+
+ // keep local flags and overwrite remote-controlled flags
+ mFlags = (mFlags & FLAGS_LOCAL) | flags;
+ // ...new objects that should come in selected need to be added to the selected list
+ mCreateSelected = ((flags & FLAGS_CREATE_SELECTED) != 0);
+ return;
+}
void LLViewerObject::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
{
@@ -4061,7 +4279,7 @@ void LLViewerObject::setTE(const U8 te, const LLTextureEntry &texture_entry)
{
LLPrimitive::setTE(te, texture_entry);
- const LLUUID& image_id = getTE(te)->getID();
+ const LLUUID& image_id = getTE(te)->getID();
mTEImages[te] = LLViewerTextureManager::getFetchedTexture(image_id, FTT_DEFAULT, TRUE, LLGLTexture::BOOST_NONE, LLViewerTexture::LOD_TEXTURE);
if (getTE(te)->getMaterialParams().notNull())
@@ -5485,6 +5703,17 @@ void LLViewerObject::setRegion(LLViewerRegion *regionp)
{
llwarns << "viewer object set region to NULL" << llendl;
}
+ if(regionp != mRegionp)
+ {
+ if(mRegionp)
+ {
+ mRegionp->removeFromCreatedList(getLocalID());
+ }
+ if(regionp)
+ {
+ regionp->addToCreatedList(getLocalID());
+ }
+ }
mLatestRecvPacketID = 0;
mRegionp = regionp;