IDisplayViewport.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. struct DisplayContext;
  10. class CBaseObjectsCache;
  11. class QPoint;
  12. struct AABB;
  13. class CViewport;
  14. // Viewport functionality required for DisplayContext
  15. struct IDisplayViewport
  16. {
  17. virtual void Update() = 0;
  18. virtual float GetScreenScaleFactor(const Vec3& position) const = 0;
  19. /**
  20. * Gets the distance of the point on screen to the line defined by the two points, converted to screenspace.
  21. * @param lineP1 The first point of the line, in world space.
  22. * @param lineP2 The second point of the line, in world space.
  23. * @param point The point to check the distance from the line. This point is in screen space.
  24. * @return The distance of the point to the line.
  25. */
  26. virtual float GetDistanceToLine(const Vec3& lineP1, const Vec3& lineP2, const QPoint& point) const = 0;
  27. enum EAxis
  28. {
  29. AXIS_NONE,
  30. AXIS_X,
  31. AXIS_Y,
  32. AXIS_Z
  33. };
  34. virtual void GetPerpendicularAxis(EAxis* axis, bool* is2D) const = 0;
  35. virtual const Matrix34& GetViewTM() const = 0;
  36. virtual const Matrix34& GetScreenTM() const = 0;
  37. virtual QPoint WorldToView(const Vec3& worldPoint) const = 0;
  38. virtual Vec3 WorldToView3D(const Vec3& worldPoint, int flags = 0) const = 0;
  39. virtual Vec3 ViewToWorld(const QPoint& vp, bool* collideWithTerrain = nullptr, bool onlyTerrain = false, bool bSkipVegetation = false, bool bTestRenderMesh = false, bool* collideWithObject = nullptr) const = 0;
  40. virtual void ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const = 0;
  41. virtual void setRay(QPoint& vp, Vec3& raySrc, Vec3& rayDir) = 0;
  42. virtual float GetAspectRatio() const = 0;
  43. virtual bool IsBoundsVisible(const AABB& box) const = 0;
  44. virtual void ScreenToClient(QPoint& pt) const = 0;
  45. virtual void GetDimensions(int* width, int* height) const = 0;
  46. virtual CViewport *asCViewport() { return nullptr; }
  47. };