summaryrefslogtreecommitdiff
path: root/indra/newview/pipeline.cpp
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2011-03-01 15:22:17 -0600
committerDave Parks <davep@lindenlab.com>2011-03-01 15:22:17 -0600
commit5eeca73940bb083e76cb73d1528e61544d3f7fd2 (patch)
treed958e4caa6cebd64aa616c850408080e74b4cf8e /indra/newview/pipeline.cpp
parent10f14598243ef93f8990f9a1473334ef918f9cf7 (diff)
SH-1072 Fix for DoF focal point being incorrect.
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rwxr-xr-xindra/newview/pipeline.cpp41
1 files changed, 27 insertions, 14 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp
index c280805516..55d73f9808 100755
--- a/indra/newview/pipeline.cpp
+++ b/indra/newview/pipeline.cpp
@@ -6173,26 +6173,39 @@ void LLPipeline::renderBloom(BOOL for_snapshot, F32 zoom_factor, int subfield)
//depth of field focal plane calculations
- F32 subject_distance = 16.f;
- if (LLViewerJoystick::getInstance()->getOverrideCamera())
- {
- //flycam mode, use mouse cursor as focus point
- LLVector3 eye = LLViewerCamera::getInstance()->getOrigin();
- subject_distance = (eye-gDebugRaycastIntersection).magVec();
+ static F32 current_distance = 16.f;
+ static F32 start_distance = 16.f;
+ static F32 transition_time = 1.f;
+
+ LLVector3 eye = LLViewerCamera::getInstance()->getOrigin();
+ F32 target_distance = LLViewerCamera::getInstance()->getAtAxis() * (gDebugRaycastIntersection-eye);
+
+ if (transition_time >= 1.f &&
+ fabsf(current_distance-target_distance)/current_distance > 0.01f)
+ { //large shift happened, interpolate smoothly to new target distance
+ llinfos << "start" << llendl;
+ transition_time = 0.f;
+ start_distance = current_distance;
}
- else
- {
- LLViewerObject* obj = gAgentCamera.getFocusObject();
- if (obj)
+ else if (transition_time < 1.f)
+ { //currently in a transition, continue interpolating
+ transition_time += 1.f/gSavedSettings.getF32("CameraFocusTransitionTime")*gFrameIntervalSeconds;
+ if (transition_time >= 1.f)
{
- LLVector3 focus = LLVector3(gAgentCamera.getFocusGlobal()-gAgent.getRegion()->getOriginGlobal());
- LLVector3 eye = LLViewerCamera::getInstance()->getOrigin();
- subject_distance = (focus-eye).magVec();
+ llinfos << "stop" << llendl;
}
+ transition_time = llmin(transition_time, 1.f);
+
+ F32 t = cosf(transition_time*F_PI+F_PI)*0.5f+0.5f;
+ current_distance = start_distance + (target_distance-start_distance)*t;
+ }
+ else
+ { //small or no change, just snap to target distance
+ current_distance = target_distance;
}
//convert to mm
- subject_distance *= 1000.f;
+ F32 subject_distance = current_distance*1000.f;
F32 fnumber = gSavedSettings.getF32("CameraFNumber");
const F32 default_focal_length = gSavedSettings.getF32("CameraFocalLength");