diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-11-07 18:26:31 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-11-07 18:26:31 +1100 |
commit | 3b40e89b3297a97a833711dbb77734b0412ac1d9 (patch) | |
tree | d1ed453d1aa48868bc6e3de6233b7fce9b8801be /source/rendering/StarWorldCamera.cpp | |
parent | 9502b05ea4587f2c060608718486d5c8d5bc3ac5 (diff) |
Add camera bindings
override missing, but it's a start
Diffstat (limited to 'source/rendering/StarWorldCamera.cpp')
-rw-r--r-- | source/rendering/StarWorldCamera.cpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/source/rendering/StarWorldCamera.cpp b/source/rendering/StarWorldCamera.cpp deleted file mode 100644 index de23f3e..0000000 --- a/source/rendering/StarWorldCamera.cpp +++ /dev/null @@ -1,42 +0,0 @@ -#include "StarWorldCamera.hpp" - -namespace Star { - -void WorldCamera::setCenterWorldPosition(Vec2F const& position, bool force) { - m_rawWorldCenter = position; - // Only actually move the world center if a half pixel distance has been - // moved in any direction. This is sort of arbitrary, but helps prevent - // judder if the camera is at a boundary and floating point inaccuracy is - // causing the focus to jitter back and forth across the boundary. - if (fabs(position[0] - m_worldCenter[0]) < 1.0f / (TilePixels * m_pixelRatio * 2) - && fabs(position[1] - m_worldCenter[1]) < 1.0f / (TilePixels * m_pixelRatio * 2) && !force) - return; - - // First, make sure the camera center position is inside the main x - // coordinate bounds, and that the top and bototm of the screen are not - // outside of the y coordinate bounds. - m_worldCenter = m_worldGeometry.xwrap(position); - m_worldCenter[1] = clamp(m_worldCenter[1], - (float)m_screenSize[1] / (TilePixels * m_pixelRatio * 2), - m_worldGeometry.height() - (float)m_screenSize[1] / (TilePixels * m_pixelRatio * 2)); - - // Then, position the camera center position so that the tile grid is as - // close as possible aligned to whole pixel boundaries. This is incredibly - // important, because this means that even without any complicated rounding, - // elements drawn in world space that are aligned with TilePixels will - // eventually also be aligned to real screen pixels. - - float ratio = TilePixels * m_pixelRatio; - - if (m_screenSize[0] % 2 == 0) - m_worldCenter[0] = round(m_worldCenter[0] * ratio) / ratio; - else - m_worldCenter[0] = (round(m_worldCenter[0] * ratio + 0.5f) - 0.5f) / ratio; - - if (m_screenSize[1] % 2 == 0) - m_worldCenter[1] = round(m_worldCenter[1] * ratio) / ratio; - else - m_worldCenter[1] = (round(m_worldCenter[1] * ratio + 0.5f) - 0.5f) / ratio; -} - -} |