summaryrefslogtreecommitdiff
path: root/indra/newview/llreflectionmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llreflectionmap.cpp')
-rw-r--r--indra/newview/llreflectionmap.cpp65
1 files changed, 32 insertions, 33 deletions
diff --git a/indra/newview/llreflectionmap.cpp b/indra/newview/llreflectionmap.cpp
index a26445b4bc..07e2c39379 100644
--- a/indra/newview/llreflectionmap.cpp
+++ b/indra/newview/llreflectionmap.cpp
@@ -49,33 +49,38 @@ LLReflectionMap::~LLReflectionMap()
}
}
-void LLReflectionMap::update(U32 resolution, U32 face)
+void LLReflectionMap::update(U32 resolution, U32 face, bool force_dynamic, F32 near_clip, bool useClipPlane, LLPlane clipPlane)
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
mLastUpdateTime = gFrameTimeSeconds;
llassert(mCubeArray.notNull());
llassert(mCubeIndex != -1);
//llassert(LLPipeline::sRenderDeferred);
-
+
// make sure we don't walk off the edge of the render target
while (resolution > gPipeline.mRT->deferredScreen.getWidth() ||
resolution > gPipeline.mRT->deferredScreen.getHeight())
{
resolution /= 2;
}
- gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, getNearClip(), getIsDynamic());
+
+ F32 clip = (near_clip > 0) ? near_clip : getNearClip();
+
+ gViewerWindow->cubeSnapshot(LLVector3(mOrigin), mCubeArray, mCubeIndex, face, clip, getIsDynamic() || force_dynamic, useClipPlane, clipPlane);
}
void LLReflectionMap::autoAdjustOrigin()
{
LL_PROFILE_ZONE_SCOPED_CATEGORY_DISPLAY;
- if (mGroup && !mComplete)
+
+ if (mGroup && !mComplete && !mGroup->hasState(LLViewerOctreeGroup::DEAD))
{
const LLVector4a* bounds = mGroup->getBounds();
auto* node = mGroup->getOctreeNode();
+ LLSpatialPartition* part = mGroup->getSpatialPartition();
- if (mGroup->getSpatialPartition()->mPartitionType == LLViewerRegion::PARTITION_VOLUME)
+ if (part && part->mPartitionType == LLViewerRegion::PARTITION_VOLUME)
{
mPriority = 0;
// cast a ray towards 8 corners of bounding box
@@ -140,7 +145,7 @@ void LLReflectionMap::autoAdjustOrigin()
LLVector3 origin(fp);
F32 height = LLWorld::instance().resolveLandHeightAgent(origin) + 2.f;
fp[2] = llmax(fp[2], height);
-
+
// make sure radius encompasses all objects
LLSimdScalar r2 = 0.0;
for (int i = 0; i < 8; ++i)
@@ -160,10 +165,10 @@ void LLReflectionMap::autoAdjustOrigin()
// make sure near clip doesn't poke through ground
fp[2] = llmax(fp[2], height+mRadius*0.5f);
-
+
}
}
- else if (mViewerObject)
+ else if (mViewerObject && !mViewerObject->isDead())
{
mPriority = 1;
mOrigin.load3(mViewerObject->getPositionAgent().mV);
@@ -215,7 +220,7 @@ F32 LLReflectionMap::getNearClip()
if (mViewerObject && mViewerObject->getVolume())
{
- ret = ((LLVOVolume*)mViewerObject)->getReflectionProbeNearClip();
+ ret = mViewerObject->getReflectionProbeNearClip();
}
else if (mGroup)
{
@@ -232,46 +237,40 @@ F32 LLReflectionMap::getNearClip()
bool LLReflectionMap::getIsDynamic()
{
if (gSavedSettings.getS32("RenderReflectionProbeDetail") > (S32) LLReflectionMapManager::DetailLevel::STATIC_ONLY &&
- mViewerObject &&
+ mViewerObject &&
mViewerObject->getVolume())
{
- return ((LLVOVolume*)mViewerObject)->getReflectionProbeIsDynamic();
+ return mViewerObject->getReflectionProbeIsDynamic();
}
return false;
}
bool LLReflectionMap::getBox(LLMatrix4& box)
-{
+{
if (mViewerObject)
{
LLVolume* volume = mViewerObject->getVolume();
- if (volume)
+ if (volume && mViewerObject->getReflectionProbeIsBox())
{
- LLVOVolume* vobjp = (LLVOVolume*)mViewerObject;
-
- if (vobjp->getReflectionProbeIsBox())
+ glm::mat4 mv(get_current_modelview());
+ LLVector3 s = mViewerObject->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f));
+ mRadius = s.magVec();
+ glm::mat4 scale = glm::scale(glm::make_vec3(LLVector4(s).mV));
+ if (mViewerObject->mDrawable != nullptr)
{
- glh::matrix4f mv(gGLModelView);
- glh::matrix4f scale;
- LLVector3 s = vobjp->getScale().scaledVec(LLVector3(0.5f, 0.5f, 0.5f));
- mRadius = s.magVec();
- scale.set_scale(glh::vec3f(s.mV));
- if (vobjp->mDrawable != nullptr)
- {
- // object to agent space (no scale)
- glh::matrix4f rm((F32*)vobjp->mDrawable->getWorldMatrix().mMatrix);
+ // object to agent space (no scale)
+ glm::mat4 rm(glm::make_mat4((F32*)mViewerObject->mDrawable->getWorldMatrix().mMatrix));
- // construct object to camera space (with scale)
- mv = mv * rm * scale;
+ // construct object to camera space (with scale)
+ mv = mv * rm * scale;
- // inverse is camera space to object unit cube
- mv = mv.inverse();
+ // inverse is camera space to object unit cube
+ mv = glm::inverse(mv);
- box = LLMatrix4(mv.m);
+ box = LLMatrix4(glm::value_ptr(mv));
- return true;
- }
+ return true;
}
}
}
@@ -332,7 +331,7 @@ void LLReflectionMap::doOcclusion(const LLVector4a& eye)
mOccluded = false;
return;
}
-
+
if (mOcclusionQuery == 0)
{ // no query was previously issued, allocate one and issue
LL_PROFILE_ZONE_NAMED_CATEGORY_PIPELINE("rmdo - glGenQueries");