summaryrefslogtreecommitdiff
path: root/indra/newview/llviewercamera.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llviewercamera.cpp')
-rw-r--r--indra/newview/llviewercamera.cpp75
1 files changed, 45 insertions, 30 deletions
diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp
index b37f08283d..4134e35f87 100644
--- a/indra/newview/llviewercamera.cpp
+++ b/indra/newview/llviewercamera.cpp
@@ -50,6 +50,7 @@
#include "llquaternion.h"
#include "llwindow.h" // getPixelAspectRatio()
#include "lltracerecording.h"
+#include "llenvironment.h"
// System includes
#include <iomanip> // for setprecision
@@ -96,35 +97,41 @@ LLViewerCamera::LLViewerCamera() : LLCamera()
gSavedSettings.getControl("CameraAngle")->getCommitSignal()->connect(boost::bind(&LLViewerCamera::updateCameraAngle, this, _2));
}
-void LLViewerCamera::updateCameraLocation(const LLVector3 &center,
- const LLVector3 &up_direction,
- const LLVector3 &point_of_interest)
+void LLViewerCamera::updateCameraLocation(const LLVector3 &center, const LLVector3 &up_direction, const LLVector3 &point_of_interest)
{
- // do not update if avatar didn't move
- if (!LLViewerJoystick::getInstance()->getCameraNeedsUpdate())
- {
- return;
- }
-
- LLVector3 last_position;
- LLVector3 last_axis;
- last_position = getOrigin();
- last_axis = getAtAxis();
-
- mLastPointOfInterest = point_of_interest;
-
- LLViewerRegion * regp = gAgent.getRegion();
- F32 water_height = (NULL != regp) ? regp->getWaterHeight() : 0.f;
-
- LLVector3 origin = center;
- if (origin.mV[2] > water_height)
- {
- origin.mV[2] = llmax(origin.mV[2], water_height+0.20f);
- }
- else
- {
- origin.mV[2] = llmin(origin.mV[2], water_height-0.20f);
- }
+ // do not update if avatar didn't move
+ if (!LLViewerJoystick::getInstance()->getCameraNeedsUpdate())
+ {
+ return;
+ }
+
+ LLVector3 last_position;
+ LLVector3 last_axis;
+ last_position = getOrigin();
+ last_axis = getAtAxis();
+
+ mLastPointOfInterest = point_of_interest;
+
+ LLViewerRegion* regp = LLWorld::instance().getRegionFromPosAgent(getOrigin());
+ if (!regp)
+ {
+ regp = gAgent.getRegion();
+ }
+
+ F32 water_height = (NULL != regp) ? regp->getWaterHeight() : 0.f;
+
+ LLVector3 origin = center;
+
+ {
+ if (origin.mV[2] > water_height)
+ {
+ origin.mV[2] = llmax(origin.mV[2], water_height + 0.20f);
+ }
+ else
+ {
+ origin.mV[2] = llmin(origin.mV[2], water_height - 0.20f);
+ }
+ }
setOriginAndLookAt(origin, up_direction, point_of_interest);
@@ -755,11 +762,19 @@ LLVector3 LLViewerCamera::roundToPixel(const LLVector3 &pos_agent)
BOOL LLViewerCamera::cameraUnderWater() const
{
- if(!gAgent.getRegion())
+ LLViewerRegion* regionp = LLWorld::instance().getRegionFromPosAgent(getOrigin());
+
+ if (!regionp)
+ {
+ regionp = gAgent.getRegion();
+ }
+
+ if(!regionp)
{
return FALSE ;
}
- return getOrigin().mV[VZ] < gAgent.getRegion()->getWaterHeight();
+
+ return getOrigin().mV[VZ] < regionp->getWaterHeight();
}
BOOL LLViewerCamera::areVertsVisible(LLViewerObject* volumep, BOOL all_verts)