/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/Editor/EditorFramework/Gizmos/Implementation/ConeAngleGizmo.cpp
155 строк
4 KB
Trevor Cash
Update (Templatize) Primative Type Tests to test both float and double versions. (#1785)
27 янв 2026, 09:34
Не верифицирован
27 янв 2026, 09:34
6a0df83
Код
Авторство
О чём код?
#include <EditorFramework/EditorFrameworkPCH.h> #include <EditorFramework/Assets/AssetDocument.h> #include <EditorFramework/DocumentWindow/EngineDocumentWindow.moc.h> #include <EditorFramework/Gizmos/ConeAngleGizmo.h> EZ_BEGIN_DYNAMIC_REFLECTED_TYPE(ezConeAngleGizmo, 1, ezRTTINoAllocator) EZ_END_DYNAMIC_REFLECTED_TYPE; ezConeAngleGizmo::ezConeAngleGizmo() { m_Angle = ezAngle::MakeFromDegree(1.0f); m_fAngleScale = 1.0f; m_fRadius = 1.0f; m_ManipulateMode = ManipulateMode::None; m_hConeAngle.ConfigureHandle(this, ezEngineGizmoHandleType::Cone, ezColorLinearUB(200, 200, 0, 128), ezGizmoFlags::Pickable); SetVisible(false); SetTransformation(ezTransform::MakeIdentity()); } void ezConeAngleGizmo::OnSetOwner(ezQtEngineDocumentWindow* pOwnerWindow, ezQtEngineViewWidget* pOwnerView) { pOwnerWindow->GetDocument()->AddSyncObject(&m_hConeAngle); } void ezConeAngleGizmo::OnVisibleChanged(bool bVisible) { m_hConeAngle.SetVisible(bVisible); } void ezConeAngleGizmo::OnTransformationChanged(const ezTransform& transform) { ezTransform t = transform; t.m_vScale *= ezVec3(1.0f, m_fAngleScale, m_fAngleScale) * m_fRadius; m_hConeAngle.SetTransformation(t); } void ezConeAngleGizmo::DoFocusLost(bool bCancel) { ezGizmoEvent ev; ev.m_pGizmo = this; ev.m_Type = bCancel ? ezGizmoEvent::Type::CancelInteractions : ezGizmoEvent::Type::EndInteractions; m_GizmoEvents.Broadcast(ev); ezViewHighlightMsgToEngine msg; GetOwnerWindow()->GetEditorEngineConnection()->SendHighlightObjectMessage(&msg); m_hConeAngle.SetVisible(true); m_ManipulateMode = ManipulateMode::None; } ezEditorInput ezConeAngleGizmo::DoMousePressEvent(QMouseEvent* e) { if (IsActiveInputContext()) return ezEditorInput::WasExclusivelyHandled; if (e->button() != Qt::MouseButton::LeftButton) return ezEditorInput::MayBeHandledByOthers; if (e->modifiers() != 0 && e->modifiers() != Qt::KeyboardModifier::ShiftModifier) // allow shift for toggling snapping return ezEditorInput::MayBeHandledByOthers; if (m_pInteractionGizmoHandle == &m_hConeAngle) { m_ManipulateMode = ManipulateMode::Angle; } else return ezEditorInput::MayBeHandledByOthers; ezViewHighlightMsgToEngine msg; msg.m_HighlightObject = m_pInteractionGizmoHandle->GetGuid(); GetOwnerWindow()->GetEditorEngineConnection()->SendHighlightObjectMessage(&msg); m_LastInteraction = ezTime::Now(); m_vLastMousePos = SetMouseMode(ezEditorInputContext::MouseMode::HideAndWrapAtScreenBorders); SetActiveInputContext(this); ezGizmoEvent ev; ev.m_pGizmo = this; ev.m_Type = ezGizmoEvent::Type::BeginInteractions; m_GizmoEvents.Broadcast(ev); return ezEditorInput::WasExclusivelyHandled; } ezEditorInput ezConeAngleGizmo::DoMouseReleaseEvent(QMouseEvent* e) { if (!IsActiveInputContext()) return ezEditorInput::MayBeHandledByOthers; if (e->button() != Qt::MouseButton::LeftButton) return ezEditorInput::WasExclusivelyHandled; FocusLost(false); SetActiveInputContext(nullptr); return ezEditorInput::WasExclusivelyHandled; } ezEditorInput ezConeAngleGizmo::DoMouseMoveEvent(QMouseEvent* e) { if (!IsActiveInputContext()) return ezEditorInput::MayBeHandledByOthers; const ezTime tNow = ezTime::Now(); if (tNow - m_LastInteraction < ezTime::MakeFromSeconds(1.0 / 25.0)) return ezEditorInput::WasExclusivelyHandled; m_LastInteraction = tNow; const QPoint mousePosition = e->globalPosition().toPoint(); const ezVec2I32 vNewMousePos = ezVec2I32(mousePosition.x(), mousePosition.y()); const ezVec2I32 vDiff = vNewMousePos - m_vLastMousePos; m_vLastMousePos = UpdateMouseMode(e); const float fSpeed = 0.02f; const ezAngle aSpeed = ezAngle::MakeFromDegree(1.0f); { m_Angle += float(vDiff.x) * aSpeed; m_Angle -= float(vDiff.y) * aSpeed; m_Angle = ezMath::Clamp(m_Angle, ezAngle(), ezAngle::MakeFromDegree(179.0f)); m_fAngleScale = ezMath::Tan(m_Angle * 0.5f); } // update the scale OnTransformationChanged(GetTransformation()); ezGizmoEvent ev; ev.m_pGizmo = this; ev.m_Type = ezGizmoEvent::Type::Interaction; m_GizmoEvents.Broadcast(ev); return ezEditorInput::WasExclusivelyHandled; } void ezConeAngleGizmo::SetAngle(ezAngle angle) { m_Angle = angle; m_fAngleScale = ezMath::Tan(m_Angle * 0.5f); // update the scale OnTransformationChanged(GetTransformation()); }