summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/pipeline.cpp223
1 files changed, 114 insertions, 109 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index 17650bde15..f9d510472d 100644
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -9228,28 +9228,27 @@ inline float sgn(float a)
}
void LLPipeline::generateWaterReflection(LLCamera& camera_in)
-{
- if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate)
- {
- bool skip_avatar_update = false;
- if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
- {
- skip_avatar_update = true;
- }
-
- LLCamera camera = camera_in;
+{
+ if (LLPipeline::sWaterReflections && assertInitialized() && LLDrawPoolWater::sNeedsReflectionUpdate)
+ {
+ bool skip_avatar_update = false;
+ if (!isAgentAvatarValid() || gAgentCamera.getCameraAnimating() || gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK || !LLVOAvatar::sVisibleInFirstPerson)
+ {
+ skip_avatar_update = true;
+ }
+ LLCamera camera = camera_in;
camera.setFar(camera_in.getFar() * 0.75f);
bool camera_is_underwater = LLViewerCamera::getInstance()->cameraUnderWater();
- LLPipeline::sReflectionRender = true;
-
- gPipeline.pushRenderTypeMask();
+ LLPipeline::sReflectionRender = true;
+
+ gPipeline.pushRenderTypeMask();
glh::matrix4f saved_modelview = get_current_modelview();
glh::matrix4f saved_projection = get_current_projection();
- glh::matrix4f mat;
+ glh::matrix4f mat;
S32 reflection_detail = RenderReflectionDetail;
@@ -9265,22 +9264,24 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point);
- //plane params
+ //plane params
LLPlane plane;
- LLVector3 pnorm;
- S32 water_clip = 0;
+ LLVector3 pnorm;
+ S32 water_clip = 0;
if (!camera_is_underwater)
- { //camera is above water, clip plane points up
- pnorm.setVec(0,0,1);
+ {
+ //camera is above water, clip plane points up
+ pnorm.setVec(0,0,1);
plane.setVec(pnorm, -water_height);
water_clip = 1;
- }
- else
- { //camera is below water, clip plane points down
- pnorm = LLVector3(0,0,-1);
+ }
+ else
+ {
+ //camera is below water, clip plane points down
+ pnorm = LLVector3(0,0,-1);
plane.setVec(pnorm, water_height);
water_clip = -1;
- }
+ }
S32 occlusion = LLPipeline::sUseOcclusion;
@@ -9288,9 +9289,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
LLPipeline::sUseOcclusion = 0;
if (!camera_is_underwater)
- { //generate planar reflection map
-
- LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0;
+ {
+ //generate planar reflection map
+ LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER0;
gGL.matrixMode(LLRender::MM_MODELVIEW);
gGL.pushMatrix();
@@ -9303,9 +9304,9 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
mReflectionModelView = mat;
set_current_modelview(mat);
- gGL.loadMatrix(mat.m);
+ gGL.loadMatrix(mat.m);
- LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE);
+ LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE);
glh::vec3f origin(0, 0, 0);
glh::matrix4f inv_mat = mat.inverse();
@@ -9313,10 +9314,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
camera.setOrigin(origin.v);
- glCullFace(GL_FRONT);
+ glCullFace(GL_FRONT);
- if (LLDrawPoolWater::sNeedsReflectionUpdate)
- {
+ if (LLDrawPoolWater::sNeedsReflectionUpdate)
+ {
gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
glClearColor(0,0,0,0);
mWaterRef.bindTarget();
@@ -9326,38 +9327,38 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
gGL.setColorMask(true, false);
mWaterRef.getViewport(gGLViewport);
- //initial sky pass (no user clip plane)
- { //mask out everything but the sky
- gPipeline.pushRenderTypeMask();
+ //initial sky pass (no user clip plane)
+ //mask out everything but the sky
+ gPipeline.pushRenderTypeMask();
+ {
+ if (reflection_detail >= WATER_REFLECT_MINIMAL)
{
- if (reflection_detail >= WATER_REFLECT_MINIMAL)
- {
- gPipeline.andRenderTypeMask(
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::END_RENDER_TYPES);
- }
- else
- {
- gPipeline.andRenderTypeMask(
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_WL_SKY,
- LLPipeline::END_RENDER_TYPES);
- }
-
- updateCull(camera, mSky);
- stateSort(camera, mSky);
- renderGeom(camera, TRUE);
+ gPipeline.andRenderTypeMask(
+ LLPipeline::RENDER_TYPE_SKY,
+ LLPipeline::RENDER_TYPE_WL_SKY,
+ LLPipeline::RENDER_TYPE_CLOUDS,
+ LLPipeline::END_RENDER_TYPES);
}
- gPipeline.popRenderTypeMask();
- }
+ else
+ {
+ gPipeline.andRenderTypeMask(
+ LLPipeline::RENDER_TYPE_SKY,
+ LLPipeline::RENDER_TYPE_WL_SKY,
+ LLPipeline::END_RENDER_TYPES);
+ }
+
+ updateCull(camera, mSky);
+ stateSort(camera, mSky);
+ renderGeom(camera, TRUE);
+ }
+ gPipeline.popRenderTypeMask();
if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT)
{
gPipeline.pushRenderTypeMask();
{
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
+ clearRenderTypeMask(
+ LLPipeline::RENDER_TYPE_WATER,
LLPipeline::RENDER_TYPE_VOIDWATER,
LLPipeline::RENDER_TYPE_GROUND,
LLPipeline::RENDER_TYPE_SKY,
@@ -9371,7 +9372,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
clearRenderTypeMask(LLPipeline::RENDER_TYPE_PARTICLES, END_RENDER_TYPES);
if (reflection_detail < WATER_REFLECT_AVATARS)
{
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_AVATAR, LLPipeline::RENDER_TYPE_CONTROL_AV, END_RENDER_TYPES);
+ clearRenderTypeMask(
+ LLPipeline::RENDER_TYPE_AVATAR,
+ LLPipeline::RENDER_TYPE_CONTROL_AV,
+ END_RENDER_TYPES);
if (reflection_detail < WATER_REFLECT_STATIC_OBJECTS)
{
clearRenderTypeMask(LLPipeline::RENDER_TYPE_VOLUME, END_RENDER_TYPES);
@@ -9392,45 +9396,46 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
mWaterRef.flush();
}
- glCullFace(GL_BACK);
+ glCullFace(GL_BACK);
gGL.matrixMode(LLRender::MM_MODELVIEW);
- gGL.popMatrix();
-
+ gGL.popMatrix();
+
set_current_modelview(saved_modelview);
- }
+ }
//LLPipeline::sUseOcclusion = occlusion;
- camera.setOrigin(camera_in.getOrigin());
- //render distortion map
- static bool last_update = true;
- if (last_update)
- {
+ camera.setOrigin(camera_in.getOrigin());
+ //render distortion map
+ static bool last_update = true;
+ if (last_update)
+ {
gPipeline.pushRenderTypeMask();
- camera.setFar(camera_in.getFar());
- clearRenderTypeMask(LLPipeline::RENDER_TYPE_WATER,
- LLPipeline::RENDER_TYPE_VOIDWATER,
- LLPipeline::RENDER_TYPE_GROUND,
- END_RENDER_TYPES);
+ camera.setFar(camera_in.getFar());
+ clearRenderTypeMask(
+ LLPipeline::RENDER_TYPE_WATER,
+ LLPipeline::RENDER_TYPE_VOIDWATER,
+ LLPipeline::RENDER_TYPE_GROUND,
+ END_RENDER_TYPES);
// intentionally inverted so that distortion map contents (objects under the water when we're above it)
// will properly include water fog effects
LLPipeline::sUnderWaterRender = !camera_is_underwater;
- if (LLPipeline::sUnderWaterRender)
- {
+ if (LLPipeline::sUnderWaterRender)
+ {
clearRenderTypeMask(
- LLPipeline::RENDER_TYPE_GROUND,
- LLPipeline::RENDER_TYPE_SKY,
- LLPipeline::RENDER_TYPE_CLOUDS,
- LLPipeline::RENDER_TYPE_WL_SKY,
- END_RENDER_TYPES);
- }
- LLViewerCamera::updateFrustumPlanes(camera);
+ LLPipeline::RENDER_TYPE_GROUND,
+ LLPipeline::RENDER_TYPE_SKY,
+ LLPipeline::RENDER_TYPE_CLOUDS,
+ LLPipeline::RENDER_TYPE_WL_SKY,
+ END_RENDER_TYPES);
+ }
+ LLViewerCamera::updateFrustumPlanes(camera);
+
+ gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
- gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE);
-
if (LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsDistortionUpdate)
{
LLPipeline::sDistortionRender = true;
@@ -9439,10 +9444,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
glClearColor(col.mV[0], col.mV[1], col.mV[2], 0.f);
LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WATER1;
-
+
mWaterDis.bindTarget();
mWaterDis.getViewport(gGLViewport);
-
+
gGL.setColorMask(true, true);
mWaterDis.clear();
gGL.setColorMask(true, false);
@@ -9454,15 +9459,15 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
LLPlane plane(-pnorm, water_dist);
LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection);
- gGL.setColorMask(true, true);
- mWaterDis.clear();
- gGL.setColorMask(true, false);
+ gGL.setColorMask(true, true);
+ mWaterDis.clear();
+ gGL.setColorMask(true, false);
// ignore clip plane if we're underwater and viewing distortion map of objects above waterline
if (camera_is_underwater)
- {
+ {
clip_plane.disable();
- }
+ }
if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT)
{
@@ -9484,39 +9489,39 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in)
}
mWaterDis.flush();
- }
+ }
LLPipeline::sDistortionRender = false;
-
+
gPipeline.popRenderTypeMask();
- }
- last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
+ }
+ last_update = LLDrawPoolWater::sNeedsReflectionUpdate && LLDrawPoolWater::sNeedsDistortionUpdate;
gPipeline.popRenderTypeMask();
LLPipeline::sUseOcclusion = occlusion;
LLPipeline::sUnderWaterRender = false;
- LLPipeline::sReflectionRender = false;
+ LLPipeline::sReflectionRender = false;
LLDrawPoolWater::sNeedsReflectionUpdate = FALSE;
LLDrawPoolWater::sNeedsDistortionUpdate = FALSE;
- if (!LLRenderTarget::sUseFBO)
- {
- glClear(GL_DEPTH_BUFFER_BIT);
- }
- glClearColor(0.f, 0.f, 0.f, 0.f);
- gViewerWindow->setup3DViewport();
-
- LLGLState::checkStates();
+ if (!LLRenderTarget::sUseFBO)
+ {
+ glClear(GL_DEPTH_BUFFER_BIT);
+ }
+ glClearColor(0.f, 0.f, 0.f, 0.f);
+ gViewerWindow->setup3DViewport();
- if (!skip_avatar_update)
- {
- gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
- }
+ LLGLState::checkStates();
- LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
- }
+ if (!skip_avatar_update)
+ {
+ gAgentAvatarp->updateAttachmentVisibility(gAgentCamera.getCameraMode());
+ }
+
+ LLViewerCamera::sCurCameraID = LLViewerCamera::CAMERA_WORLD;
+ }
}
glh::matrix4f look(const LLVector3 pos, const LLVector3 dir, const LLVector3 up)