Catch up with viewer-beta. Primarily sim transition alterations to reduce frame hitching, and some optimization in LLViewerObjectList (std::set -> std::vector and and some allocation tweakage).

This commit is contained in:
Shyotl
2012-10-20 17:02:43 -05:00
parent 43271f290e
commit b73f4dd8e4
20 changed files with 218 additions and 96 deletions

View File

@@ -63,6 +63,8 @@ const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f;
static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound");
extern bool gShiftFrame;
//////////////////////// ////////////////////////
// //
@@ -722,6 +724,11 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update)
return; return;
} }
if (gShiftFrame)
{
return;
}
//switch LOD with the spatial group to avoid artifacts //switch LOD with the spatial group to avoid artifacts
//LLSpatialGroup* sg = getSpatialGroup(); //LLSpatialGroup* sg = getSpatialGroup();
@@ -820,14 +827,19 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
mXform.setPosition(mVObjp->getPositionAgent()); mXform.setPosition(mVObjp->getPositionAgent());
} }
mXform.setRotation(mVObjp->getRotation());
mXform.setScale(1,1,1);
mXform.updateMatrix(); mXform.updateMatrix();
if (isStatic()) if (isStatic())
{ {
LLVOVolume* volume = getVOVolume(); LLVOVolume* volume = getVOVolume();
if (!volume)
bool rebuild = (!volume &&
getRenderType() != LLPipeline::RENDER_TYPE_TREE &&
getRenderType() != LLPipeline::RENDER_TYPE_TERRAIN &&
getRenderType() != LLPipeline::RENDER_TYPE_SKY &&
getRenderType() != LLPipeline::RENDER_TYPE_GROUND);
if (rebuild)
{ {
gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE); gPipeline.markRebuild(this, LLDrawable::REBUILD_ALL, TRUE);
} }
@@ -841,7 +853,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector)
facep->mExtents[0].add(shift_vector); facep->mExtents[0].add(shift_vector);
facep->mExtents[1].add(shift_vector); facep->mExtents[1].add(shift_vector);
if (!volume && facep->hasGeometry()) if (rebuild && facep->hasGeometry())
{ {
facep->clearVertexBuffer(); facep->clearVertexBuffer();
} }
@@ -960,6 +972,12 @@ LLSpatialGroup* LLDrawable::getSpatialGroup() const
void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp) void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
{ {
//precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this
llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this));
//precondition: groupp MUST be null or groupp MUST contain this
llassert(!groupp || groupp->hasElement(this));
/*if (mSpatialGroupp && (groupp != mSpatialGroupp)) /*if (mSpatialGroupp && (groupp != mSpatialGroupp))
{ {
mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY); mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY);
@@ -979,9 +997,12 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp)
} }
} }
mSpatialGroupp = groupp; //postcondition: if next group is NULL, previous group must be dead OR NULL OR binIndex must be -1
//postcondition: if next group is NOT NULL, binIndex must not be -1
llassert(groupp == NULL ? (mSpatialGroupp == NULL || mSpatialGroupp->isDead()) || getBinIndex() == -1 :
getBinIndex() != -1);
llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1); mSpatialGroupp = groupp;
} }
LLSpatialPartition* LLDrawable::getSpatialPartition() LLSpatialPartition* LLDrawable::getSpatialPartition()
@@ -1416,6 +1437,11 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update)
return; return;
} }
if (gShiftFrame)
{
return;
}
if (mDrawable->getVObj()) if (mDrawable->getVObj())
{ {
if (mDrawable->getVObj()->isAttachment()) if (mDrawable->getVObj()->isAttachment())
@@ -1499,13 +1525,11 @@ void LLSpatialBridge::cleanupReferences()
LLDrawable::cleanupReferences(); LLDrawable::cleanupReferences();
if (mDrawable) if (mDrawable)
{ {
LLSpatialGroup* group = mDrawable->getSpatialGroup(); /*
if (group)
{
group->mOctreeNode->remove(mDrawable);
mDrawable->setSpatialGroup(NULL);
}
DON'T DO THIS -- this should happen through octree destruction
mDrawable->setSpatialGroup(NULL);
if (mDrawable->getVObj()) if (mDrawable->getVObj())
{ {
LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren();
@@ -1516,15 +1540,10 @@ void LLSpatialBridge::cleanupReferences()
LLDrawable* drawable = child->mDrawable; LLDrawable* drawable = child->mDrawable;
if (drawable) if (drawable)
{ {
LLSpatialGroup* group = drawable->getSpatialGroup();
if (group)
{
group->mOctreeNode->remove(drawable);
drawable->setSpatialGroup(NULL); drawable->setSpatialGroup(NULL);
} }
} }
} }*/
}
LLDrawable* drawablep = mDrawable; LLDrawable* drawablep = mDrawable;
mDrawable = NULL; mDrawable = NULL;

View File

@@ -257,48 +257,6 @@ void LLFacePool::dirtyTextures(const std::set<LLViewerFetchedTexture*>& textures
{ {
} }
// static
S32 LLFacePool::drawLoop(face_array_t& face_list)
{
S32 res = 0;
if (!face_list.empty())
{
for (std::vector<LLFace*>::iterator iter = face_list.begin();
iter != face_list.end(); iter++)
{
LLFace *facep = *iter;
res += facep->renderIndexed();
}
}
return res;
}
// static
S32 LLFacePool::drawLoopSetTex(face_array_t& face_list, S32 stage)
{
S32 res = 0;
if (!face_list.empty())
{
for (std::vector<LLFace*>::iterator iter = face_list.begin();
iter != face_list.end(); iter++)
{
LLFace *facep = *iter;
gGL.getTexUnit(stage)->bind(facep->getTexture(), TRUE);
gGL.getTexUnit(0)->activate();
res += facep->renderIndexed();
}
}
return res;
}
void LLFacePool::drawLoop()
{
if (!mDrawFace.empty())
{
drawLoop(mDrawFace);
}
}
void LLFacePool::enqueue(LLFace* facep) void LLFacePool::enqueue(LLFace* facep)
{ {
mDrawFace.push_back(facep); mDrawFace.push_back(facep);

View File

@@ -192,10 +192,6 @@ public:
void buildEdges(); void buildEdges();
static S32 drawLoop(face_array_t& face_list);
static S32 drawLoopSetTex(face_array_t& face_list, S32 stage);
void drawLoop();
void addFaceReference(LLFace *facep); void addFaceReference(LLFace *facep);
void removeFaceReference(LLFace *facep); void removeFaceReference(LLFace *facep);

View File

@@ -1040,9 +1040,13 @@ void LLDrawPoolAvatar::endDeferredSkinned()
gGL.getTexUnit(0)->activate(); gGL.getTexUnit(0)->activate();
} }
static LLFastTimer::DeclareTimer FTM_RENDER_AVATARS("renderAvatars");
void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass) void LLDrawPoolAvatar::renderAvatars(LLVOAvatar* single_avatar, S32 pass)
{ {
LLFastTimer t(FTM_RENDER_AVATARS);
if (pass == -1) if (pass == -1)
{ {
for (S32 i = 1; i < getNumPasses(); i++) for (S32 i = 1; i < getNumPasses(); i++)
@@ -1546,8 +1550,12 @@ void LLDrawPoolAvatar::renderDeferredRiggedBump(LLVOAvatar* avatar)
renderRigged(avatar, RIGGED_DEFERRED_BUMP); renderRigged(avatar, RIGGED_DEFERRED_BUMP);
} }
static LLFastTimer::DeclareTimer FTM_RIGGED_VBO("Rigged VBO");
void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar) void LLDrawPoolAvatar::updateRiggedVertexBuffers(LLVOAvatar* avatar)
{ {
LLFastTimer t(FTM_RIGGED_VBO);
//update rigged vertex buffers //update rigged vertex buffers
for (U32 type = 0; type < NUM_RIGGED_PASSES; ++type) for (U32 type = 0; type < NUM_RIGGED_PASSES; ++type)
{ {

View File

@@ -302,6 +302,34 @@ void LLDrawPoolTerrain::renderShadow(S32 pass)
//glCullFace(GL_BACK); //glCullFace(GL_BACK);
} }
void LLDrawPoolTerrain::drawLoop()
{
if (!mDrawFace.empty())
{
for (std::vector<LLFace*>::iterator iter = mDrawFace.begin();
iter != mDrawFace.end(); iter++)
{
LLFace *facep = *iter;
LLMatrix4* model_matrix = &(facep->getDrawable()->getRegion()->mRenderMatrix);
if (model_matrix != gGLLastMatrix)
{
gGLLastMatrix = model_matrix;
gGL.loadMatrix(gGLModelView);
if (model_matrix)
{
gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
}
gPipeline.mMatrixOpCount++;
}
facep->renderIndexed();
}
}
}
void LLDrawPoolTerrain::renderFullShader() void LLDrawPoolTerrain::renderFullShader()
{ {
// Hack! Get the region that this draw pool is rendering from! // Hack! Get the region that this draw pool is rendering from!

View File

@@ -89,6 +89,7 @@ protected:
void renderFull2TU(); void renderFull2TU();
void renderFull4TU(); void renderFull4TU();
void renderFullShader(); void renderFullShader();
void drawLoop();
}; };
#endif // LL_LLDRAWPOOLSIMPLE_H #endif // LL_LLDRAWPOOLSIMPLE_H

View File

@@ -43,6 +43,7 @@
#include "llviewershadermgr.h" #include "llviewershadermgr.h"
#include "llrender.h" #include "llrender.h"
#include "llviewercontrol.h" #include "llviewercontrol.h"
#include "llviewerregion.h"
S32 LLDrawPoolTree::sDiffTex = 0; S32 LLDrawPoolTree::sDiffTex = 0;
static LLGLSLShader* shader = NULL; static LLGLSLShader* shader = NULL;
@@ -116,8 +117,22 @@ void LLDrawPoolTree::render(S32 pass)
{ {
LLFace *face = *iter; LLFace *face = *iter;
LLVertexBuffer* buff = face->getVertexBuffer(); LLVertexBuffer* buff = face->getVertexBuffer();
if(buff) if(buff)
{ {
LLMatrix4* model_matrix = &(face->getDrawable()->getRegion()->mRenderMatrix);
if (model_matrix != gGLLastMatrix)
{
gGLLastMatrix = model_matrix;
gGL.loadMatrix(gGLModelView);
if (model_matrix)
{
gGL.multMatrix((GLfloat*) model_matrix->mMatrix);
}
gPipeline.mMatrixOpCount++;
}
buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK); buff->setBuffer(LLDrawPoolTree::VERTEX_DATA_MASK);
buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0); buff->drawRange(LLRender::TRIANGLES, 0, buff->getNumVerts()-1, buff->getNumIndices(), 0);
gPipeline.addTrianglesDrawn(buff->getNumIndices()); gPipeline.addTrianglesDrawn(buff->getNumIndices());

View File

@@ -73,6 +73,7 @@ const F32 SG_OCCLUSION_FUDGE = 0.25f;
#define assert_states_valid(x) #define assert_states_valid(x)
#endif #endif
extern bool gShiftFrame;
static U32 sZombieGroups = 0; static U32 sZombieGroups = 0;
U32 LLSpatialGroup::sNodeCount = 0; U32 LLSpatialGroup::sNodeCount = 0;
@@ -806,7 +807,10 @@ void LLSpatialGroup::shift(const LLVector4a &offset)
mObjectExtents[0].add(offset); mObjectExtents[0].add(offset);
mObjectExtents[1].add(offset); mObjectExtents[1].add(offset);
if (!mSpatialPartition->mRenderByGroup) if (!mSpatialPartition->mRenderByGroup &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TREE &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_TERRAIN &&
mSpatialPartition->mPartitionType != LLViewerRegion::PARTITION_BRIDGE)
{ {
setState(GEOM_DIRTY); setState(GEOM_DIRTY);
gPipeline.markRebuild(this, TRUE); gPipeline.markRebuild(this, TRUE);
@@ -1121,6 +1125,11 @@ void LLSpatialGroup::updateDistance(LLCamera &camera)
return; return;
} }
if (gShiftFrame)
{
return;
}
#if !LL_RELEASE_FOR_DOWNLOAD #if !LL_RELEASE_FOR_DOWNLOAD
if (isState(LLSpatialGroup::OBJECT_DIRTY)) if (isState(LLSpatialGroup::OBJECT_DIRTY))
{ {
@@ -1735,6 +1744,8 @@ BOOL LLSpatialPartition::remove(LLDrawable *drawablep, LLSpatialGroup *curp)
drawablep->setSpatialGroup(NULL); drawablep->setSpatialGroup(NULL);
} }
drawablep->setSpatialGroup(NULL);
assert_octree_valid(mOctree); assert_octree_valid(mOctree);
return TRUE; return TRUE;

View File

@@ -352,9 +352,10 @@ public:
void dirtyMesh() { setState(MESH_DIRTY); } void dirtyMesh() { setState(MESH_DIRTY); }
//octree wrappers to make code more readable //octree wrappers to make code more readable
//element_list& getData() { return mOctreeNode->getData(); } //element_list& getData() { return mOctreeNode->getData(); } //unused
element_iter getDataBegin() { return mOctreeNode->getDataBegin(); } element_iter getDataBegin() { return mOctreeNode->getDataBegin(); }
element_iter getDataEnd() { return mOctreeNode->getDataEnd(); } element_iter getDataEnd() { return mOctreeNode->getDataEnd(); }
bool hasElement(LLDrawable* drawablep) { return std::find(mOctreeNode->getDataBegin(), mOctreeNode->getDataEnd(), drawablep) != mOctreeNode->getDataEnd(); }
U32 getElementCount() const { return mOctreeNode->getElementCount(); } U32 getElementCount() const { return mOctreeNode->getElementCount(); }
bool isEmpty() const { return mOctreeNode->isEmpty(); } bool isEmpty() const { return mOctreeNode->isEmpty(); }

View File

@@ -61,6 +61,7 @@
#include "lldrawable.h" #include "lldrawable.h"
extern LLPipeline gPipeline; extern LLPipeline gPipeline;
extern bool gShiftFrame;
LLColor4U MAX_WATER_COLOR(0, 48, 96, 240); LLColor4U MAX_WATER_COLOR(0, 48, 96, 240);
@@ -351,13 +352,21 @@ void LLSurface::getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegio
} }
} }
void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
void LLSurface::getNeighboringRegionsStatus( std::vector<S32>& regions )
{ {
if (gNoRender) S32 i;
for (i = 0; i < 8; i++)
{ {
return; if ( mNeighbors[i] != NULL )
{
regions.push_back( i );
}
}
} }
void LLSurface::connectNeighbor(LLSurface *neighborp, U32 direction)
{
S32 i; S32 i;
LLSurfacePatch *patchp, *neighbor_patchp; LLSurfacePatch *patchp, *neighbor_patchp;
@@ -618,6 +627,11 @@ void LLSurface::moveZ(const S32 x, const S32 y, const F32 delta)
void LLSurface::updatePatchVisibilities(LLAgent &agent) void LLSurface::updatePatchVisibilities(LLAgent &agent)
{ {
if (gShiftFrame)
{
return;
}
LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgentCamera.getCameraPositionGlobal()); LLVector3 pos_region = mRegionp->getPosRegionFromGlobal(gAgentCamera.getCameraPositionGlobal());
LLSurfacePatch *patchp; LLSurfacePatch *patchp;

View File

@@ -148,6 +148,7 @@ public:
friend std::ostream& operator<<(std::ostream &s, const LLSurface &S); friend std::ostream& operator<<(std::ostream &s, const LLSurface &S);
void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions ); void getNeighboringRegions( std::vector<LLViewerRegion*>& uniqueRegions );
void getNeighboringRegionsStatus( std::vector<S32>& regions );
public: public:
// Number of grid points on one side of a region, including +1 buffer for // Number of grid points on one side of a region, including +1 buffer for

View File

@@ -49,6 +49,7 @@
#include "lldrawpool.h" #include "lldrawpool.h"
#include "noise.h" #include "noise.h"
extern bool gShiftFrame;
extern U64 gFrameTime; extern U64 gFrameTime;
extern LLPipeline gPipeline; extern LLPipeline gPipeline;
@@ -224,7 +225,7 @@ void LLSurfacePatch::eval(const U32 x, const U32 y, const U32 stride, LLVector3
pos_agent.mV[VX] += x * mSurfacep->getMetersPerGrid(); pos_agent.mV[VX] += x * mSurfacep->getMetersPerGrid();
pos_agent.mV[VY] += y * mSurfacep->getMetersPerGrid(); pos_agent.mV[VY] += y * mSurfacep->getMetersPerGrid();
pos_agent.mV[VZ] = *(mDataZ + point_offset); pos_agent.mV[VZ] = *(mDataZ + point_offset);
*vertex = pos_agent; *vertex = pos_agent-mVObjp->getRegion()->getOriginAgent();
LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent(); LLVector3 rel_pos = pos_agent - mSurfacep->getOriginAgent();
LLVector3 tex_pos = rel_pos * (1.f/surface_stride); LLVector3 tex_pos = rel_pos * (1.f/surface_stride);
@@ -371,12 +372,15 @@ const LLVector3 &LLSurfacePatch::getNormal(const U32 x, const U32 y) const
void LLSurfacePatch::updateCameraDistanceRegion(const LLVector3 &pos_region) void LLSurfacePatch::updateCameraDistanceRegion(const LLVector3 &pos_region)
{ {
if (LLPipeline::sDynamicLOD) if (LLPipeline::sDynamicLOD)
{
if (!gShiftFrame)
{ {
LLVector3 dv = pos_region; LLVector3 dv = pos_region;
dv -= mCenterRegion; dv -= mCenterRegion;
mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/ mVisInfo.mDistance = llmax(0.f, (F32)(dv.magVec() - mRadius))/
llmax(LLVOSurfacePatch::sLODFactor, 0.1f); llmax(LLVOSurfacePatch::sLODFactor, 0.1f);
} }
}
else else
{ {
mVisInfo.mDistance = 0.f; mVisInfo.mDistance = 0.f;

View File

@@ -90,6 +90,8 @@
#include "rlvlocks.h" #include "rlvlocks.h"
// [/RLVa:KB] // [/RLVa:KB]
extern bool gShiftFrame;
LLPointer<LLViewerTexture> gDisconnectedImagep = NULL; LLPointer<LLViewerTexture> gDisconnectedImagep = NULL;
// used to toggle renderer back on after teleport // used to toggle renderer back on after teleport
@@ -1109,6 +1111,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot, boo
display_stats(); display_stats();
LLAppViewer::instance()->pingMainloopTimeout("Display:Done"); LLAppViewer::instance()->pingMainloopTimeout("Display:Done");
gShiftFrame = false;
} }
void render_hud_attachments() void render_hud_attachments()

View File

@@ -207,6 +207,7 @@ static const U32 LLREQUEST_PERMISSION_THROTTLE_LIMIT = 5; // requests
static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL = 10.0f; // seconds static const F32 LLREQUEST_PERMISSION_THROTTLE_INTERVAL = 10.0f; // seconds
extern BOOL gDebugClicks; extern BOOL gDebugClicks;
extern bool gShiftFrame;
// function prototypes // function prototypes
bool check_offer_throttle(const std::string& from_name, bool check_only); bool check_offer_throttle(const std::string& from_name, bool check_only);
@@ -4208,6 +4209,7 @@ void process_avatar_init_complete(LLMessageSystem* msg, void**)
void process_agent_movement_complete(LLMessageSystem* msg, void**) void process_agent_movement_complete(LLMessageSystem* msg, void**)
{ {
gShiftFrame = true;
gAgentMovementCompleted = true; gAgentMovementCompleted = true;
LLUUID agent_id; LLUUID agent_id;

View File

@@ -205,6 +205,7 @@ LLViewerObject::LLViewerObject(const LLUUID &id, const LLPCode pcode, LLViewerRe
mID(id), mID(id),
mLocalID(0), mLocalID(0),
mTotalCRC(0), mTotalCRC(0),
mListIndex(-1),
mTEImages(NULL), mTEImages(NULL),
mGLName(0), mGLName(0),
mbCanSelect(TRUE), mbCanSelect(TRUE),

View File

@@ -219,6 +219,8 @@ public:
const LLUUID &getID() const { return mID; } const LLUUID &getID() const { return mID; }
U32 getLocalID() const { return mLocalID; } U32 getLocalID() const { return mLocalID; }
U32 getCRC() const { return mTotalCRC; } U32 getCRC() const { return mTotalCRC; }
S32 getListIndex() const { return mListIndex; }
void setListIndex(S32 idx) { mListIndex = idx; }
virtual BOOL isFlexible() const { return FALSE; } virtual BOOL isFlexible() const { return FALSE; }
virtual BOOL isSculpted() const { return FALSE; } virtual BOOL isSculpted() const { return FALSE; }
@@ -603,6 +605,9 @@ public:
// Last total CRC received from sim, used for caching // Last total CRC received from sim, used for caching
U32 mTotalCRC; U32 mTotalCRC;
// index into LLViewerObjectList::mActiveObjects or -1 if not in list
S32 mListIndex;
LLPointer<LLViewerTexture> *mTEImages; LLPointer<LLViewerTexture> *mTEImages;
// Selection, picking and rendering variables // Selection, picking and rendering variables

View File

@@ -922,23 +922,34 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
LLViewerObject *objectp = NULL; LLViewerObject *objectp = NULL;
// Make a copy of the list in case something in idleUpdate() messes with it // Make a copy of the list in case something in idleUpdate() messes with it
std::vector<LLViewerObject*> idle_list; static std::vector<LLViewerObject*> idle_list;
if(mActiveObjects.size() > idle_list.capacity())
idle_list.reserve( mActiveObjects.size() );
U32 idle_count = 0;
static LLFastTimer::DeclareTimer idle_copy("Idle Copy"); static LLFastTimer::DeclareTimer idle_copy("Idle Copy");
{ {
LLFastTimer t(idle_copy); LLFastTimer t(idle_copy);
idle_list.reserve( mActiveObjects.size() );
for (std::set<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin(); for (std::vector<LLPointer<LLViewerObject> >::iterator active_iter = mActiveObjects.begin();
active_iter != mActiveObjects.end(); active_iter++) active_iter != mActiveObjects.end(); active_iter++)
{ {
objectp = *active_iter; objectp = *active_iter;
if (objectp) if (objectp)
{
if (idle_count >= idle_list.size())
{ {
idle_list.push_back( objectp ); idle_list.push_back( objectp );
} }
else else
{
idle_list[idle_count] = objectp;
}
++idle_count;
}
else
{ // There shouldn't be any NULL pointers in the list, but they have caused { // There shouldn't be any NULL pointers in the list, but they have caused
// crashes before. This may be idleUpdate() messing with the list. // crashes before. This may be idleUpdate() messing with the list.
llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl; llwarns << "LLViewerObjectList::update has a NULL objectp" << llendl;
@@ -946,11 +957,13 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
} }
} }
std::vector<LLViewerObject*>::iterator idle_end = idle_list.begin()+idle_count;
static const LLCachedControl<bool> freeze_time("FreezeTime",0); static const LLCachedControl<bool> freeze_time("FreezeTime",0);
if (freeze_time) if (freeze_time)
{ {
for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin(); for (std::vector<LLViewerObject*>::iterator iter = idle_list.begin();
iter != idle_list.end(); iter++) iter != idle_end; iter++)
{ {
objectp = *iter; objectp = *iter;
if ( if (
@@ -966,17 +979,17 @@ void LLViewerObjectList::update(LLAgent &agent, LLWorld &world)
else else
{ {
for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin(); for (std::vector<LLViewerObject*>::iterator idle_iter = idle_list.begin();
idle_iter != idle_list.end(); idle_iter++) idle_iter != idle_end; idle_iter++)
{ {
objectp = *idle_iter; objectp = *idle_iter;
if (!objectp->idleUpdate(agent, world, frame_time)) if (objectp->idleUpdate(agent, world, frame_time))
{ {
// If Idle Update returns false, kill object! num_active_objects++;
kill_list.push_back(objectp);
} }
else else
{ {
num_active_objects++; // If Idle Update returns false, kill object!
kill_list.push_back(objectp);
} }
} }
for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin(); for (std::vector<LLViewerObject*>::iterator kill_iter = kill_list.begin();
@@ -1219,7 +1232,7 @@ void LLViewerObjectList::cleanupReferences(LLViewerObject *objectp)
{ {
//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl; //llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list in cleanupReferences." << llendl;
objectp->setOnActiveList(FALSE); objectp->setOnActiveList(FALSE);
mActiveObjects.erase(objectp); removeFromActiveList(objectp);
} }
if (objectp->isOnMap()) if (objectp->isOnMap())
@@ -1409,6 +1422,26 @@ void LLViewerObjectList::cleanDeadObjects(BOOL use_timer)
mNumDeadObjects = 0; mNumDeadObjects = 0;
} }
void LLViewerObjectList::removeFromActiveList(LLViewerObject* objectp)
{
S32 idx = objectp->getListIndex();
if (idx != -1)
{ //remove by moving last element to this object's position
llassert(mActiveObjects[idx] == objectp);
objectp->setListIndex(-1);
S32 last_index = mActiveObjects.size()-1;
if (idx != last_index)
{
mActiveObjects[idx] = mActiveObjects[last_index];
mActiveObjects[idx]->setListIndex(idx);
mActiveObjects.pop_back();
}
}
}
void LLViewerObjectList::updateActive(LLViewerObject *objectp) void LLViewerObjectList::updateActive(LLViewerObject *objectp)
{ {
LLMemType mt(LLMemType::MTYPE_OBJECT); LLMemType mt(LLMemType::MTYPE_OBJECT);
@@ -1423,13 +1456,29 @@ void LLViewerObjectList::updateActive(LLViewerObject *objectp)
if (active) if (active)
{ {
//llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl; //llinfos << "Adding " << objectp->mID << " " << objectp->getPCodeString() << " to active list." << llendl;
mActiveObjects.insert(objectp); S32 idx = objectp->getListIndex();
if (idx <= -1)
{
mActiveObjects.push_back(objectp);
objectp->setListIndex(mActiveObjects.size()-1);
objectp->setOnActiveList(TRUE); objectp->setOnActiveList(TRUE);
} }
else else
{
llassert(idx < mActiveObjects.size());
llassert(mActiveObjects[idx] == objectp);
if (idx >= (S32)mActiveObjects.size() ||
mActiveObjects[idx] != objectp)
{
llwarns << "Invalid object list index detected!" << llendl;
}
}
}
else
{ {
//llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl; //llinfos << "Removing " << objectp->mID << " " << objectp->getPCodeString() << " from active list." << llendl;
mActiveObjects.erase(objectp); removeFromActiveList(objectp);
objectp->setOnActiveList(FALSE); objectp->setOnActiveList(FALSE);
} }
} }

View File

@@ -128,7 +128,9 @@ public:
void dirtyAllObjectInventory(); void dirtyAllObjectInventory();
void removeFromActiveList(LLViewerObject* objectp);
void updateActive(LLViewerObject *objectp); void updateActive(LLViewerObject *objectp);
void updateAvatarVisibility(); void updateAvatarVisibility();
// Selection related stuff // Selection related stuff
@@ -206,7 +208,7 @@ public:
typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t; typedef std::vector<LLPointer<LLViewerObject> > vobj_list_t;
vobj_list_t mObjects; vobj_list_t mObjects;
std::set<LLPointer<LLViewerObject> > mActiveObjects; std::vector<LLPointer<LLViewerObject> > mActiveObjects;
vobj_list_t mMapObjects; vobj_list_t mMapObjects;

View File

@@ -389,7 +389,7 @@ BOOL LLVOTree::idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time)
// *TODO: I don't know what's so special about trees // *TODO: I don't know what's so special about trees
// that they don't get REBUILD_POSITION automatically // that they don't get REBUILD_POSITION automatically
// at a higher level. // at a higher level.
const LLVector3 &this_position = getPositionAgent(); const LLVector3 &this_position = getPositionRegion();
if (this_position != mLastPosition) if (this_position != mLastPosition)
{ {
gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION); gPipeline.markRebuild(mDrawable, LLDrawable::REBUILD_POSITION);
@@ -858,10 +858,10 @@ void LLVOTree::updateMesh()
LLMatrix4 matrix; LLMatrix4 matrix;
// Translate to tree base HACK - adjustment in Z plants tree underground // Translate to tree base HACK - adjustment in Z plants tree underground
const LLVector3 &pos_agent = getPositionAgent(); const LLVector3 &pos_region = getPositionRegion();
//gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f); //gGL.translatef(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f);
LLMatrix4 trans_mat; LLMatrix4 trans_mat;
trans_mat.setTranslation(pos_agent.mV[VX], pos_agent.mV[VY], pos_agent.mV[VZ] - 0.1f); trans_mat.setTranslation(pos_region.mV[VX], pos_region.mV[VY], pos_region.mV[VZ] - 0.1f);
trans_mat *= matrix; trans_mat *= matrix;
// Rotate to tree position and bend for current trunk/wind // Rotate to tree position and bend for current trunk/wind

View File

@@ -142,6 +142,8 @@ void check_stack_depth(S32 stack_depth)
//#define DEBUG_INDICES //#define DEBUG_INDICES
#endif #endif
bool gShiftFrame = false;
const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f; const F32 BACKLIGHT_DAY_MAGNITUDE_AVATAR = 0.2f;
const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f; const F32 BACKLIGHT_NIGHT_MAGNITUDE_AVATAR = 0.1f;
const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f; const F32 BACKLIGHT_DAY_MAGNITUDE_OBJECT = 0.1f;
@@ -543,6 +545,7 @@ void LLPipeline::cleanup()
mInitialized = FALSE; mInitialized = FALSE;
mDeferredVB = NULL; mDeferredVB = NULL;
mCubeVB = NULL;
} }
//============================================================================ //============================================================================