/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Editor/EditorFramework/DocumentWindow/Implementation/OrbitCamViewWidget.cpp
73 строки
2 KB
Jan Krassnigg
Rewrote how the orbit camera behaves (#924)
13 апр 2023, 21:56
Не верифицирован
13 апр 2023, 21:56
fbbc284
Код
Авторство
О чём код?
#include <EditorFramework/EditorFrameworkPCH.h> #include <EditorFramework/DocumentWindow/OrbitCamViewWidget.moc.h> #include <EditorFramework/InputContexts/OrbitCameraContext.h> #include <EditorFramework/InputContexts/SelectionContext.h> ezQtOrbitCamViewWidget::ezQtOrbitCamViewWidget(ezQtEngineDocumentWindow* pOwnerWindow, ezEngineViewConfig* pViewConfig, bool bPicking) : ezQtEngineViewWidget(nullptr, pOwnerWindow, pViewConfig) { setAcceptDrops(true); m_pOrbitCameraContext = EZ_DEFAULT_NEW(ezOrbitCameraContext, pOwnerWindow, this); m_pOrbitCameraContext->SetCamera(&m_pViewConfig->m_Camera); if (bPicking) { m_pSelectionContext = EZ_DEFAULT_NEW(ezSelectionContext, pOwnerWindow, this, &m_pViewConfig->m_Camera); m_InputContexts.PushBack(m_pSelectionContext.Borrow()); } m_InputContexts.PushBack(m_pOrbitCameraContext.Borrow()); } ezQtOrbitCamViewWidget::~ezQtOrbitCamViewWidget() = default; void ezQtOrbitCamViewWidget::ConfigureFixed(const ezVec3& vCenterPos, const ezVec3& vHalfBoxSize, const ezVec3& vCamPosition) { m_pOrbitCameraContext->SetDefaultCameraFixed(vCamPosition); m_pOrbitCameraContext->SetOrbitVolume(vCenterPos, vHalfBoxSize); m_pOrbitCameraContext->MoveCameraToDefaultPosition(); m_bSetDefaultCamPos = false; } void ezQtOrbitCamViewWidget::ConfigureRelative(const ezVec3& vCenterPos, const ezVec3& vHalfBoxSize, const ezVec3& vCamDirection, float fCamDistanceScale) { m_pOrbitCameraContext->SetDefaultCameraRelative(vCamDirection, fCamDistanceScale); m_pOrbitCameraContext->SetOrbitVolume(vCenterPos, vHalfBoxSize); m_pOrbitCameraContext->MoveCameraToDefaultPosition(); m_bSetDefaultCamPos = true; } void ezQtOrbitCamViewWidget::SetOrbitVolume(const ezVec3& vCenterPos, const ezVec3& vHalfBoxSize) { m_pOrbitCameraContext->SetOrbitVolume(vCenterPos, vHalfBoxSize); if (m_bSetDefaultCamPos) { if (vHalfBoxSize != ezVec3(0.1f)) { // 0.1f is a hard-coded value for the bounding box, in case nothing is available yet // not pretty, but somehow we need to know when the first 'proper' bounds are available m_bSetDefaultCamPos = false; m_pOrbitCameraContext->MoveCameraToDefaultPosition(); } } } ezOrbitCameraContext* ezQtOrbitCamViewWidget::GetOrbitCamera() { return m_pOrbitCameraContext.Borrow(); } void ezQtOrbitCamViewWidget::SyncToEngine() { if (m_pSelectionContext) { m_pSelectionContext->SetWindowConfig(ezVec2I32(width(), height())); } ezQtEngineViewWidget::SyncToEngine(); }