summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorXiaohong Bao <bao@lindenlab.com>2012-12-18 14:37:16 -0700
committerXiaohong Bao <bao@lindenlab.com>2012-12-18 14:37:16 -0700
commitc66c8d32c7ead6535cf6d80b7001499df83a523d (patch)
tree43c4578ddd6d5ad27b72ffdefbb705bf73b2e588 /indra
parenta853a8cf20729eb954c834e2f8afb03d3b079d2f (diff)
parente1247d631f24065a31d9668915cb8bc84f3abc7f (diff)
Automated merge with ssh://hg.lindenlab.com/bao/bao-viewer-interesting/
Diffstat (limited to 'indra')
-rw-r--r--indra/llmath/llcamera.cpp50
-rw-r--r--indra/llmath/llcamera.h8
-rw-r--r--indra/newview/lldrawable.cpp13
-rw-r--r--indra/newview/llvieweroctree.cpp50
-rw-r--r--indra/newview/llvieweroctree.h19
-rw-r--r--indra/newview/llviewerregion.cpp98
-rw-r--r--indra/newview/llviewerregion.h1
-rw-r--r--indra/newview/llvocache.cpp49
-rw-r--r--indra/newview/llvocache.h2
-rw-r--r--indra/newview/llworld.cpp1
10 files changed, 168 insertions, 123 deletions
diff --git a/indra/llmath/llcamera.cpp b/indra/llmath/llcamera.cpp
index 22ba26f99b..6551b52462 100644
--- a/indra/llmath/llcamera.cpp
+++ b/indra/llmath/llcamera.cpp
@@ -161,7 +161,7 @@ size_t LLCamera::readFrustumFromBuffer(const char *buffer)
// ---------------- test methods ----------------
-S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
+S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius, const LLPlane* planes)
{
static const LLVector4a scaler[] = {
LLVector4a(-1,-1,-1),
@@ -174,6 +174,12 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
LLVector4a( 1, 1, 1)
};
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -183,7 +189,7 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
mask = mPlaneMask[i];
if (mask != 0xff)
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, scaler[mask]);
minp.setSub(center, rscale);
@@ -204,8 +210,14 @@ S32 LLCamera::AABBInFrustum(const LLVector4a &center, const LLVector4a& radius)
return result?1:2;
}
+//exactly same as the function AABBInFrustum(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustum(center, radius, mRegionPlanes);
+}
-S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes)
{
static const LLVector4a scaler[] = {
LLVector4a(-1,-1,-1),
@@ -218,6 +230,12 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
LLVector4a( 1, 1, 1)
};
+ if(!planes)
+ {
+ //use agent space
+ planes = mAgentPlanes;
+ }
+
U8 mask = 0;
bool result = false;
LLVector4a rscale, maxp, minp;
@@ -227,7 +245,7 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
mask = mPlaneMask[i];
if ((i != 5) && (mask != 0xff))
{
- const LLPlane& p(mAgentPlanes[i]);
+ const LLPlane& p(planes[i]);
p.getAt<3>(d);
rscale.setMul(radius, scaler[mask]);
minp.setSub(center, rscale);
@@ -248,6 +266,13 @@ S32 LLCamera::AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a&
return result?1:2;
}
+//exactly same as the function AABBInFrustumNoFarClip(...)
+//except uses mRegionPlanes instead of mAgentPlanes.
+S32 LLCamera::AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius)
+{
+ return AABBInFrustumNoFarClip(center, radius, mRegionPlanes);
+}
+
int LLCamera::sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius)
{
LLVector3 dist = sphere_center-mFrustCenter;
@@ -584,6 +609,23 @@ void LLCamera::calcAgentFrustumPlanes(LLVector3* frust)
}
}
+//calculate regional planes from mAgentPlanes.
+//vector "shift" is the vector of the region origin in the agent space.
+void LLCamera::calcRegionFrustumPlanes(const LLVector3& shift)
+{
+ F32 d;
+ LLVector3 n;
+ for(S32 i = 0 ; i < 7; i++)
+ {
+ if (mPlaneMask[i] != 0xff)
+ {
+ n.setVec(mAgentPlanes[i][0], mAgentPlanes[i][1], mAgentPlanes[i][2]);
+ d = mAgentPlanes[i][3] - n * shift;
+ mRegionPlanes[i].setVec(n, d);
+ }
+ }
+}
+
void LLCamera::calculateFrustumPlanes(F32 left, F32 right, F32 top, F32 bottom)
{
LLVector3 a, b, c;
diff --git a/indra/llmath/llcamera.h b/indra/llmath/llcamera.h
index 0b591be622..898d73ed7e 100644
--- a/indra/llmath/llcamera.h
+++ b/indra/llmath/llcamera.h
@@ -109,6 +109,7 @@ public:
private:
LL_ALIGN_16(LLPlane mAgentPlanes[7]); //frustum planes in agent space a la gluUnproject (I'm a bastard, I know) - DaveP
+ LL_ALIGN_16(LLPlane mRegionPlanes[7]); //frustum planes in a local region space, derived from mAgentPlanes
U8 mPlaneMask[8]; // 8 for alignment
F32 mView; // angle between top and bottom frustum planes in radians.
@@ -178,6 +179,7 @@ public:
// Return number of bytes copied.
size_t readFrustumFromBuffer(const char *buffer);
void calcAgentFrustumPlanes(LLVector3* frust);
+ void calcRegionFrustumPlanes(const LLVector3& shift); //calculate regional planes from mAgentPlanes.
void ignoreAgentFrustumPlane(S32 idx);
// Returns 1 if partly in, 2 if fully in.
@@ -186,8 +188,10 @@ public:
S32 sphereInFrustum(const LLVector3 &center, const F32 radius) const;
S32 pointInFrustum(const LLVector3 &point) const { return sphereInFrustum(point, 0.0f); }
S32 sphereInFrustumFull(const LLVector3 &center, const F32 radius) const { return sphereInFrustum(center, radius); }
- S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius);
- S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustum(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustum(const LLVector4a& center, const LLVector4a& radius);
+ S32 AABBInFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius, const LLPlane* planes = NULL);
+ S32 AABBInRegionFrustumNoFarClip(const LLVector4a& center, const LLVector4a& radius);
//does a quick 'n dirty sphere-sphere check
S32 sphereInFrustumQuick(const LLVector3 &sphere_center, const F32 radius);
diff --git a/indra/newview/lldrawable.cpp b/indra/newview/lldrawable.cpp
index c782fbfe7e..1b7a98ba54 100644
--- a/indra/newview/lldrawable.cpp
+++ b/indra/newview/lldrawable.cpp
@@ -1473,19 +1473,6 @@ void LLSpatialBridge::shiftPos(const LLVector4a& vec)
void LLSpatialBridge::cleanupReferences()
{
- LLPointer<LLVOCacheEntry> dummy_entry;
- if (mDrawable && mDrawable->isDead() && mDrawable->getEntry()->hasVOCacheEntry())
- {
- //create a dummy entry to insert the entire LLSpatialBridge to the vo_cache partition so it can be reloaded.
-
- dummy_entry = new LLVOCacheEntry();
- dummy_entry->setOctreeEntry(mEntry);
- dummy_entry->addChild((LLVOCacheEntry*)mDrawable->getEntry()->getVOCacheEntry());
- //llassert(!mDrawable->getParent());
-
- //mDrawable->mParent = this;
- }
-
LLDrawable::cleanupReferences();
if (mDrawable)
{
diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp
index b6e0674a95..7f502a6c51 100644
--- a/indra/newview/llvieweroctree.cpp
+++ b/indra/newview/llvieweroctree.cpp
@@ -675,6 +675,8 @@ void LLViewerOctreeCull::traverse(const OctreeNode* n)
}
}
+//------------------------------------------
+//agent space group culling
S32 LLViewerOctreeCull::AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group)
{
return mCamera->AABBInFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
@@ -685,6 +687,14 @@ S32 LLViewerOctreeCull::AABBSphereIntersectGroupExtents(const LLviewerOctreeGrou
return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
}
+S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group)
+{
+ return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+}
+//------------------------------------------
+
+//------------------------------------------
+//agent space object set culling
S32 LLViewerOctreeCull::AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group)
{
return mCamera->AABBInFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
@@ -695,15 +705,47 @@ S32 LLViewerOctreeCull::AABBSphereIntersectObjectExtents(const LLviewerOctreeGro
return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin(), mCamera->mFrustumCornerDist);
}
-S32 LLViewerOctreeCull::AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group)
+S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group)
{
- return mCamera->AABBInFrustum(group->mBounds[0], group->mBounds[1]);
+ return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
}
+//------------------------------------------
-S32 LLViewerOctreeCull::AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group)
+//------------------------------------------
+//local regional space group culling
+S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group)
{
- return mCamera->AABBInFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+ return mCamera->AABBInRegionFrustumNoFarClip(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group)
+{
+ return mCamera->AABBInRegionFrustum(group->mBounds[0], group->mBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift)
+{
+ return AABBSphereIntersect(group->mExtents[0], group->mExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist);
+}
+//------------------------------------------
+
+//------------------------------------------
+//local regional space object culling
+S32 LLViewerOctreeCull::AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group)
+{
+ return mCamera->AABBInRegionFrustum(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group)
+{
+ return mCamera->AABBInRegionFrustumNoFarClip(group->mObjectBounds[0], group->mObjectBounds[1]);
+}
+
+S32 LLViewerOctreeCull::AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift)
+{
+ return AABBSphereIntersect(group->mObjectExtents[0], group->mObjectExtents[1], mCamera->getOrigin() - shift, mCamera->mFrustumCornerDist);
}
+//------------------------------------------
//virtual
bool LLViewerOctreeCull::checkObjects(const OctreeNode* branch, const LLviewerOctreeGroup* group)
diff --git a/indra/newview/llvieweroctree.h b/indra/newview/llvieweroctree.h
index b89014119c..f6ad3ac327 100644
--- a/indra/newview/llvieweroctree.h
+++ b/indra/newview/llvieweroctree.h
@@ -280,13 +280,26 @@ public:
virtual bool earlyFail(LLviewerOctreeGroup* group);
virtual void traverse(const OctreeNode* n);
- S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);
+ //agent space group cull
+ S32 AABBInFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);
S32 AABBSphereIntersectGroupExtents(const LLviewerOctreeGroup* group);
- S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group);
- S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group);
S32 AABBInFrustumGroupBounds(const LLviewerOctreeGroup* group);
+
+ //agent space object set cull
+ S32 AABBInFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group);
+ S32 AABBSphereIntersectObjectExtents(const LLviewerOctreeGroup* group);
S32 AABBInFrustumObjectBounds(const LLviewerOctreeGroup* group);
+ //local region space group cull
+ S32 AABBInRegionFrustumNoFarClipGroupBounds(const LLviewerOctreeGroup* group);
+ S32 AABBInRegionFrustumGroupBounds(const LLviewerOctreeGroup* group);
+ S32 AABBRegionSphereIntersectGroupExtents(const LLviewerOctreeGroup* group, const LLVector3& shift);
+
+ //local region space object set cull
+ S32 AABBInRegionFrustumNoFarClipObjectBounds(const LLviewerOctreeGroup* group);
+ S32 AABBInRegionFrustumObjectBounds(const LLviewerOctreeGroup* group);
+ S32 AABBRegionSphereIntersectObjectExtents(const LLviewerOctreeGroup* group, const LLVector3& shift);
+
virtual S32 frustumCheck(const LLviewerOctreeGroup* group) = 0;
virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group) = 0;
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index ab692308b0..33e8348660 100644
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -87,6 +87,7 @@ const F32 CAP_REQUEST_TIMEOUT = 18;
const S32 MAX_CAP_REQUEST_ATTEMPTS = 30;
LLViewerRegion* LLViewerRegion::sCurRegionp = NULL;
+BOOL LLViewerRegion::sVOCacheCullingEnabled = FALSE;
typedef std::map<std::string, std::string> CapabilityMap;
@@ -141,7 +142,6 @@ public:
LLVOCacheEntry::vocache_entry_map_t mCacheMap; //all cached entries
LLVOCacheEntry::vocache_entry_set_t mActiveSet; //all active entries;
LLVOCacheEntry::vocache_entry_set_t mWaitingSet; //entries waiting for LLDrawable to be generated.
- std::set< LLPointer<LLVOCacheEntry> > mDummyEntries; //dummy vo cache entries, for LLSpatialBridge use.
std::set< LLviewerOctreeGroup* > mVisibleGroups; //visible groupa
LLVOCachePartition* mVOCachePartition;
LLVOCacheEntry::vocache_entry_set_t mVisibleEntries; //must-be-created visible entries wait for objects creation.
@@ -841,17 +841,8 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
{
return;
}
- if(entry->isDummy())
- {
- mImpl->mDummyEntries.insert(entry); //keep a copy to prevent from being deleted.
- addToVOCacheTree(entry);
- }
- else if(!drawablep->getParent()) //root node
- {
- addToVOCacheTree(entry);
- mImpl->mVisibleEntries.erase(entry);
- }
- else //child node
+
+ if(drawablep->getParent()) //child object
{
LLViewerOctreeEntry* parent_oct_entry = drawablep->getParent()->getEntry();
if(parent_oct_entry && parent_oct_entry->hasVOCacheEntry())
@@ -860,7 +851,19 @@ void LLViewerRegion::removeActiveCacheEntry(LLVOCacheEntry* entry, LLDrawable* d
parent->addChild(entry);
}
}
+ else //insert to vo cache tree.
+ {
+ //shift to the local regional space from agent space
+ const LLVector3 pos = drawablep->getVObj()->getPositionRegion();
+ LLVector4a vec(pos[0], pos[1], pos[2]);
+ LLVector4a shift;
+ shift.setSub(vec, entry->getPositionGroup());
+ entry->shift(shift);
+
+ addToVOCacheTree(entry);
+ }
+ mImpl->mVisibleEntries.erase(entry);
mImpl->mActiveSet.erase(entry);
mImpl->mWaitingSet.erase(entry);
entry->setState(LLVOCacheEntry::INACTIVE);
@@ -878,7 +881,10 @@ void LLViewerRegion::addVisibleGroup(LLviewerOctreeGroup* group)
void LLViewerRegion::addToVOCacheTree(LLVOCacheEntry* entry)
{
- static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
+ if(!sVOCacheCullingEnabled)
+ {
+ return;
+ }
if(mDead || !entry || !entry->getEntry())
{
@@ -954,12 +960,13 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
//process visible entries
max_time *= 0.5f; //only use up to half available time to update entries.
+#if 1
for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
{
LLVOCacheEntry* vo_entry = *iter;
vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);
- if(vo_entry->getState() < LLVOCacheEntry::WAITING && !vo_entry->isDummy())
+ if(vo_entry->getState() < LLVOCacheEntry::WAITING)
{
mImpl->mWaitingList.insert(vo_entry);
}
@@ -987,12 +994,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
if(!vo_entry->getNumOfChildren())
{
- if(vo_entry->isDummy())
- {
- mImpl->mDummyEntries.erase(vo_entry);
- iter = mImpl->mVisibleEntries.erase(iter);
- }
- else if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
+ if(vo_entry->getState() >= LLVOCacheEntry::WAITING)
{
iter = mImpl->mVisibleEntries.erase(iter);
}
@@ -1011,6 +1013,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
// break;
//}
}
+#endif
//process visible groups
std::set< LLviewerOctreeGroup* >::iterator group_iter = mImpl->mVisibleGroups.begin();
@@ -1027,11 +1030,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
if((*i)->hasVOCacheEntry())
{
LLVOCacheEntry* vo_entry = (LLVOCacheEntry*)(*i)->getVOCacheEntry();
- if(vo_entry->isDummy())
- {
- addVisibleCacheEntry(vo_entry); //for LLSpatialBridge.
- continue;
- }
vo_entry->calcSceneContribution(camera_origin, needs_update, mImpl->mLastCameraUpdate);
mImpl->mWaitingList.insert(vo_entry);
@@ -1118,6 +1116,11 @@ BOOL LLViewerRegion::idleUpdate(F32 max_update_time)
F32 LLViewerRegion::killInvisibleObjects(F32 max_time)
{
+ if(!sVOCacheCullingEnabled)
+ {
+ return max_time;
+ }
+
std::vector<LLDrawable*> delete_list;
for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mActiveSet.begin();
iter != mImpl->mActiveSet.end(); ++iter)
@@ -1695,13 +1698,6 @@ LLViewerRegion::eCacheUpdateResult LLViewerRegion::cacheFullUpdate(LLViewerObjec
LLVOCacheEntry* LLViewerRegion::getCacheEntryForOctree(U32 local_id)
{
- static BOOL vo_cache_culling_enabled = gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
-
- if(!vo_cache_culling_enabled)
- {
- return NULL;
- }
-
LLVOCacheEntry* entry = getCacheEntry(local_id);
removeFromVOCacheTree(entry);
@@ -1741,44 +1737,6 @@ bool LLViewerRegion::probeCache(U32 local_id, U32 crc, U8 &cache_miss_type)
}
addVisibleCacheEntry(entry);
-#if 0
- if(entry->isBridgeChild()) //bridge child
- {
- addVisibleCacheEntry(entry);
- }
- else
- {
- U32 parent_id = entry->getParentID();
- if(parent_id > 0) //has parent
- {
- LLVOCacheEntry* parent = getCacheEntry(parent_id);
-
- if(parent) //parent cached
- {
- parent->addChild(entry);
-
- if(parent->isState(LLVOCacheEntry::INACTIVE))
- {
- //addToVOCacheTree(parent);
- addVisibleCacheEntry(parent);
- }
- else //parent visible
- {
- addVisibleCacheEntry(parent);
- }
- }
- else //parent not cached. This should not happen, but just in case...
- {
- addVisibleCacheEntry(entry);
- }
- }
- else //root node
- {
- //addToVOCacheTree(entry);
- addVisibleCacheEntry(entry);
- }
- }
-#endif
return true;
}
else
diff --git a/indra/newview/llviewerregion.h b/indra/newview/llviewerregion.h
index 9a47227f1c..dbc59cee8f 100644
--- a/indra/newview/llviewerregion.h
+++ b/indra/newview/llviewerregion.h
@@ -392,6 +392,7 @@ public:
LLDynamicArray<LLUUID> mMapAvatarIDs;
static LLViewerRegion* sCurRegionp;
+ static BOOL sVOCacheCullingEnabled; //vo cache culling enabled or not.
private:
LLViewerRegionImpl * mImpl;
diff --git a/indra/newview/llvocache.cpp b/indra/newview/llvocache.cpp
index 8ea79dbae6..59645fdbe9 100644
--- a/indra/newview/llvocache.cpp
+++ b/indra/newview/llvocache.cpp
@@ -424,24 +424,6 @@ void LLVOCacheEntry::calcSceneContribution(const LLVector3& camera_origin, bool
setVisible();
}
-U32 LLVOCacheEntry::getParentID()
-{
- if(!(mState & CHILD))
- {
- return 0; //not a child
- }
-
- U32 parent_id = 0;
- LLDataPackerBinaryBuffer* dp = getDP();
- if(dp)
- {
- dp->reset();
- dp->unpackU32(parent_id, "ParentID");
- dp->reset();
- }
- return parent_id;
-}
-
//-------------------------------------------------------------------
//LLVOCachePartition
//-------------------------------------------------------------------
@@ -471,24 +453,31 @@ void LLVOCachePartition::removeEntry(LLViewerOctreeEntry* entry)
class LLVOCacheOctreeCull : public LLViewerOctreeCull
{
public:
- LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp) : LLViewerOctreeCull(camera), mRegionp(regionp) {}
+ LLVOCacheOctreeCull(LLCamera* camera, LLViewerRegion* regionp, const LLVector3& shift) : LLViewerOctreeCull(camera), mRegionp(regionp)
+ {
+ mLocalShift = shift;
+ }
virtual S32 frustumCheck(const LLviewerOctreeGroup* group)
{
- S32 res = AABBInFrustumNoFarClipGroupBounds(group);
+ //S32 res = AABBInRegionFrustumGroupBounds(group);
+
+ S32 res = AABBInRegionFrustumNoFarClipGroupBounds(group);
if (res != 0)
{
- res = llmin(res, AABBSphereIntersectGroupExtents(group));
+ res = llmin(res, AABBRegionSphereIntersectGroupExtents(group, mLocalShift));
}
return res;
}
virtual S32 frustumCheckObjects(const LLviewerOctreeGroup* group)
{
- S32 res = AABBInFrustumNoFarClipObjectBounds(group);
+ //S32 res = AABBInRegionFrustumObjectBounds(group);
+
+ S32 res = AABBInRegionFrustumNoFarClipObjectBounds(group);
if (res != 0)
{
- res = llmin(res, AABBSphereIntersectObjectExtents(group));
+ res = llmin(res, AABBRegionSphereIntersectObjectExtents(group, mLocalShift));
}
return res;
}
@@ -500,10 +489,16 @@ public:
private:
LLViewerRegion* mRegionp;
+ LLVector3 mLocalShift; //shift vector from agent space to local region space.
};
S32 LLVOCachePartition::cull(LLCamera &camera)
{
+ if(!LLViewerRegion::sVOCacheCullingEnabled)
+ {
+ return 0;
+ }
+
if(mVisitedTime == LLViewerOctreeEntryData::getCurrentFrame())
{
return 0; //already visited.
@@ -511,8 +506,12 @@ S32 LLVOCachePartition::cull(LLCamera &camera)
mVisitedTime = LLViewerOctreeEntryData::getCurrentFrame();
((LLviewerOctreeGroup*)mOctree->getListener(0))->rebound();
-
- LLVOCacheOctreeCull culler(&camera, mRegionp);
+
+ //localize the camera
+ LLVector3 region_agent = mRegionp->getOriginAgent();
+ camera.calcRegionFrustumPlanes(region_agent);
+
+ LLVOCacheOctreeCull culler(&camera, mRegionp, region_agent);
culler.traverse(mOctree);
return 0;
diff --git a/indra/newview/llvocache.h b/indra/newview/llvocache.h
index 4d058ffdac..f5cc5d2f75 100644
--- a/indra/newview/llvocache.h
+++ b/indra/newview/llvocache.h
@@ -98,7 +98,6 @@ public:
S32 getHitCount() const { return mHitCount; }
S32 getCRCChangeCount() const { return mCRCChangeCount; }
S32 getMinVisFrameRange()const;
- U32 getParentID();
void calcSceneContribution(const LLVector3& camera_origin, bool needs_update, U32 last_update);
void setSceneContribution(F32 scene_contrib) {mSceneContrib = scene_contrib;}
@@ -118,7 +117,6 @@ public:
LLVOCacheEntry* getChild(S32 i) {return mChildrenList[i];}
S32 getNumOfChildren() {return mChildrenList.size();}
void clearChildrenList() {mChildrenList.clear();}
- bool isDummy() {return !mBuffer;}
public:
typedef std::map<U32, LLPointer<LLVOCacheEntry> > vocache_entry_map_t;
diff --git a/indra/newview/llworld.cpp b/indra/newview/llworld.cpp
index aed2835e4a..7a7d6a7b43 100644
--- a/indra/newview/llworld.cpp
+++ b/indra/newview/llworld.cpp
@@ -110,6 +110,7 @@ LLWorld::LLWorld() :
gGL.getTexUnit(0)->bind(mDefaultWaterTexturep);
mDefaultWaterTexturep->setAddressMode(LLTexUnit::TAM_CLAMP);
+ LLViewerRegion::sVOCacheCullingEnabled = (BOOL)gSavedSettings.getBOOL("ObjectCacheViewCullingEnabled");
}