summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatercamera.cpp
diff options
context:
space:
mode:
authorBrad Linden <brad@lindenlab.com>2024-04-24 09:55:34 -0700
committerBrad Linden <brad@lindenlab.com>2024-04-24 09:55:34 -0700
commit86c0c1d5536897c925f4e8aa2859a160313d964c (patch)
tree9d32be1b0d6a4dd139d8a72b35a94f48046b2ffc /indra/newview/llfloatercamera.cpp
parentcadc1a02cc7289dabd368dd1a1d237c042e9f82e (diff)
parentd98fc504a1d4bc292ba86acdda053c8b4598a193 (diff)
Merge remote-tracking branch 'origin/main' into release/materials_featurette
Diffstat (limited to 'indra/newview/llfloatercamera.cpp')
-rw-r--r--indra/newview/llfloatercamera.cpp158
1 files changed, 137 insertions, 21 deletions
diff --git a/indra/newview/llfloatercamera.cpp b/indra/newview/llfloatercamera.cpp
index 1c69b9d60b..7985ce447f 100644
--- a/indra/newview/llfloatercamera.cpp
+++ b/indra/newview/llfloatercamera.cpp
@@ -44,6 +44,7 @@
#include "llfirstuse.h"
#include "llhints.h"
#include "lltabcontainer.h"
+#include "llviewercamera.h"
#include "llvoavatarself.h"
static LLDefaultChildRegistry::Register<LLPanelCameraItem> r("panel_camera_item");
@@ -65,13 +66,19 @@ class LLPanelCameraZoom
: public LLPanel
{
LOG_CLASS(LLPanelCameraZoom);
+
public:
- LLPanelCameraZoom();
+ struct Params : public LLInitParam::Block<Params, LLPanel::Params> {};
+
+ LLPanelCameraZoom() { onCreate(); }
/* virtual */ BOOL postBuild();
/* virtual */ void draw();
protected:
+ LLPanelCameraZoom(const Params& p) { onCreate(); }
+
+ void onCreate();
void onZoomPlusHeldDown();
void onZoomMinusHeldDown();
void onSliderValueChanged();
@@ -80,9 +87,11 @@ protected:
F32 getOrbitRate(F32 time);
private:
- LLButton* mPlusBtn;
- LLButton* mMinusBtn;
- LLSlider* mSlider;
+ LLButton* mPlusBtn { nullptr };
+ LLButton* mMinusBtn{ nullptr };
+ LLSlider* mSlider{ nullptr };
+
+ friend class LLUICtrlFactory;
};
LLPanelCameraItem::Params::Params()
@@ -158,10 +167,7 @@ static LLPanelInjector<LLPanelCameraZoom> t_camera_zoom_panel("camera_zoom_panel
// LLPanelCameraZoom
//-------------------------------------------------------------------------------
-LLPanelCameraZoom::LLPanelCameraZoom()
-: mPlusBtn( NULL ),
- mMinusBtn( NULL ),
- mSlider( NULL )
+void LLPanelCameraZoom::onCreate()
{
mCommitCallbackRegistrar.add("Zoom.minus", boost::bind(&LLPanelCameraZoom::onZoomMinusHeldDown, this));
mCommitCallbackRegistrar.add("Zoom.plus", boost::bind(&LLPanelCameraZoom::onZoomPlusHeldDown, this));
@@ -172,9 +178,9 @@ LLPanelCameraZoom::LLPanelCameraZoom()
BOOL LLPanelCameraZoom::postBuild()
{
- mPlusBtn = getChild <LLButton> ("zoom_plus_btn");
- mMinusBtn = getChild <LLButton> ("zoom_minus_btn");
- mSlider = getChild <LLSlider> ("zoom_slider");
+ mPlusBtn = getChild<LLButton>("zoom_plus_btn");
+ mMinusBtn = getChild<LLButton>("zoom_minus_btn");
+ mSlider = getChild<LLSlider>("zoom_slider");
return LLPanel::postBuild();
}
@@ -240,11 +246,80 @@ void activate_camera_tool()
LLToolMgr::getInstance()->setTransientTool(LLToolCamera::getInstance());
};
+class LLCameraInfoPanel : public LLPanel
+{
+public:
+ typedef std::function<LLVector3()> get_vector_t;
+
+ LLCameraInfoPanel(
+ const LLView* parent,
+ const char* title,
+ const LLCoordFrame& camera,
+ const get_vector_t get_focus
+ )
+ : LLPanel([&]() -> LLPanel::Params
+ {
+ LLPanel::Params params;
+ params.rect = LLRect(parent->getLocalRect());
+ return params;
+ }())
+ , mTitle(title)
+ , mCamera(camera)
+ , mGetFocus(get_focus)
+ , mFont(LLFontGL::getFontSansSerifBig())
+ {
+ }
+
+ virtual void draw() override
+ {
+ LLPanel::draw();
+
+ static const U32 HPADDING = 10;
+ static const U32 VPADDING = 5;
+ LLVector3 focus = mGetFocus();
+ LLVector3 sight = focus - mCamera.mOrigin;
+ std::pair<const char*, const LLVector3&> const data[] =
+ {
+ { "Origin:", mCamera.mOrigin },
+ { "X Axis:", mCamera.mXAxis },
+ { "Y Axis:", mCamera.mYAxis },
+ { "Z Axis:", mCamera.mZAxis },
+ { "Focus:", focus },
+ { "Sight:", sight }
+ };
+ S32 width = getRect().getWidth();
+ S32 height = getRect().getHeight();
+ S32 row_count = 1 + sizeof(data) / sizeof(*data);
+ S32 row_height = (height - VPADDING * 2) / row_count;
+ S32 top = height - VPADDING - row_height / 2;
+ mFont->renderUTF8(mTitle, 0, HPADDING, top, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER);
+ for (const auto& row : data)
+ {
+ top -= row_height;
+ mFont->renderUTF8(row.first, 0, HPADDING, top, LLColor4::white, LLFontGL::LEFT, LLFontGL::VCENTER);
+ const LLVector3& vector = row.second;
+ for (S32 i = 0; i < 3; ++i)
+ {
+ std::string text = llformat("%.6f", vector[i]);
+ S32 right = width / 4 * (i + 2) - HPADDING;
+ mFont->renderUTF8(text, 0, right, top, LLColor4::white, LLFontGL::RIGHT, LLFontGL::VCENTER);
+ }
+ }
+ }
+
+private:
+ const char* mTitle;
+ const LLCoordFrame& mCamera;
+ const get_vector_t mGetFocus;
+ const LLFontGL* mFont;
+};
+
//
// Member functions
//
-/*static*/ bool LLFloaterCamera::inFreeCameraMode()
+// static
+bool LLFloaterCamera::inFreeCameraMode()
{
LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
if (floater_camera && floater_camera->mCurrMode == CAMERA_CTRL_MODE_FREE_CAMERA && gAgentCamera.getCameraMode() != CAMERA_MODE_MOUSELOOK)
@@ -254,6 +329,7 @@ void activate_camera_tool()
return false;
}
+// static
void LLFloaterCamera::resetCameraMode()
{
LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
@@ -261,6 +337,7 @@ void LLFloaterCamera::resetCameraMode()
floater_camera->switchMode(CAMERA_CTRL_MODE_PAN);
}
+// static
void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
{
sAppearanceEditing = editing;
@@ -269,15 +346,46 @@ void LLFloaterCamera::onAvatarEditingAppearance(bool editing)
floater_camera->handleAvatarEditingAppearance(editing);
}
-void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
+// static
+void LLFloaterCamera::onDebugCameraToggled()
{
+ if (LLFloaterCamera* instance = LLFloaterCamera::findInstance())
+ {
+ instance->showDebugInfo(LLView::sDebugCamera);
+ }
+ if (LLView::sDebugCamera)
+ {
+ LLFloaterReg::showInstanceOrBringToFront("camera");
+ }
+}
+
+void LLFloaterCamera::showDebugInfo(bool show)
+{
+ // Initially LLPanel contains 1 child "view_border"
+ if (show && mViewerCameraInfo->getChildCount() < 2)
+ {
+ mViewerCameraInfo->addChild(new LLCameraInfoPanel(mViewerCameraInfo, "Viewer Camera", *LLViewerCamera::getInstance(),
+ []() { return LLViewerCamera::getInstance()->getPointOfInterest(); }));
+ mAgentCameraInfo->addChild(new LLCameraInfoPanel(mAgentCameraInfo, "Agent Camera", gAgent.getFrameAgent(),
+ []() { return gAgent.getPosAgentFromGlobal(gAgentCamera.calcFocusPositionTargetGlobal()); }));
+ }
+
+ mAgentCameraInfo->setVisible(show);
+ mViewerCameraInfo->setVisible(show);
+}
+
+void LLFloaterCamera::handleAvatarEditingAppearance(bool editing)
+{
}
void LLFloaterCamera::update()
{
ECameraControlMode mode = determineMode();
- if (mode != mCurrMode) setMode(mode);
+ if (mode != mCurrMode)
+ {
+ setMode(mode);
+ }
}
@@ -286,7 +394,8 @@ void LLFloaterCamera::toPrevMode()
switchMode(mPrevMode);
}
-/*static*/ void LLFloaterCamera::onLeavingMouseLook()
+// static
+void LLFloaterCamera::onLeavingMouseLook()
{
LLFloaterCamera* floater_camera = LLFloaterCamera::findInstance();
if (floater_camera)
@@ -320,12 +429,14 @@ void LLFloaterCamera::onOpen(const LLSD& key)
mClosed = FALSE;
populatePresetCombo();
+
+ showDebugInfo(LLView::sDebugCamera);
}
void LLFloaterCamera::onClose(bool app_quitting)
{
//We don't care of camera mode if app is quitting
- if(app_quitting)
+ if (app_quitting)
return;
// It is necessary to reset mCurrMode to CAMERA_CTRL_MODE_PAN so
// to avoid seeing an empty floater when reopening the control.
@@ -360,14 +471,18 @@ BOOL LLFloaterCamera::postBuild()
{
updateTransparency(TT_ACTIVE); // force using active floater transparency (STORM-730)
+ mControls = getChild<LLPanel>("controls");
+ mAgentCameraInfo = getChild<LLPanel>("agent_camera_info");
+ mViewerCameraInfo = getChild<LLPanel>("viewer_camera_info");
mRotate = getChild<LLJoystickCameraRotate>(ORBIT);
- mZoom = findChild<LLPanelCameraZoom>(ZOOM);
+ mZoom = getChild<LLPanelCameraZoom>(ZOOM);
mTrack = getChild<LLJoystickCameraTrack>(PAN);
mPresetCombo = getChild<LLComboBox>("preset_combo");
+ mPreciseCtrls = getChild<LLTextBox>("precise_ctrs_label");
- getChild<LLTextBox>("precise_ctrs_label")->setShowCursorHand(false);
- getChild<LLTextBox>("precise_ctrs_label")->setSoundFlags(LLView::MOUSE_UP);
- getChild<LLTextBox>("precise_ctrs_label")->setClickedCallback(boost::bind(&LLFloaterReg::showInstance, "prefs_view_advanced", LLSD(), FALSE));
+ mPreciseCtrls->setShowCursorHand(false);
+ mPreciseCtrls->setSoundFlags(LLView::MOUSE_UP);
+ mPreciseCtrls->setClickedCallback(boost::bind(&LLFloaterReg::showInstance, "prefs_view_advanced", LLSD(), FALSE));
mPresetCombo->setCommitCallback(boost::bind(&LLFloaterCamera::onCustomPresetSelected, this));
LLPresetsManager::getInstance()->setPresetListChangeCameraCallback(boost::bind(&LLFloaterCamera::populatePresetCombo, this));
@@ -507,6 +622,7 @@ void LLFloaterCamera::updateItemsSelection()
getChild<LLPanelCameraItem>("object_view")->setValue(argument);
}
+// static
void LLFloaterCamera::onClickCameraItem(const LLSD& param)
{
std::string name = param.asString();
@@ -533,7 +649,7 @@ void LLFloaterCamera::onClickCameraItem(const LLSD& param)
}
}
-/*static*/
+// static
void LLFloaterCamera::switchToPreset(const std::string& name)
{
sFreeCamera = false;