Xiaohong Bao 2013-10-24 20:50:08 -06:00
commit bcba6ee3a5
2 changed files with 47 additions and 19 deletions

View File

@ -36,7 +36,7 @@
//-----------------------------------------------------------------------------------
//static variables definitions
//-----------------------------------------------------------------------------------
U32 LLViewerOctreeEntryData::sCurVisible = 0;
U32 LLViewerOctreeEntryData::sCurVisible = 10; //reserve the low numbers for special use.
BOOL LLViewerOctreeDebug::sInDebug = FALSE;
static LLTrace::CountStatHandle<S32> sOcclusionQueries("occlusion_queries", "Number of occlusion queries executed"),
@ -234,7 +234,8 @@ LLViewerOctreeEntry::LLViewerOctreeEntry()
: LLTrace::MemTrackable<LLViewerOctreeEntry, 16>("LLViewerOctreeEntry"),
mGroup(NULL),
mBinRadius(0.f),
mBinIndex(-1)
mBinIndex(-1),
mVisible(0)
{
mPositionGroup.clear();
mExtents[0].clear();

View File

@ -1049,6 +1049,8 @@ void LLViewerRegion::addVisibleCacheEntry(LLVOCacheEntry* entry)
F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
{
static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
if(mDead)
{
return max_time;
@ -1059,8 +1061,27 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
return max_time;
}
if(!sNewObjectCreationThrottle)
{
return max_time;
}
U32 new_obj_count = sNewObjectCreationThrottle;
if(sNewObjectCreationThrottle < 0)
{
new_obj_count = (U32)-1; //maximum
}
else
{
new_obj_count *= 1.5f; //load 50% more for selection
}
LLTimer update_timer;
//object projected area threshold
F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
projection_threshold *= projection_threshold;
const F32 LARGE_SCENE_CONTRIBUTION = 100.f; //a large number to force to load the object.
const LLVector3 camera_origin = LLViewerCamera::getInstance()->getOrigin();
const U32 cur_frame = LLViewerOctreeEntryData::getCurrentFrame();
@ -1068,7 +1089,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
U32 last_update = mImpl->mLastCameraUpdate;
//process visible entries
for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); iter != mImpl->mVisibleEntries.end();)
for(LLVOCacheEntry::vocache_entry_set_t::iterator iter = mImpl->mVisibleEntries.begin(); new_obj_count > 0 && iter != mImpl->mVisibleEntries.end();)
{
LLVOCacheEntry* vo_entry = *iter;
@ -1078,6 +1099,10 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
if(vo_entry->getState() < LLVOCacheEntry::WAITING)
{
mImpl->mWaitingList.insert(vo_entry);
if(!(--new_obj_count))
{
break;
}
}
LLVOCacheEntry* child;
@ -1090,6 +1115,11 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
{
child->setSceneContribution(LARGE_SCENE_CONTRIBUTION); //a large number to force to load the child.
mImpl->mWaitingList.insert(child);
if(!(--new_obj_count))
{
break;
}
}
else
{
@ -1123,7 +1153,7 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
//process visible groups
std::set< LLPointer<LLViewerOctreeGroup> >::iterator group_iter = mImpl->mVisibleGroups.begin();
for(; group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
for(; new_obj_count > 0 && group_iter != mImpl->mVisibleGroups.end(); ++group_iter)
{
LLPointer<LLViewerOctreeGroup> group = *group_iter;
if(group->getNumRefs() < 3 || //group to be deleted
@ -1145,7 +1175,16 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
}
vo_entry->calcSceneContribution(camera_origin, needs_update, last_update);
mImpl->mWaitingList.insert(vo_entry);
if(vo_entry->getSceneContribution() > projection_threshold)
{
mImpl->mWaitingList.insert(vo_entry);
if(!(--new_obj_count))
{
break;
}
}
}
}
}
@ -1161,8 +1200,6 @@ F32 LLViewerRegion::updateVisibleEntries(F32 max_time)
F32 LLViewerRegion::createVisibleObjects(F32 max_time)
{
static LLCachedControl<F32> projection_area_cutoff(gSavedSettings,"ObjectProjectionAreaCutOFF");
if(mDead)
{
return max_time;
@ -1171,12 +1208,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
{
mImpl->mVOCachePartition->setCullHistory(FALSE);
return max_time;
}
//object projected area threshold
F32 pixel_meter_ratio = LLViewerCamera::getInstance()->getPixelMeterRatio();
F32 projection_threshold = pixel_meter_ratio > 0.f ? projection_area_cutoff / pixel_meter_ratio : 0.f;
projection_threshold *= projection_threshold;
}
S32 throttle = sNewObjectCreationThrottle;
BOOL has_new_obj = FALSE;
@ -1184,12 +1216,7 @@ F32 LLViewerRegion::createVisibleObjects(F32 max_time)
for(LLVOCacheEntry::vocache_entry_priority_list_t::iterator iter = mImpl->mWaitingList.begin();
iter != mImpl->mWaitingList.end(); ++iter)
{
LLVOCacheEntry* vo_entry = *iter;
if(vo_entry->getSceneContribution() < projection_threshold)
{
break;
}
LLVOCacheEntry* vo_entry = *iter;
if(vo_entry->getState() < LLVOCacheEntry::WAITING)
{