Merge git://github.com/Shyotl/SingularityViewer

This commit is contained in:
Siana Gearz
2011-03-25 03:41:11 +01:00
10 changed files with 167 additions and 102 deletions

View File

@@ -1908,7 +1908,12 @@ BOOL LLDataPackerAsciiFile::getValueStr(const char *name, char *out_value, S32 v
if (mFP) if (mFP)
{ {
fpos_t last_pos; fpos_t last_pos;
fgetpos(mFP, &last_pos); if (0 != fgetpos(mFP, &last_pos)) // 0==success for fgetpos
{
llwarns << "Data packer failed to fgetpos" << llendl;
return FALSE;
}
if (fgets(buffer, DP_BUFSIZE, mFP) == NULL) if (fgets(buffer, DP_BUFSIZE, mFP) == NULL)
{ {
buffer[0] = '\0'; buffer[0] = '\0';

View File

@@ -1056,7 +1056,7 @@ void clear_glerror()
// //
// Static members // Static members
std::map<LLGLenum, LLGLboolean> LLGLState::sStateMap; boost::unordered_map<LLGLenum, LLGLboolean> LLGLState::sStateMap;
GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default GLboolean LLGLDepthTest::sDepthEnabled = GL_FALSE; // OpenGL default
GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default GLenum LLGLDepthTest::sDepthFunc = GL_LESS; // OpenGL default
@@ -1104,7 +1104,7 @@ void LLGLState::resetTextureStates()
void LLGLState::dumpStates() void LLGLState::dumpStates()
{ {
LL_INFOS("RenderState") << "GL States:" << LL_ENDL; LL_INFOS("RenderState") << "GL States:" << LL_ENDL;
for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin(); for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
iter != sStateMap.end(); ++iter) iter != sStateMap.end(); ++iter)
{ {
LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)iter->first,iter->second?"TRUE":"FALSE") << LL_ENDL; LL_INFOS("RenderState") << llformat(" 0x%04x : %s",(S32)iter->first,iter->second?"TRUE":"FALSE") << LL_ENDL;
@@ -1130,7 +1130,7 @@ void LLGLState::checkStates(const std::string& msg)
LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << LL_ENDL; LL_GL_ERRS << "Blend function corrupted: " << std::hex << src << " " << std::hex << dst << " " << msg << std::dec << LL_ENDL;
} }
for (std::map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin(); for (boost::unordered_map<LLGLenum, LLGLboolean>::iterator iter = sStateMap.begin();
iter != sStateMap.end(); ++iter) iter != sStateMap.end(); ++iter)
{ {
LLGLenum state = iter->first; LLGLenum state = iter->first;
@@ -1769,6 +1769,8 @@ LLGLDepthTest::LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled, G
: mPrevDepthEnabled(sDepthEnabled), mPrevDepthFunc(sDepthFunc), mPrevWriteEnabled(sWriteEnabled) : mPrevDepthEnabled(sDepthEnabled), mPrevDepthFunc(sDepthFunc), mPrevWriteEnabled(sWriteEnabled)
{ {
stop_glerror(); stop_glerror();
checkState();
if (!depth_enabled) if (!depth_enabled)
{ // always disable depth writes if depth testing is disabled { // always disable depth writes if depth testing is disabled
@@ -1800,6 +1802,7 @@ LLGLDepthTest::LLGLDepthTest(GLboolean depth_enabled, GLboolean write_enabled, G
LLGLDepthTest::~LLGLDepthTest() LLGLDepthTest::~LLGLDepthTest()
{ {
checkState();
if (sDepthEnabled != mPrevDepthEnabled ) if (sDepthEnabled != mPrevDepthEnabled )
{ {
gGL.flush(); gGL.flush();
@@ -1821,6 +1824,26 @@ LLGLDepthTest::~LLGLDepthTest()
} }
} }
void LLGLDepthTest::checkState()
{
if (gDebugGL)
{
GLint func = 0;
GLboolean mask = FALSE;
glGetIntegerv(GL_DEPTH_FUNC, &func);
glGetBooleanv(GL_DEPTH_WRITEMASK, &mask);
if (glIsEnabled(GL_DEPTH_TEST) != sDepthEnabled ||
sWriteEnabled != mask ||
sDepthFunc != func)
{
{
LL_GL_ERRS << "Unexpected depth testing state." << LL_ENDL;
}
}
}
}
LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P) LLGLSquashToFarClip::LLGLSquashToFarClip(glh::matrix4f P)
{ {
for (U32 i = 0; i < 4; i++) for (U32 i = 0; i < 4; i++)

View File

@@ -36,6 +36,7 @@
// This file contains various stuff for handling gl extensions and other gl related stuff. // This file contains various stuff for handling gl extensions and other gl related stuff.
#include <string> #include <string>
#include <boost/unordered_map.hpp>
#include <map> #include <map>
#include "llerror.h" #include "llerror.h"
@@ -233,7 +234,7 @@ public:
static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001); static void checkClientArrays(const std::string& msg = "", U32 data_mask = 0x0001);
protected: protected:
static std::map<LLGLenum, LLGLboolean> sStateMap; static boost::unordered_map<LLGLenum, LLGLboolean> sStateMap;
public: public:
enum { CURRENT_STATE = -2 }; enum { CURRENT_STATE = -2 };

View File

@@ -1041,7 +1041,11 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat
mPartitionType = LLViewerRegion::PARTITION_VOLUME; mPartitionType = LLViewerRegion::PARTITION_VOLUME;
mOctree->balance(); mOctree->balance();
llassert(mDrawable);
llassert(mDrawable->getRegion());
LLSpatialPartition *part = mDrawable->getRegion()->getSpatialPartition(mPartitionType); LLSpatialPartition *part = mDrawable->getRegion()->getSpatialPartition(mPartitionType);
llassert(part);
if (part) if (part)
{ {
@@ -1360,6 +1364,9 @@ void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL imm
BOOL LLSpatialBridge::updateMove() BOOL LLSpatialBridge::updateMove()
{ {
llassert_always(mDrawable);
llassert_always(mDrawable->mVObjp);
llassert_always(mDrawable->getRegion());
LLSpatialPartition* part = mDrawable->getRegion()->getSpatialPartition(mPartitionType); LLSpatialPartition* part = mDrawable->getRegion()->getSpatialPartition(mPartitionType);
llassert_always(part); llassert_always(part);
mOctree->balance(); mOctree->balance();

View File

@@ -299,8 +299,11 @@ void LLDrawPoolAlpha::renderAlpha(U32 mask)
for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i) for (LLCullResult::sg_list_t::iterator i = gPipeline.beginAlphaGroups(); i != gPipeline.endAlphaGroups(); ++i)
{ {
LLSpatialGroup* group = *i; LLSpatialGroup* group = *i;
llassert(group);
llassert(group->mSpatialPartition);
if (group->mSpatialPartition->mRenderByGroup && if (group->mSpatialPartition->mRenderByGroup &&
!group->isDead()) !group->isDead())
{ {
bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow. bool draw_glow_for_this_partition = mVertexShaderLevel > 0 && // no shaders = no glow.
// All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress. // All particle systems seem to come off the wire with texture entries which claim that they glow. This is probably a bug in the data. Suppress.

View File

@@ -1056,11 +1056,11 @@ void LLViewerObjectList::renderObjectBeacons()
S32 last_line_width = -1; S32 last_line_width = -1;
// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
BOOL flush = FALSE; BOOL flush = FALSE;
for (S32 i = 0; i < mDebugBeacons.count(); i++) for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
{ {
const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; const LLDebugBeacon &debug_beacon = *iter;
LLColor4 color = debug_beacon.mColor; LLColor4 color = debug_beacon.mColor;
color.mV[3] *= 0.25f; color.mV[3] *= 0.25f;
S32 line_width = debug_beacon.mLineWidth; S32 line_width = debug_beacon.mLineWidth;
@@ -1098,10 +1098,10 @@ void LLViewerObjectList::renderObjectBeacons()
S32 last_line_width = -1; S32 last_line_width = -1;
// gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width) // gGL.begin(LLRender::LINES); // Always happens in (line_width != last_line_width)
BOOL flush = FALSE; BOOL flush = FALSE;
for (S32 i = 0; i < mDebugBeacons.count(); i++) for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
{ {
const LLDebugBeacon &debug_beacon = mDebugBeacons[i]; const LLDebugBeacon &debug_beacon = *iter;
S32 line_width = debug_beacon.mLineWidth; S32 line_width = debug_beacon.mLineWidth;
if (line_width != last_line_width) if (line_width != last_line_width)
@@ -1133,9 +1133,9 @@ void LLViewerObjectList::renderObjectBeacons()
gGL.flush(); gGL.flush();
glLineWidth(1.f); glLineWidth(1.f);
for (S32 i = 0; i < mDebugBeacons.count(); i++) for (std::vector<LLDebugBeacon>::iterator iter = mDebugBeacons.begin(); iter != mDebugBeacons.end(); ++iter)
{ {
LLDebugBeacon &debug_beacon = mDebugBeacons[i]; LLDebugBeacon &debug_beacon = *iter;
if (debug_beacon.mString == "") if (debug_beacon.mString == "")
{ {
continue; continue;

View File

@@ -356,12 +356,14 @@ void LLSurfacePatch::calcNormal(const U32 x, const U32 y, const U32 stride)
normal %= c2; normal %= c2;
normal.normVec(); normal.normVec();
llassert(mDataNorm);
*(mDataNorm + surface_stride * y + x) = normal; *(mDataNorm + surface_stride * y + x) = normal;
} }
const LLVector3 &LLSurfacePatch::getNormal(const U32 x, const U32 y) const const LLVector3 &LLSurfacePatch::getNormal(const U32 x, const U32 y) const
{ {
U32 surface_stride = mSurfacep->getGridsPerEdge(); U32 surface_stride = mSurfacep->getGridsPerEdge();
llassert(mDataNorm);
return *(mDataNorm + surface_stride * y + x); return *(mDataNorm + surface_stride * y + x);
} }
@@ -403,6 +405,7 @@ void LLSurfacePatch::updateVerticalStats()
U32 i, j, k; U32 i, j, k;
F32 z, total; F32 z, total;
llassert(mDataZ);
z = *(mDataZ); z = *(mDataZ);
mMinZ = z; mMinZ = z;

View File

@@ -2148,6 +2148,10 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
{ {
LLFloaterGroupInfo::showNotice(subj,mes,group_id,has_inventory,item_name,info); LLFloaterGroupInfo::showNotice(subj,mes,group_id,has_inventory,item_name,info);
} }
else
{
delete info;
}
} }
break; break;
case IM_GROUP_INVITATION: case IM_GROUP_INVITATION:
@@ -2209,6 +2213,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
if (sizeof(offer_agent_bucket_t) != binary_bucket_size) if (sizeof(offer_agent_bucket_t) != binary_bucket_size)
{ {
LL_WARNS("Messaging") << "Malformed inventory offer from agent" << LL_ENDL; LL_WARNS("Messaging") << "Malformed inventory offer from agent" << LL_ENDL;
delete info;
break; break;
} }
bucketp = (struct offer_agent_bucket_t*) &binary_bucket[0]; bucketp = (struct offer_agent_bucket_t*) &binary_bucket[0];
@@ -2227,6 +2232,7 @@ void process_improved_im(LLMessageSystem *msg, void **user_data)
if (sizeof(S8) != binary_bucket_size) if (sizeof(S8) != binary_bucket_size)
{ {
LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL; LL_WARNS("Messaging") << "Malformed inventory offer from object" << LL_ENDL;
delete info;
break; break;
} }
info->mType = (LLAssetType::EType) binary_bucket[0]; info->mType = (LLAssetType::EType) binary_bucket[0];
@@ -3577,6 +3583,9 @@ void process_teleport_finish(LLMessageSystem* msg, void**)
LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL; LL_WARNS("Messaging") << "Got teleport notification for wrong agent!" << LL_ENDL;
return; return;
} }
// Teleport is finished; it can't be cancelled now.
gViewerWindow->setProgressCancelButtonVisible(FALSE);
// Do teleport effect for where you're leaving // Do teleport effect for where you're leaving
// VEFFECT: TeleportStart // VEFFECT: TeleportStart
@@ -6181,6 +6190,9 @@ void handle_lure(const LLUUID& invitee)
// Prompt for a message to the invited user. // Prompt for a message to the invited user.
void handle_lure(LLDynamicArray<LLUUID>& ids) void handle_lure(LLDynamicArray<LLUUID>& ids)
{ {
if (ids.empty()) return;
if (!gAgent.getRegion()) return;
LLSD edit_args; LLSD edit_args;
// [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a) // [RLVa:KB] - Version: 1.23.4 | Checked: 2009-07-04 (RLVa-1.0.0a)
edit_args["REGION"] = edit_args["REGION"] =
@@ -6715,7 +6727,6 @@ void onCovenantLoadComplete(LLVFS *vfs,
// Version 0 (just text, doesn't include version number) // Version 0 (just text, doesn't include version number)
covenant_text = editor->getText(); covenant_text = editor->getText();
} }
delete[] buffer;
delete editor; delete editor;
} }
else else
@@ -6723,6 +6734,7 @@ void onCovenantLoadComplete(LLVFS *vfs,
LL_WARNS("Messaging") << "Problem importing estate covenant: Covenant file format error." << LL_ENDL; LL_WARNS("Messaging") << "Problem importing estate covenant: Covenant file format error." << LL_ENDL;
covenant_text = "Problem importing estate covenant: Covenant file format error."; covenant_text = "Problem importing estate covenant: Covenant file format error.";
} }
delete[] buffer;
} }
else else
{ {

View File

@@ -95,7 +95,7 @@ extern LLPipeline gPipeline;
// Statics for object lookup tables. // Statics for object lookup tables.
U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check. U32 LLViewerObjectList::sSimulatorMachineIndex = 1; // Not zero deliberately, to speed up index check.
LLMap<U64, U32> LLViewerObjectList::sIPAndPortToIndex; std::map<U64, U32> LLViewerObjectList::sIPAndPortToIndex;
std::map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID; std::map<U64, LLUUID> LLViewerObjectList::sIndexAndLocalIDToUUID;
LLViewerObjectList::LLViewerObjectList() LLViewerObjectList::LLViewerObjectList()
@@ -594,10 +594,9 @@ void LLViewerObjectList::processCachedObjectUpdate(LLMessageSystem *mesgsys,
void LLViewerObjectList::dirtyAllObjectInventory() void LLViewerObjectList::dirtyAllObjectInventory()
{ {
S32 count = mObjects.count(); for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
for(S32 i = 0; i < count; ++i)
{ {
mObjects[i]->dirtyInventory(); (*iter)->dirtyInventory();
} }
} }
@@ -610,14 +609,14 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
S32 num_updates, max_value; S32 num_updates, max_value;
if (NUM_BINS - 1 == mCurBin) if (NUM_BINS - 1 == mCurBin)
{ {
num_updates = mObjects.count() - mCurLazyUpdateIndex; num_updates = (S32) mObjects.size() - mCurLazyUpdateIndex;
max_value = mObjects.count(); max_value = (S32) mObjects.size();
gImageList.setUpdateStats(TRUE); gImageList.setUpdateStats(TRUE);
} }
else else
{ {
num_updates = (mObjects.count() / NUM_BINS) + 1; num_updates = ((S32) mObjects.size() / NUM_BINS) + 1;
max_value = llmin(mObjects.count(), mCurLazyUpdateIndex + num_updates); max_value = llmin((S32) mObjects.size(), mCurLazyUpdateIndex + num_updates);
} }
@@ -666,7 +665,7 @@ void LLViewerObjectList::updateApparentAngles(LLAgent &agent)
} }
mCurLazyUpdateIndex = max_value; mCurLazyUpdateIndex = max_value;
if (mCurLazyUpdateIndex == mObjects.count()) if (mCurLazyUpdateIndex == mObjects.size())
{ {
mCurLazyUpdateIndex = 0; mCurLazyUpdateIndex = 0;
} }
@@ -827,7 +826,7 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
} }
*/ */
mNumObjectsStat.addValue(mObjects.count()); mNumObjectsStat.addValue((S32) mObjects.size());
mNumActiveObjectsStat.addValue(num_active_objects); mNumActiveObjectsStat.addValue(num_active_objects);
mNumSizeCulledStat.addValue(mNumSizeCulled); mNumSizeCulledStat.addValue(mNumSizeCulled);
mNumVisCulledStat.addValue(mNumVisCulled); mNumVisCulledStat.addValue(mNumVisCulled);
@@ -835,9 +834,9 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
void LLViewerObjectList::clearDebugText() void LLViewerObjectList::clearDebugText()
{ {
for (S32 i = 0; i < mObjects.count(); i++) for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{ {
mObjects[i]->setDebugText(""); (*iter)->setDebugText("");
} }
} }
@@ -845,14 +844,13 @@ void LLViewerObjectList::clearDebugText()
void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp) void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
{ {
LLMemType mt(LLMemType::MTYPE_OBJECT); LLMemType mt(LLMemType::MTYPE_OBJECT);
if (mDeadObjects.find(objectp->mID) != mDeadObjects.end()) if (mDeadObjects.count(objectp->mID))
{ {
llinfos << "Object " << objectp->mID << " already on dead list, ignoring cleanup!" << llendl; llinfos << "Object " << objectp->mID << " already on dead list, ignoring cleanup!" << llendl;
return;
} }
else
{ mDeadObjects.insert(std::pair<LLUUID, LLPointer<LLViewerObject> >(objectp->mID, objectp));
mDeadObjects.insert(std::pair<LLUUID, LLPointer<LLViewerObject> >(objectp->mID, objectp));
}
// Cleanup any references we have to this object // Cleanup any references we have to this object
// Remove from object map so noone can look it up. // Remove from object map so noone can look it up.
@@ -878,7 +876,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
if (objectp->isOnMap()) if (objectp->isOnMap())
{ {
mMapObjects.removeObj(objectp); removeFromMap(objectp);
} }
// Don't clean up mObject references, these will be cleaned up more efficiently later! // Don't clean up mObject references, these will be cleaned up more efficiently later!
@@ -935,10 +933,10 @@ void LLViewerObjectList::killObjects(LLViewerRegion *regionp)
{ {
LLViewerObject *objectp; LLViewerObject *objectp;
S32 i;
for (i = 0; i < mObjects.count(); i++) for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{ {
objectp = mObjects[i]; objectp = *iter;
if (objectp->mRegionp == regionp) if (objectp->mRegionp == regionp)
{ {
@@ -955,9 +953,9 @@ void LLViewerObjectList::killAllObjects()
// Used only on global destruction. // Used only on global destruction.
LLViewerObject *objectp; LLViewerObject *objectp;
for (S32 i = 0; i < mObjects.count(); i++) for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{ {
objectp = mObjects[i]; objectp = *iter;
killObject(objectp); killObject(objectp);
llassert(objectp->isDead()); llassert(objectp->isDead());
@@ -967,7 +965,7 @@ void LLViewerObjectList::killAllObjects()
if(!mObjects.empty()) if(!mObjects.empty())
{ {
llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.count() << llendl; llwarns << "LLViewerObjectList::killAllObjects still has entries in mObjects: " << mObjects.size() << llendl;
mObjects.clear(); mObjects.clear();
} }
@@ -992,16 +990,15 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
return; return;
} }
S32 i = 0;
S32 num_removed = 0; S32 num_removed = 0;
LLViewerObject *objectp; LLViewerObject *objectp;
while (i < mObjects.count()) for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); )
{ {
// Scan for all of the dead objects and remove any "global" references to them. // Scan for all of the dead objects and remove any "global" references to them.
objectp = mObjects[i]; objectp = *iter;
if (objectp->isDead()) if (objectp->isDead())
{ {
mObjects.remove(i); iter = mObjects.erase(iter);
num_removed++; num_removed++;
if (num_removed == mNumDeadObjects) if (num_removed == mNumDeadObjects)
@@ -1012,8 +1009,7 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
} }
else else
{ {
// iterate, this isn't a dead object. ++iter;
i++;
} }
} }
@@ -1063,10 +1059,9 @@ void LLViewerObjectList::shiftObjects(const LLVector3 &offset)
} }
LLViewerObject *objectp; LLViewerObject *objectp;
S32 i; for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
for (i = 0; i < mObjects.count(); i++)
{ {
objectp = getObject(i); objectp = *iter;
// There could be dead objects on the object list, so don't update stuff if the object is dead. // There could be dead objects on the object list, so don't update stuff if the object is dead.
if (objectp && !objectp->isDead()) if (objectp && !objectp->isDead())
{ {
@@ -1098,10 +1093,14 @@ void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap)
F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius"); F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius");
for (S32 i = 0; i < mMapObjects.count(); i++) for (vobj_list_t::iterator iter = mMapObjects.begin(); iter != mMapObjects.end(); ++iter)
{ {
LLViewerObject* objectp = mMapObjects[i]; LLViewerObject* objectp = *iter;
if (objectp->isDead() || !objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment())
llassert_always(objectp);
llassert_always(!objectp->isDead());
if (!objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment())
{ {
continue; continue;
} }
@@ -1177,10 +1176,9 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
LLViewerObject *objectp; LLViewerObject *objectp;
S32 i; S32 i;
// Reset all of the GL names to zero. // Reset all of the GL names to zero.
for (i = 0; i < mObjects.count(); i++) for (vobj_list_t::iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{ {
objectp = mObjects[i]; (*iter)->mGLName = 0;
objectp->mGLName = 0;
} }
mSelectPickList.clear(); mSelectPickList.clear();
@@ -1240,6 +1238,7 @@ void LLViewerObjectList::generatePickList(LLCamera &camera)
LLVOAvatar* avatarp = gAgent.getAvatarObject(); LLVOAvatar* avatarp = gAgent.getAvatarObject();
if (avatarp) if (avatarp)
{ {
LLVOAvatar* avatarp = gAgent.getAvatarObject();
for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin(); for (LLVOAvatar::attachment_map_t::iterator iter = avatarp->mAttachmentPoints.begin();
iter != avatarp->mAttachmentPoints.end(); ) iter != avatarp->mAttachmentPoints.end(); )
{ {
@@ -1343,17 +1342,19 @@ void LLViewerObjectList::addDebugBeacon(const LLVector3 &pos_agent,
const LLColor4 &text_color, const LLColor4 &text_color,
S32 line_width) S32 line_width)
{ {
LLDebugBeacon *beaconp = mDebugBeacons.reserve_block(1); LLDebugBeacon beacon;
beaconp->mPositionAgent = pos_agent; beacon.mPositionAgent = pos_agent;
beaconp->mString = string; beacon.mString = string;
beaconp->mColor = color; beacon.mColor = color;
beaconp->mTextColor = text_color; beacon.mTextColor = text_color;
beaconp->mLineWidth = line_width; beacon.mLineWidth = line_width;
mDebugBeacons.push_back(beacon);
} }
void LLViewerObjectList::resetObjectBeacons() void LLViewerObjectList::resetObjectBeacons()
{ {
mDebugBeacons.reset(); mDebugBeacons.clear();
} }
LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp) LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLViewerRegion *regionp)
@@ -1377,7 +1378,7 @@ LLViewerObject *LLViewerObjectList::createObjectViewer(const LLPCode pcode, LLVi
mUUIDAvatarMap[fullid] = pAvatar; mUUIDAvatarMap[fullid] = pAvatar;
} }
mObjects.put(objectp); mObjects.push_back(objectp);
updateActive(objectp); updateActive(objectp);
@@ -1421,7 +1422,7 @@ LLViewerObject *LLViewerObjectList::createObject(const LLPCode pcode, LLViewerRe
gMessageSystem->getSenderIP(), gMessageSystem->getSenderIP(),
gMessageSystem->getSenderPort()); gMessageSystem->getSenderPort());
mObjects.put(objectp); mObjects.push_back(objectp);
updateActive(objectp); updateActive(objectp);
@@ -1433,7 +1434,7 @@ LLViewerObject *LLViewerObjectList::replaceObject(const LLUUID &id, const LLPCod
LLViewerObject *old_instance = findObject(id); LLViewerObject *old_instance = findObject(id);
if (old_instance) if (old_instance)
{ {
cleanupReferences(old_instance); //cleanupReferences(old_instance);
old_instance->markDead(); old_instance->markDead();
return createObject(pcode, regionp, id, old_instance->getLocalID(), LLHost()); return createObject(pcode, regionp, id, old_instance->getLocalID(), LLHost());
@@ -1444,11 +1445,11 @@ LLViewerObject *LLViewerObjectList::replaceObject(const LLUUID &id, const LLPCod
S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const S32 LLViewerObjectList::findReferences(LLDrawable *drawablep) const
{ {
LLViewerObject *objectp; LLViewerObject *objectp;
S32 i;
S32 num_refs = 0; S32 num_refs = 0;
for (i = 0; i < mObjects.count(); i++)
for (vobj_list_t::const_iterator iter = mObjects.begin(); iter != mObjects.end(); ++iter)
{ {
objectp = mObjects[i]; objectp = *iter;
if (objectp->mDrawable.notNull()) if (objectp->mDrawable.notNull())
{ {
num_refs += objectp->mDrawable->findReferences(drawablep); num_refs += objectp->mDrawable->findReferences(drawablep);
@@ -1493,15 +1494,15 @@ void LLViewerObjectList::orphanize(LLViewerObject *childp, U32 parent_id, U32 ip
// Unknown parent, add to orpaned child list // Unknown parent, add to orpaned child list
U64 parent_info = getIndex(parent_id, ip, port); U64 parent_info = getIndex(parent_id, ip, port);
if (-1 == mOrphanParents.find(parent_info)) if (std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info) == mOrphanParents.end())
{ {
mOrphanParents.put(parent_info); mOrphanParents.push_back(parent_info);
} }
LLViewerObjectList::OrphanInfo oi(parent_info, childp->mID); LLViewerObjectList::OrphanInfo oi(parent_info, childp->mID);
if (-1 == mOrphanChildren.find(oi)) if (std::find(mOrphanChildren.begin(), mOrphanChildren.end(), oi) == mOrphanChildren.end())
{ {
mOrphanChildren.put(oi); mOrphanChildren.push_back(oi);
mNumOrphans++; mNumOrphans++;
} }
} }
@@ -1524,28 +1525,29 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
// See if we are a parent of an orphan. // See if we are a parent of an orphan.
// Note: This code is fairly inefficient but it should happen very rarely. // Note: This code is fairly inefficient but it should happen very rarely.
// It can be sped up if this is somehow a performance issue... // It can be sped up if this is somehow a performance issue...
if (0 == mOrphanParents.count()) if (mOrphanParents.empty())
{ {
// no known orphan parents // no known orphan parents
return; return;
} }
if (-1 == mOrphanParents.find(getIndex(objectp->mLocalID, ip, port))) if (std::find(mOrphanParents.begin(), mOrphanParents.end(), getIndex(objectp->mLocalID, ip, port)) == mOrphanParents.end())
{ {
// did not find objectp in OrphanParent list // did not find objectp in OrphanParent list
return; return;
} }
S32 i;
U64 parent_info = getIndex(objectp->mLocalID, ip, port); U64 parent_info = getIndex(objectp->mLocalID, ip, port);
BOOL orphans_found = FALSE; BOOL orphans_found = FALSE;
// Iterate through the orphan list, and set parents of matching children. // Iterate through the orphan list, and set parents of matching children.
for (i = 0; i < mOrphanChildren.count(); i++)
{ for (std::vector<OrphanInfo>::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); )
if (mOrphanChildren[i].mParentInfo != parent_info) {
if (iter->mParentInfo != parent_info)
{ {
++iter;
continue; continue;
} }
LLViewerObject *childp = findObject(mOrphanChildren[i].mChildInfo); LLViewerObject *childp = findObject(iter->mChildInfo);
if (childp) if (childp)
{ {
if (childp == objectp) if (childp == objectp)
@@ -1579,29 +1581,35 @@ void LLViewerObjectList::findOrphans(LLViewerObject* objectp, U32 ip, U32 port)
objectp->addChild(childp); objectp->addChild(childp);
orphans_found = TRUE; orphans_found = TRUE;
++iter;
} }
else else
{ {
llinfos << "Missing orphan child, removing from list" << llendl; llinfos << "Missing orphan child, removing from list" << llendl;
mOrphanChildren.remove(i);
i--; iter = mOrphanChildren.erase(iter);
} }
} }
// Remove orphan parent and children from lists now that they've been found // Remove orphan parent and children from lists now that they've been found
mOrphanParents.remove(mOrphanParents.find(parent_info));
i = 0;
while (i < mOrphanChildren.count())
{ {
if (mOrphanChildren[i].mParentInfo == parent_info) std::vector<U64>::iterator iter = std::find(mOrphanParents.begin(), mOrphanParents.end(), parent_info);
if (iter != mOrphanParents.end())
{ {
mOrphanChildren.remove(i); mOrphanParents.erase(iter);
}
}
for (std::vector<OrphanInfo>::iterator iter = mOrphanChildren.begin(); iter != mOrphanChildren.end(); )
{
if (iter->mParentInfo == parent_info)
{
iter = mOrphanChildren.erase(iter);
mNumOrphans--; mNumOrphans--;
} }
else else
{ {
i++; ++iter;
} }
} }

View File

@@ -38,7 +38,6 @@
// common includes // common includes
#include "llstat.h" #include "llstat.h"
#include "lldarrayptr.h"
#include "llstring.h" #include "llstring.h"
// project includes // project includes
@@ -49,7 +48,7 @@ class LLNetMap;
class LLDebugBeacon; class LLDebugBeacon;
const U32 CLOSE_BIN_SIZE = 10; const U32 CLOSE_BIN_SIZE = 10;
const U32 NUM_BINS = 16; const U32 NUM_BINS = 128;
// GL name = position in object list + GL_NAME_INDEX_OFFSET so that // GL name = position in object list + GL_NAME_INDEX_OFFSET so that
// we can have special numbers like zero. // we can have special numbers like zero.
@@ -119,9 +118,7 @@ public:
LLViewerObject *getSelectedObject(const U32 object_id); LLViewerObject *getSelectedObject(const U32 object_id);
inline S32 getNumObjects() { return mObjects.count(); } inline S32 getNumObjects() { return (S32) mObjects.size(); }
LLDynamicArrayPtr<LLPointer<LLViewerObject> > getObjectMap(){ return mMapObjects; }
void addToMap(LLViewerObject *objectp); void addToMap(LLViewerObject *objectp);
void removeFromMap(LLViewerObject *objectp); void removeFromMap(LLViewerObject *objectp);
@@ -135,7 +132,7 @@ public:
S32 findReferences(LLDrawable *drawablep) const; // Find references to drawable in all objects, and return value. S32 findReferences(LLDrawable *drawablep) const; // Find references to drawable in all objects, and return value.
S32 getOrphanParentCount() const { return mOrphanParents.count(); } S32 getOrphanParentCount() const { return (S32) mOrphanParents.size(); }
S32 getOrphanCount() const { return mNumOrphans; } S32 getOrphanCount() const { return mNumOrphans; }
void orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port); void orphanize(LLViewerObject *childp, U32 parent_id, U32 ip, U32 port);
void findOrphans(LLViewerObject* objectp, U32 ip, U32 port); void findOrphans(LLViewerObject* objectp, U32 ip, U32 port);
@@ -194,14 +191,16 @@ public:
S32 mNumUnknownKills; S32 mNumUnknownKills;
S32 mNumDeadObjects; S32 mNumDeadObjects;
protected: protected:
LLDynamicArray<U64> mOrphanParents; // LocalID/ip,port of orphaned objects std::vector<U64> mOrphanParents; // LocalID/ip,port of orphaned objects
LLDynamicArray<OrphanInfo> mOrphanChildren; // UUID's of orphaned objects std::vector<OrphanInfo> mOrphanChildren; // UUID's of orphaned objects
S32 mNumOrphans; S32 mNumOrphans;
LLDynamicArrayPtr<LLPointer<LLViewerObject>, 256> mObjects; typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
vobj_list_t mObjects;
std::set<LLPointer<LLViewerObject> > mActiveObjects; std::set<LLPointer<LLViewerObject> > mActiveObjects;
LLDynamicArrayPtr<LLPointer<LLViewerObject> > mMapObjects; vobj_list_t mMapObjects;
typedef std::map<LLUUID, LLPointer<LLViewerObject> > vo_map; typedef std::map<LLUUID, LLPointer<LLViewerObject> > vo_map;
vo_map mDeadObjects; // Need to keep multiple entries per UUID vo_map mDeadObjects; // Need to keep multiple entries per UUID
@@ -209,12 +208,12 @@ protected:
std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap; std::map<LLUUID, LLPointer<LLViewerObject> > mUUIDObjectMap;
std::map<LLUUID, LLPointer<LLVOAvatar> > mUUIDAvatarMap; std::map<LLUUID, LLPointer<LLVOAvatar> > mUUIDAvatarMap;
LLDynamicArray<LLDebugBeacon> mDebugBeacons; std::vector<LLDebugBeacon> mDebugBeacons;
S32 mCurLazyUpdateIndex; S32 mCurLazyUpdateIndex;
static U32 sSimulatorMachineIndex; static U32 sSimulatorMachineIndex;
static LLMap<U64, U32> sIPAndPortToIndex; static std::map<U64, U32> sIPAndPortToIndex;
static std::map<U64, LLUUID> sIndexAndLocalIDToUUID; static std::map<U64, LLUUID> sIndexAndLocalIDToUUID;
@@ -282,12 +281,16 @@ inline LLViewerObject *LLViewerObjectList::getObject(const S32 index)
inline void LLViewerObjectList::addToMap(LLViewerObject *objectp) inline void LLViewerObjectList::addToMap(LLViewerObject *objectp)
{ {
mMapObjects.put(objectp); mMapObjects.push_back(objectp);
} }
inline void LLViewerObjectList::removeFromMap(LLViewerObject *objectp) inline void LLViewerObjectList::removeFromMap(LLViewerObject *objectp)
{ {
mMapObjects.removeObj(objectp); std::vector<LLPointer<LLViewerObject> >::iterator iter = std::find(mMapObjects.begin(), mMapObjects.end(), objectp);
if (iter != mMapObjects.end())
{
mMapObjects.erase(iter);
}
} }