Apply occlusion refactor.

This commit is contained in:
Shyotl
2015-07-23 01:24:12 -05:00
parent dedd75dc4f
commit dbd1eb0d68
20 changed files with 2396 additions and 1529 deletions

View File

@@ -1300,18 +1300,18 @@ S32 LLPipeline::setLightingDetail(S32 level)
return mLightingDetail;
}
class LLOctreeDirtyTexture : public LLOctreeTraveler<LLDrawable>
class LLOctreeDirtyTexture : public OctreeTraveler
{
public:
const std::set<LLViewerFetchedTexture*>& mTextures;
LLOctreeDirtyTexture(const std::set<LLViewerFetchedTexture*>& textures) : mTextures(textures) { }
virtual void visit(const LLOctreeNode<LLDrawable>* node)
virtual void visit(const OctreeNode* node)
{
LLSpatialGroup* group = (LLSpatialGroup*) node->getListener(0);
if (!group->isState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
if (!group->hasState(LLSpatialGroup::GEOM_DIRTY) && !group->isEmpty())
{
for (LLSpatialGroup::draw_map_t::iterator i = group->mDrawMap.begin(); i != group->mDrawMap.end(); ++i)
{
@@ -1591,11 +1591,9 @@ void LLPipeline::allocDrawable(LLViewerObject *vobj)
LL_ERRS() << "Null object passed to allocDrawable!" << LL_ENDL;
}
LLDrawable *drawable = new LLDrawable();
LLDrawable *drawable = new LLDrawable(vobj);
vobj->mDrawable = drawable;
drawable->mVObjp = vobj;
//encompass completely sheared objects by taking
//the most extreme point possible (<1,1,0.5>)
drawable->setRadius(LLVector3(1,1,0.5f).scaleVec(vobj->getScale()).length());
@@ -1635,7 +1633,7 @@ void LLPipeline::unlinkDrawable(LLDrawable *drawable)
if (drawablep->getSpatialGroup())
{
LLFastTimer t(FTM_REMOVE_FROM_SPATIAL_PARTITION);
if (!drawablep->getSpatialGroup()->mSpatialPartition->remove(drawablep, drawablep->getSpatialGroup()))
if (!drawablep->getSpatialGroup()->getSpatialPartition()->remove(drawablep, drawablep->getSpatialGroup()))
{
#ifdef LL_RELEASE_FOR_DOWNLOAD
LL_WARNS() << "Couldn't remove object from spatial group!" << LL_ENDL;
@@ -2015,7 +2013,7 @@ void check_references(LLSpatialGroup* group, LLDrawable* drawable)
{
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
if (drawable == *i)
if (drawable == (LLDrawable*)(*i)->getDrawable())
{
LL_ERRS() << "LLDrawable deleted while actively reference by LLPipeline." << LL_ENDL;
}
@@ -2037,9 +2035,12 @@ void check_references(LLSpatialGroup* group, LLFace* face)
{
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
LLDrawable* drawable = *i;
LLDrawable* drawable = (LLDrawable*)(*i)->getDrawable();
if(drawable)
{
check_references(drawable, face);
}
}
}
}
void LLPipeline::checkReferences(LLFace* face)
@@ -2217,7 +2218,7 @@ BOOL LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3&
min = LLVector3(X,X,X);
max = LLVector3(-X,-X,-X);
U32 saved_camera_id = LLViewerCamera::sCurCameraID;
LLViewerCamera::eCameraID saved_camera_id = LLViewerCamera::sCurCameraID;
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
BOOL res = TRUE;
@@ -2444,15 +2445,16 @@ void LLPipeline::markNotCulled(LLSpatialGroup* group, LLCamera& camera)
return;
}
const LLVector4a* bounds = group->getBounds();
if (sMinRenderSize > 0.f &&
llmax(llmax(group->mBounds[1][0], group->mBounds[1][1]), group->mBounds[1][2]) < sMinRenderSize)
llmax(llmax(bounds[1][0], bounds[1][1]), bounds[1][2]) < sMinRenderSize)
{
return;
}
assertInitialized();
if (!group->mSpatialPartition->mRenderByGroup)
if (!group->getSpatialPartition()->mRenderByGroup)
{ //render by drawable
sCull->pushDrawableGroup(group);
}
@@ -2760,7 +2762,7 @@ void LLPipeline::rebuildGroups()
{
group->rebuildGeom();
if (group->mSpatialPartition->mRenderByGroup)
if (group->getSpatialPartition()->mRenderByGroup)
{
count++;
}
@@ -3094,23 +3096,23 @@ void LLPipeline::markMeshDirty(LLSpatialGroup* group)
void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
{
if (group && !group->isDead() && group->mSpatialPartition)
if (group && !group->isDead() && group->getSpatialPartition())
{
if (group->mSpatialPartition->mPartitionType == LLViewerRegion::PARTITION_HUD)
if (group->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_HUD)
{
priority = TRUE;
}
if (priority)
{
if (!group->isState(LLSpatialGroup::IN_BUILD_Q1))
if (!group->hasState(LLSpatialGroup::IN_BUILD_Q1))
{
llassert_always(!mGroupQ1Locked);
mGroupQ1.push_back(group);
group->setState(LLSpatialGroup::IN_BUILD_Q1);
if (group->isState(LLSpatialGroup::IN_BUILD_Q2))
if (group->hasState(LLSpatialGroup::IN_BUILD_Q2))
{
LLSpatialGroup::sg_vector_t::iterator iter = std::find(mGroupQ2.begin(), mGroupQ2.end(), group);
if (iter != mGroupQ2.end())
@@ -3121,7 +3123,7 @@ void LLPipeline::markRebuild(LLSpatialGroup* group, BOOL priority)
}
}
}
else if (!group->isState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1))
else if (!group->hasState(LLSpatialGroup::IN_BUILD_Q2 | LLSpatialGroup::IN_BUILD_Q1))
{
llassert_always(!mGroupQ2Locked);
//LL_ERRS() << "Non-priority updates not yet supported!" << LL_ENDL;
@@ -3199,10 +3201,10 @@ void LLPipeline::stateSort(LLCamera& camera, LLCullResult &result)
else
{
group->setVisible();
OctreeGuard guard(group->mOctreeNode);
OctreeGuard guard(group->getOctreeNode());
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
markVisible(*i, camera);
markVisible((LLDrawable*)(*i)->getDrawable(), camera);
}
if (!sDelayVBUpdate)
@@ -3287,10 +3289,10 @@ void LLPipeline::stateSort(LLSpatialGroup* group, LLCamera& camera)
{
if (!sSkipUpdate && group->changeLOD())
{
OctreeGuard guard(group->mOctreeNode);
OctreeGuard guard(group->getOctreeNode());
for (LLSpatialGroup::element_iter i = group->getDataBegin(); i != group->getDataEnd(); ++i)
{
LLDrawable* drawablep = *i;
LLDrawable* drawablep = (LLDrawable*)(*i)->getDrawable();
stateSort(drawablep, camera);
}
@@ -3413,10 +3415,10 @@ void forAllDrawables(LLCullResult::sg_iterator begin,
{
for (LLCullResult::sg_iterator i = begin; i != end; ++i)
{
OctreeGuard guard((*i)->mOctreeNode);
OctreeGuard guard((*i)->getOctreeNode());
for (LLSpatialGroup::element_iter j = (*i)->getDataBegin(); j != (*i)->getDataEnd(); ++j)
{
func(*j);
func((LLDrawable*)(*j)->getDrawable());
}
}
}
@@ -3653,7 +3655,7 @@ void LLPipeline::postSort(LLCamera& camera)
continue;
}
if (group->isState(LLSpatialGroup::NEW_DRAWINFO) && group->isState(LLSpatialGroup::GEOM_DIRTY))
if (group->hasState(LLSpatialGroup::NEW_DRAWINFO) && group->hasState(LLSpatialGroup::GEOM_DIRTY))
{ //no way this group is going to be drawable without a rebuild
group->rebuildGeom();
}
@@ -3691,7 +3693,7 @@ void LLPipeline::postSort(LLCamera& camera)
if (alpha != group->mDrawMap.end())
{ //store alpha groups for sorting
LLSpatialBridge* bridge = group->mSpatialPartition->asBridge();
LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge();
if (LLViewerCamera::sCurCameraID == LLViewerCamera::CAMERA_WORLD)
{
if (bridge)
@@ -4912,7 +4914,7 @@ void LLPipeline::renderDebug()
continue;
}
LLSpatialBridge* bridge = group->mSpatialPartition->asBridge();
LLSpatialBridge* bridge = group->getSpatialPartition()->asBridge();
if (bridge && (!bridge->mDrawable || bridge->mDrawable->isDead()))
{
@@ -9945,7 +9947,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
mShadowFrustPoints[j].clear();
}
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+j;
LLViewerCamera::sCurCameraID = LLViewerCamera::eCameraID(LLViewerCamera::CAMERA_SHADOW0+j);
//restore render matrices
glh_set_current_modelview(saved_view);
@@ -10304,7 +10306,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
//update shadow targets
for (U32 i = 0; i < 2; i++)
{ //for each current shadow
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW4+i;
LLViewerCamera::sCurCameraID = LLViewerCamera::eCameraID(LLViewerCamera::CAMERA_SHADOW4 + i);
if (mShadowSpotLight[i].notNull() &&
(mShadowSpotLight[i] == mTargetShadowSpotLight[0] ||
@@ -10416,7 +10418,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera)
static LLCullResult result[2];
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_SHADOW0+i+4;
LLViewerCamera::sCurCameraID = LLViewerCamera::eCameraID(LLViewerCamera::CAMERA_SHADOW0 + i + 4);
renderShadow(view[i+4], proj[i+4], shadow_cam, result[i], FALSE, FALSE, target_width);
@@ -10463,7 +10465,7 @@ void LLPipeline::renderGroups(LLRenderPass* pass, U32 type, U32 mask, BOOL textu
LLSpatialGroup* group = *i;
if (!group->isDead() &&
(!sUseOcclusion || !group->isOcclusionState(LLSpatialGroup::OCCLUDED)) &&
gPipeline.hasRenderType(group->mSpatialPartition->mDrawableType) &&
gPipeline.hasRenderType(group->getSpatialPartition()->mDrawableType) &&
group->mDrawMap.find(type) != group->mDrawMap.end())
{
pass->renderGroup(group,type,mask,texture);