diff options
author | Merov Linden <merov@lindenlab.com> | 2014-05-06 18:21:04 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2014-05-06 18:21:04 -0700 |
commit | 8dae4bc222d1b0744254442ab0b26538285341de (patch) | |
tree | 88da67f01f0dc32457b4a5085d5e699ea55715a4 /indra/newview/lldrawable.cpp | |
parent | f6bb6a0f935323434a3f3d0d94e94c8d8238effe (diff) | |
parent | d0ef02c23a7a37c8c9bfe3a86bae88bb811fc9fe (diff) |
Pull merge from lindenlab/viewer-release. Fixed some conflicts and compile errors
Diffstat (limited to 'indra/newview/lldrawable.cpp')
-rwxr-xr-x | indra/newview/lldrawable.cpp | 403 |
1 files changed, 195 insertions, 208 deletions
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp index 9682f38227..c56006d9a3 100755 --- a/indra/newview/lldrawable.cpp +++ b/indra/newview/lldrawable.cpp @@ -49,13 +49,14 @@ #include "llspatialpartition.h" #include "llviewerobjectlist.h" #include "llviewerwindow.h" +#include "llvocache.h" const F32 MIN_INTERPOLATE_DISTANCE_SQUARED = 0.001f * 0.001f; const F32 MAX_INTERPOLATE_DISTANCE_SQUARED = 10.f * 10.f; const F32 OBJECT_DAMPING_TIME_CONSTANT = 0.06f; const F32 MIN_SHADOW_CASTER_RADIUS = 2.0f; -static LLFastTimer::DeclareTimer FTM_CULL_REBOUND("Cull Rebound"); +static LLTrace::BlockTimerStatHandle FTM_CULL_REBOUND("Cull Rebound"); extern bool gShiftFrame; @@ -75,43 +76,72 @@ extern bool gShiftFrame; // // static -U32 LLDrawable::sCurVisible = 0; U32 LLDrawable::sNumZombieDrawables = 0; F32 LLDrawable::sCurPixelAngle = 0; -LLDynamicArrayPtr<LLPointer<LLDrawable> > LLDrawable::sDeadList; +std::vector<LLPointer<LLDrawable> > LLDrawable::sDeadList; #define FORCE_INVISIBLE_AREA 16.f // static void LLDrawable::incrementVisible() { - sCurVisible++; + LLViewerOctreeEntryData::incrementVisible(); sCurPixelAngle = (F32) gViewerWindow->getWindowHeightRaw()/LLViewerCamera::getInstance()->getView(); } -void LLDrawable::init() +LLDrawable::LLDrawable(LLViewerObject *vobj, bool new_entry) +: LLViewerOctreeEntryData(LLViewerOctreeEntry::LLDRAWABLE), + LLTrace::MemTrackable<LLDrawable, 16>("LLDrawable"), + mVObjp(vobj) +{ + init(new_entry); +} + +void LLDrawable::init(bool new_entry) { // mXform mParent = NULL; mRenderType = 0; mCurrentScale = LLVector3(1,1,1); mDistanceWRTCamera = 0.0f; - mPositionGroup.clear(); - mExtents[0].clear(); - mExtents[1].clear(); - mState = 0; - mVObjp = NULL; + // mFaces - mSpatialGroupp = NULL; - mVisible = sCurVisible - 2;//invisible for the current frame and the last frame. mRadius = 0.f; + mGeneration = -1; + mSpatialBridge = NULL; + + LLViewerOctreeEntry* entry = NULL; + LLVOCacheEntry* vo_entry = NULL; + if(!new_entry && mVObjp && getRegion() != NULL) + { + vo_entry = getRegion()->getCacheEntryForOctree(mVObjp->getLocalID()); + if(vo_entry) + { + entry = vo_entry->getEntry(); + } + } + setOctreeEntry(entry); + if(vo_entry) + { + if(!entry) + { + vo_entry->setOctreeEntry(mEntry); + } + + getRegion()->addActiveCacheEntry(vo_entry); + + if(vo_entry->getNumOfChildren() > 0) + { + getRegion()->addVisibleChildCacheEntry(vo_entry, NULL); //to load all children. + } + + llassert(!vo_entry->getGroup()); //not in the object cache octree. + } - mGeneration = -1; - mBinRadius = 1.f; - mBinIndex = -1; + llassert(!vo_entry || vo_entry->getEntry() == mEntry); - mSpatialBridge = NULL; + initVisible(sCurVisible - 2);//invisible for the current frame and the last frame. } // static @@ -140,7 +170,7 @@ void LLDrawable::destroy() /* cannot be guaranteed and causes crashes on false alarms if (LLSpatialGroup::sNoDelete) { - llerrs << "Illegal deletion of LLDrawable!" << llendl; + LL_ERRS() << "Illegal deletion of LLDrawable!" << LL_ENDL; }*/ std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); @@ -149,7 +179,7 @@ void LLDrawable::destroy() /*if (!(sNumZombieDrawables % 10)) { - llinfos << "- Zombie drawables: " << sNumZombieDrawables << llendl; + LL_INFOS() << "- Zombie drawables: " << sNumZombieDrawables << LL_ENDL; }*/ } @@ -158,9 +188,10 @@ void LLDrawable::markDead() { if (isDead()) { - llwarns << "Warning! Marking dead multiple times!" << llendl; + LL_WARNS() << "Warning! Marking dead multiple times!" << LL_ENDL; return; } + setState(DEAD); if (mSpatialBridge) { @@ -171,9 +202,8 @@ void LLDrawable::markDead() sNumZombieDrawables++; // We're dead. Free up all of our references to other objects - setState(DEAD); cleanupReferences(); -// sDeadList.put(this); +// sDeadList.push_back(this); } LLVOVolume* LLDrawable::getVOVolume() const @@ -207,16 +237,16 @@ BOOL LLDrawable::isLight() const } } -static LLFastTimer::DeclareTimer FTM_CLEANUP_DRAWABLE("Cleanup Drawable"); -static LLFastTimer::DeclareTimer FTM_DEREF_DRAWABLE("Deref"); -static LLFastTimer::DeclareTimer FTM_DELETE_FACES("Faces"); +static LLTrace::BlockTimerStatHandle FTM_CLEANUP_DRAWABLE("Cleanup Drawable"); +static LLTrace::BlockTimerStatHandle FTM_DEREF_DRAWABLE("Deref"); +static LLTrace::BlockTimerStatHandle FTM_DELETE_FACES("Faces"); void LLDrawable::cleanupReferences() { - LLFastTimer t(FTM_CLEANUP_DRAWABLE); + LL_RECORD_BLOCK_TIME(FTM_CLEANUP_DRAWABLE); { - LLFastTimer t(FTM_DELETE_FACES); + LL_RECORD_BLOCK_TIME(FTM_DELETE_FACES); std::for_each(mFaces.begin(), mFaces.end(), DeletePointer()); mFaces.clear(); } @@ -225,28 +255,45 @@ void LLDrawable::cleanupReferences() gPipeline.unlinkDrawable(this); + removeFromOctree(); + { - LLFastTimer t(FTM_DEREF_DRAWABLE); + LL_RECORD_BLOCK_TIME(FTM_DEREF_DRAWABLE); // Cleanup references to other objects mVObjp = NULL; mParent = NULL; } } +void LLDrawable::removeFromOctree() +{ + if(!mEntry) + { + return; + } + + mEntry->removeData(this); + if(mEntry->hasVOCacheEntry()) + { + getRegion()->removeActiveCacheEntry((LLVOCacheEntry*)mEntry->getVOCacheEntry(), this); + } + mEntry = NULL; +} + void LLDrawable::cleanupDeadDrawables() { /* S32 i; - for (i = 0; i < sDeadList.count(); i++) + for (i = 0; i < sDeadList.size(); i++) { if (sDeadList[i]->getNumRefs() > 1) { - llwarns << "Dead drawable has " << sDeadList[i]->getNumRefs() << " remaining refs" << llendl; + LL_WARNS() << "Dead drawable has " << sDeadList[i]->getNumRefs() << " remaining refs" << LL_ENDL; gPipeline.findReferences(sDeadList[i]); } } */ - sDeadList.reset(); + sDeadList.clear(); } S32 LLDrawable::findReferences(LLDrawable *drawablep) @@ -254,24 +301,24 @@ S32 LLDrawable::findReferences(LLDrawable *drawablep) S32 count = 0; if (mParent == drawablep) { - llinfos << this << ": parent reference" << llendl; + LL_INFOS() << this << ": parent reference" << LL_ENDL; count++; } return count; } -static LLFastTimer::DeclareTimer FTM_ALLOCATE_FACE("Allocate Face", true); +static LLTrace::BlockTimerStatHandle FTM_ALLOCATE_FACE("Allocate Face"); LLFace* LLDrawable::addFace(LLFacePool *poolp, LLViewerTexture *texturep) { LLFace *face; { - LLFastTimer t(FTM_ALLOCATE_FACE); + LL_RECORD_BLOCK_TIME(FTM_ALLOCATE_FACE); face = new LLFace(this, mVObjp); } - if (!face) llerrs << "Allocating new Face: " << mFaces.size() << llendl; + if (!face) LL_ERRS() << "Allocating new Face: " << mFaces.size() << LL_ENDL; if (face) { @@ -295,7 +342,7 @@ LLFace* LLDrawable::addFace(const LLTextureEntry *te, LLViewerTexture *texturep) LLFace *face; { - LLFastTimer t(FTM_ALLOCATE_FACE); + LL_RECORD_BLOCK_TIME(FTM_ALLOCATE_FACE); face = new LLFace(this, mVObjp); } @@ -428,7 +475,7 @@ void LLDrawable::deleteFaces(S32 offset, S32 count) void LLDrawable::update() { - llerrs << "Shouldn't be called!" << llendl; + LL_ERRS() << "Shouldn't be called!" << LL_ENDL; } @@ -450,7 +497,7 @@ void LLDrawable::makeActive() pcode == LLViewerObject::LL_VO_GROUND || pcode == LLViewerObject::LL_VO_SKY) { - llerrs << "Static viewer object has active drawable!" << llendl; + LL_ERRS() << "Static viewer object has active drawable!" << LL_ENDL; } } #endif @@ -488,6 +535,12 @@ void LLDrawable::makeActive() } updatePartition(); } + else if (!isRoot() && !mParent->isActive()) //this should not happen, but occasionally it does... + { + mParent->makeActive(); + //NOTE: linked set will now NEVER become static + mParent->setState(LLDrawable::ACTIVE_CHILD); + } llassert(isAvatar() || isRoot() || mParent->isActive()); } @@ -515,7 +568,7 @@ void LLDrawable::makeStatic(BOOL warning_enabled) { if (child_drawable->getParent() != this) { - llwarns << "Child drawable has unknown parent." << llendl; + LL_WARNS() << "Child drawable has unknown parent." << LL_ENDL; } child_drawable->makeStatic(warning_enabled); } @@ -569,7 +622,7 @@ F32 LLDrawable::updateXform(BOOL undamped) if (damped && isVisible()) { - F32 lerp_amt = llclamp(LLCriticalDamp::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); + F32 lerp_amt = llclamp(LLSmoothInterpolation::getInterpolant(OBJECT_DAMPING_TIME_CONSTANT), 0.f, 1.f); LLVector3 new_pos = lerp(old_pos, target_pos, lerp_amt); dist_squared = dist_vec_squared(new_pos, target_pos); @@ -690,7 +743,7 @@ BOOL LLDrawable::updateMove() { if (isDead()) { - llwarns << "Update move on dead drawable!" << llendl; + LL_WARNS() << "Update move on dead drawable!" << LL_ENDL; return TRUE; } @@ -765,7 +818,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) { if (LLViewerCamera::sCurCameraID != LLViewerCamera::CAMERA_WORLD) { - llwarns << "Attempted to update distance for non-world camera." << llendl; + LL_WARNS() << "Attempted to update distance for non-world camera." << LL_ENDL; return; } @@ -784,7 +837,7 @@ void LLDrawable::updateDistance(LLCamera& camera, bool force_update) LLVOVolume* volume = getVOVolume(); if (volume) { - if (getSpatialGroup()) + if (getGroup()) { pos.set(getPositionGroup().getF32ptr()); } @@ -830,7 +883,7 @@ void LLDrawable::updateTexture() { if (isDead()) { - llwarns << "Dead drawable updating texture!" << llendl; + LL_WARNS() << "Dead drawable updating texture!" << LL_ENDL; return; } @@ -856,7 +909,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector) { if (isDead()) { - llwarns << "Shifting dead drawable" << llendl; + LL_WARNS() << "Shifting dead drawable" << LL_ENDL; return; } @@ -902,9 +955,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector) } } - mExtents[0].add(shift_vector); - mExtents[1].add(shift_vector); - mPositionGroup.add(shift_vector); + shift(shift_vector); } else if (mSpatialBridge) { @@ -912,9 +963,7 @@ void LLDrawable::shiftPos(const LLVector4a &shift_vector) } else if (isAvatar()) { - mExtents[0].add(shift_vector); - mExtents[1].add(shift_vector); - mPositionGroup.add(shift_vector); + shift(shift_vector); } mVObjp->onShift(shift_vector); @@ -926,40 +975,24 @@ const LLVector3& LLDrawable::getBounds(LLVector3& min, LLVector3& max) const return mXform.getPositionW(); } -const LLVector4a* LLDrawable::getSpatialExtents() const -{ - return mExtents; -} - -void LLDrawable::setSpatialExtents(const LLVector3& min, const LLVector3& max) -{ - mExtents[0].load3(min.mV); - mExtents[1].load3(max.mV); -} - -void LLDrawable::setSpatialExtents(const LLVector4a& min, const LLVector4a& max) -{ - mExtents[0] = min; - mExtents[1] = max; -} - -void LLDrawable::setPositionGroup(const LLVector4a& pos) -{ - mPositionGroup = pos; -} - void LLDrawable::updateSpatialExtents() { if (mVObjp) { - mVObjp->updateSpatialExtents(mExtents[0], mExtents[1]); + const LLVector4a* exts = getSpatialExtents(); + LLVector4a extents[2]; + extents[0] = exts[0]; + extents[1] = exts[1]; + + mVObjp->updateSpatialExtents(extents[0], extents[1]); + setSpatialExtents(extents[0], extents[1]); } updateBinRadius(); if (mSpatialBridge.notNull()) { - mPositionGroup.splat(0.f); + getGroupPosition().splat(0.f); } } @@ -968,11 +1001,11 @@ void LLDrawable::updateBinRadius() { if (mVObjp.notNull()) { - mBinRadius = llmin(mVObjp->getBinRadius(), 256.f); + setBinRadius(llmin(mVObjp->getBinRadius(), 256.f)); } else { - mBinRadius = llmin(getRadius()*4.f, 256.f); + setBinRadius(llmin(getRadius()*4.f, 256.f)); } } @@ -996,7 +1029,7 @@ F32 LLDrawable::getVisibilityRadius() const { return llmax(getRadius(), vov->getLightRadius()); } else { - // llwarns ? + // LL_WARNS() ? } } return getRadius(); @@ -1006,26 +1039,52 @@ void LLDrawable::updateUVMinMax() { } -LLSpatialGroup* LLDrawable::getSpatialGroup() const +//virtual +bool LLDrawable::isVisible() const +{ + if (LLViewerOctreeEntryData::isVisible()) { - llassert((mSpatialGroupp == NULL) ? getBinIndex() == -1 : getBinIndex() != -1); - return mSpatialGroupp; + return true; +} + +{ + LLViewerOctreeGroup* group = mEntry->getGroup(); + if (group && group->isVisible()) + { + LLViewerOctreeEntryData::setVisible(); + return true; + } + } + + return false; } -void LLDrawable::setSpatialGroup(LLSpatialGroup *groupp) +//virtual +bool LLDrawable::isRecentlyVisible() const { - //precondition: mSpatialGroupp MUST be null or DEAD or mSpatialGroupp MUST NOT contain this - llassert(!mSpatialGroupp || mSpatialGroupp->isDead() || !mSpatialGroupp->hasElement(this)); + //currently visible or visible in the previous frame. + bool vis = LLViewerOctreeEntryData::isRecentlyVisible(); - //precondition: groupp MUST be null or groupp MUST contain this - llassert(!groupp || groupp->hasElement(this)); + if(!vis) + { + const U32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one. + vis = (sCurVisible - getVisible() < MIN_VIS_FRAME_RANGE); + } + + return vis ; +} -/*if (mSpatialGroupp && (groupp != mSpatialGroupp)) +void LLDrawable::setGroup(LLViewerOctreeGroup *groupp) { - mSpatialGroupp->setState(LLSpatialGroup::GEOM_DIRTY); - }*/ + LLSpatialGroup* cur_groupp = (LLSpatialGroup*)getGroup(); + + //precondition: mGroupp MUST be null or DEAD or mGroupp MUST NOT contain this + //llassert(!cur_groupp || cur_groupp->isDead() || !cur_groupp->hasElement(this)); - if (mSpatialGroupp != groupp && getVOVolume()) + //precondition: groupp MUST be null or groupp MUST contain this + llassert(!groupp || (LLSpatialGroup*)groupp->hasElement(this)); + + if (cur_groupp != groupp && getVOVolume()) { //NULL out vertex buffer references for volumes on spatial group change to maintain //requirement that every face vertex buffer is either NULL or points to a vertex buffer //contained by its drawable's spatial group @@ -1041,10 +1100,10 @@ void LLDrawable::setSpatialGroup(LLSpatialGroup *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(groupp == NULL ? (cur_groupp == NULL || cur_groupp->isDead()) || (!getEntry() || getEntry()->getBinIndex() == -1) : + // (getEntry() && getEntry()->getBinIndex() != -1)); - mSpatialGroupp = groupp; + LLViewerOctreeEntryData::setGroup(groupp); } LLSpatialPartition* LLDrawable::getSpatialPartition() @@ -1063,11 +1122,11 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() { if (mVObjp->isHUDAttachment()) { - setSpatialBridge(new LLHUDBridge(this)); + setSpatialBridge(new LLHUDBridge(this, getRegion())); } else { - setSpatialBridge(new LLVolumeBridge(this)); + setSpatialBridge(new LLVolumeBridge(this, getRegion())); } } return mSpatialBridge->asPartition(); @@ -1086,89 +1145,18 @@ LLSpatialPartition* LLDrawable::getSpatialPartition() return retval; } -const S32 MIN_VIS_FRAME_RANGE = 2 ; //two frames:the current one and the last one. -//static -S32 LLDrawable::getMinVisFrameRange() -{ - return MIN_VIS_FRAME_RANGE ; -} - -BOOL LLDrawable::isRecentlyVisible() const -{ - //currently visible or visible in the previous frame. - BOOL vis = isVisible() || (sCurVisible - mVisible < MIN_VIS_FRAME_RANGE) ; - - if(!vis) - { - LLSpatialGroup* group = getSpatialGroup(); - if (group && group->isRecentlyVisible()) - { - mVisible = sCurVisible; - vis = TRUE ; - } - } - - return vis ; -} - -BOOL LLDrawable::isVisible() const -{ - if (mVisible == sCurVisible) - { - return TRUE; - } - -#if 0 - //disabling this code fixes DEV-20105. Leaving in place in case some other bug pops up as a a result. - //should be safe to just always ask the spatial group for visibility. - if (isActive()) - { - if (isRoot()) - { - LLSpatialGroup* group = mSpatialBridge.notNull() ? mSpatialBridge->getSpatialGroup() : - getSpatialGroup(); - if (group && group->isVisible()) - { - mVisible = sCurVisible; - return TRUE; - } - } - else - { - if (getParent()->isVisible()) - { - mVisible = sCurVisible; - return TRUE; - } - } - } - else -#endif - { - LLSpatialGroup* group = getSpatialGroup(); - if (group && group->isVisible()) - { - mVisible = sCurVisible; - return TRUE; - } - } - - return FALSE; -} - //======================================= // Spatial Partition Bridging Drawable //======================================= -LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask) -: LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW_ARB) +LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 data_mask, LLViewerRegion* regionp) : + LLDrawable(root->getVObj(), true), + LLSpatialPartition(data_mask, render_by_group, GL_STREAM_DRAW_ARB, regionp) { mBridge = this; mDrawable = root; root->setSpatialBridge(this); - mBinIndex = -1; - mRenderType = mDrawable->mRenderType; mDrawableType = mDrawable->mRenderType; @@ -1189,10 +1177,13 @@ LLSpatialBridge::LLSpatialBridge(LLDrawable* root, BOOL render_by_group, U32 dat LLSpatialBridge::~LLSpatialBridge() { + if(mEntry) + { LLSpatialGroup* group = getSpatialGroup(); if (group) { - group->mSpatialPartition->remove(this, group); + group->getSpatialPartition()->remove(this, group); + } } //delete octree here so listeners will still be able to access bridge specific state @@ -1210,12 +1201,13 @@ void LLSpatialBridge::updateSpatialExtents() LLSpatialGroup* root = (LLSpatialGroup*) mOctree->getListener(0); { - LLFastTimer ftm(FTM_CULL_REBOUND); + LL_RECORD_BLOCK_TIME(FTM_CULL_REBOUND); root->rebound(); } + const LLVector4a* root_bounds = root->getBounds(); LLVector4a offset; - LLVector4a size = root->mBounds[1]; + LLVector4a size = root_bounds[1]; //VECTORIZE THIS LLMatrix4a mat; @@ -1227,7 +1219,7 @@ void LLSpatialBridge::updateSpatialExtents() LLVector4a center; mat.affineTransform(t, center); - mat.rotate(root->mBounds[0], offset); + mat.rotate(root_bounds[0], offset); center.add(offset); LLVector4a v[4]; @@ -1249,12 +1241,9 @@ void LLSpatialBridge::updateSpatialExtents() scale.mul(size); mat.rotate(scale, v[3]); - - LLVector4a& newMin = mExtents[0]; - LLVector4a& newMax = mExtents[1]; - + LLVector4a newMin; + LLVector4a newMax; newMin = newMax = center; - for (U32 i = 0; i < 4; i++) { LLVector4a delta; @@ -1267,19 +1256,21 @@ void LLSpatialBridge::updateSpatialExtents() newMin.setMin(newMin, min); newMax.setMax(newMax, max); } + setSpatialExtents(newMin, newMax); LLVector4a diagonal; diagonal.setSub(newMax, newMin); mRadius = diagonal.getLength3().getF32() * 0.5f; - mPositionGroup.setAdd(newMin,newMax); - mPositionGroup.mul(0.5f); + LLVector4a& pos = getGroupPosition(); + pos.setAdd(newMin,newMax); + pos.mul(0.5f); updateBinRadius(); } void LLSpatialBridge::updateBinRadius() { - mBinRadius = llmin( mOctree->getSize()[0]*0.5f, 256.f); + setBinRadius(llmin( mOctree->getSize()[0]*0.5f, 256.f)); } LLCamera LLSpatialBridge::transformCamera(LLCamera& camera) @@ -1313,7 +1304,7 @@ LLCamera LLSpatialBridge::transformCamera(LLCamera& camera) void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, BOOL for_select) { - mVisible = sCurVisible; + LLViewerOctreeEntryData::setVisible(); #if 0 && !LL_RELEASE_FOR_DOWNLOAD //crazy paranoid rules checking @@ -1323,46 +1314,46 @@ void LLDrawable::setVisible(LLCamera& camera, std::vector<LLDrawable*>* results, { if (isActive() && !mParent->isActive()) { - llerrs << "Active drawable has static parent!" << llendl; + LL_ERRS() << "Active drawable has static parent!" << LL_ENDL; } if (isStatic() && !mParent->isStatic()) { - llerrs << "Static drawable has active parent!" << llendl; + LL_ERRS() << "Static drawable has active parent!" << LL_ENDL; } if (mSpatialBridge) { - llerrs << "Child drawable has spatial bridge!" << llendl; + LL_ERRS() << "Child drawable has spatial bridge!" << LL_ENDL; } } else if (isActive() && !mSpatialBridge) { - llerrs << "Active root drawable has no spatial bridge!" << llendl; + LL_ERRS() << "Active root drawable has no spatial bridge!" << LL_ENDL; } else if (isStatic() && mSpatialBridge.notNull()) { - llerrs << "Static drawable has spatial bridge!" << llendl; + LL_ERRS() << "Static drawable has spatial bridge!" << LL_ENDL; } } #endif } -class LLOctreeMarkNotCulled: public LLOctreeTraveler<LLDrawable> +class LLOctreeMarkNotCulled: public OctreeTraveler { public: LLCamera* mCamera; LLOctreeMarkNotCulled(LLCamera* camera_in) : mCamera(camera_in) { } - virtual void traverse(const LLOctreeNode<LLDrawable>* node) + virtual void traverse(const OctreeNode* node) { LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0); group->setVisible(); - LLOctreeTraveler<LLDrawable>::traverse(node); + OctreeTraveler::traverse(node); } - void visit(const LLOctreeNode<LLDrawable>* branch) + void visit(const OctreeNode* branch) { gPipeline.markNotCulled((LLSpatialGroup*) branch->getListener(0), *mCamera); } @@ -1406,7 +1397,7 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* } if (!group || - LLDrawable::getCurrentFrame() - av->mVisible > 1 || + LLDrawable::getCurrentFrame() - av->getVisible() > 1 || impostor || !loaded) { @@ -1420,16 +1411,17 @@ void LLSpatialBridge::setVisible(LLCamera& camera_in, std::vector<LLDrawable*>* group->rebound(); LLVector4a center; - center.setAdd(mExtents[0], mExtents[1]); + const LLVector4a* exts = getSpatialExtents(); + center.setAdd(exts[0], exts[1]); center.mul(0.5f); LLVector4a size; - size.setSub(mExtents[1], mExtents[0]); + size.setSub(exts[1], exts[0]); size.mul(0.5f); if ((LLPipeline::sShadowRender && camera_in.AABBInFrustum(center, size)) || LLPipeline::sImpostorRender || (camera_in.AABBInFrustumNoFarClip(center, size) && - AABBSphereIntersect(mExtents[0], mExtents[1], camera_in.getOrigin(), camera_in.mFrustumCornerDist))) + AABBSphereIntersect(exts[0], exts[1], camera_in.getOrigin(), camera_in.mFrustumCornerDist))) { if (!LLPipeline::sImpostorRender && !LLPipeline::sShadowRender && @@ -1517,7 +1509,7 @@ void LLSpatialBridge::updateDistance(LLCamera& camera_in, bool force_update) void LLSpatialBridge::makeActive() { //it is an error to make a spatial bridge active (it's already active) - llerrs << "makeActive called on spatial bridge" << llendl; + LL_ERRS() << "makeActive called on spatial bridge" << LL_ENDL; } void LLSpatialBridge::move(LLDrawable *drawablep, LLSpatialGroup *curp, BOOL immediate) @@ -1544,9 +1536,7 @@ BOOL LLSpatialBridge::updateMove() void LLSpatialBridge::shiftPos(const LLVector4a& vec) { - mExtents[0].add(vec); - mExtents[1].add(vec); - mPositionGroup.add(vec); + LLDrawable::shift(vec); } void LLSpatialBridge::cleanupReferences() @@ -1554,11 +1544,8 @@ void LLSpatialBridge::cleanupReferences() LLDrawable::cleanupReferences(); if (mDrawable) { - /* - - DON'T DO THIS -- this should happen through octree destruction + mDrawable->setGroup(NULL); - mDrawable->setSpatialGroup(NULL); if (mDrawable->getVObj()) { LLViewerObject::const_child_list_t& child_list = mDrawable->getVObj()->getChildren(); @@ -1569,10 +1556,10 @@ void LLSpatialBridge::cleanupReferences() LLDrawable* drawable = child->mDrawable; if (drawable) { - drawable->setSpatialGroup(NULL); + drawable->setGroup(NULL); + } } } - }*/ LLDrawable* drawablep = mDrawable; mDrawable = NULL; @@ -1641,8 +1628,8 @@ void LLDrawable::updateFaceSize(S32 idx) } } -LLBridgePartition::LLBridgePartition() -: LLSpatialPartition(0, FALSE, 0) +LLBridgePartition::LLBridgePartition(LLViewerRegion* regionp) +: LLSpatialPartition(0, FALSE, 0, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_AVATAR; mPartitionType = LLViewerRegion::PARTITION_BRIDGE; @@ -1650,8 +1637,8 @@ LLBridgePartition::LLBridgePartition() mSlopRatio = 0.25f; } -LLHUDBridge::LLHUDBridge(LLDrawable* drawablep) -: LLVolumeBridge(drawablep) +LLHUDBridge::LLHUDBridge(LLDrawable* drawablep, LLViewerRegion* regionp) +: LLVolumeBridge(drawablep, regionp) { mDrawableType = LLPipeline::RENDER_TYPE_HUD; mPartitionType = LLViewerRegion::PARTITION_HUD; |