Added rounding to various translations like camera movements.

This commit is contained in:
Leon Styhre 2022-09-05 20:13:47 +02:00
parent 881b602cb4
commit ff0e76332c
7 changed files with 19 additions and 16 deletions

View file

@ -1194,14 +1194,16 @@ void SystemView::renderElements(const glm::mat4& parentTrans, bool abovePrimary)
mCarousel->getType() ==
CarouselComponent<SystemData*>::CarouselType::HORIZONTAL_WHEEL)
elementTrans = glm::translate(
elementTrans, glm::vec3 {(i - mCamOffset) * mSize.x, 0.0f, 0.0f});
elementTrans,
glm::round(glm::vec3 {(i - mCamOffset) * mSize.x, 0.0f, 0.0f}));
else
elementTrans = glm::translate(
elementTrans, glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f});
elementTrans,
glm::round(glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f}));
}
else if (mTextList != nullptr) {
elementTrans = glm::translate(elementTrans,
glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f});
elementTrans = glm::translate(
elementTrans, glm::round(glm::vec3 {0.0f, (i - mCamOffset) * mSize.y, 0.0f}));
}
mRenderer->pushClipRect(

View file

@ -354,7 +354,7 @@ void ViewController::goToSystemView(SystemData* system, bool playTransition)
// Application startup animation.
if (applicationStartup) {
mCamera = glm::translate(mCamera, -mCurrentView->getPosition());
mCamera = glm::translate(mCamera, glm::round(-mCurrentView->getPosition()));
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
if (getSystemListView()->getPrimaryType() == SystemView::PrimaryType::CAROUSEL) {
if (getSystemListView()->getCarouselType() ==
@ -540,7 +540,7 @@ void ViewController::goToGamelist(SystemData* system)
// Application startup animation, if starting in a gamelist rather than in the system view.
if (mState.viewing == NOTHING) {
mCamera = glm::translate(mCamera, -mCurrentView->getPosition());
mCamera = glm::translate(mCamera, glm::round(-mCurrentView->getPosition()));
if (Settings::getInstance()->getString("TransitionStyle") == "slide") {
mCamera[3].y -= Renderer::getScreenHeight();
updateHelpPrompts();

View file

@ -229,9 +229,9 @@ const glm::mat4& GuiComponent::getTransform()
mTransform = glm::translate(mTransform, glm::vec3 {xOff, yOff, 0.0f});
}
mTransform =
glm::translate(mTransform, glm::vec3 {std::round(mOrigin.x * mSize.x * -1.0f),
std::round(mOrigin.y * mSize.y * -1.0f), 0.0f});
mTransform = glm::translate(
mTransform,
glm::round(glm::vec3 {mOrigin.x * mSize.x * -1.0f, mOrigin.y * mSize.y * -1.0f, 0.0f}));
return mTransform;
}

View file

@ -613,7 +613,7 @@ void Window::renderLoadingScreen(std::string text)
float x {std::round((Renderer::getScreenWidth() - cache->metrics.size.x) / 2.0f)};
float y {std::round(Renderer::getScreenHeight() * 0.835f)};
trans = glm::translate(trans, glm::vec3 {x, y, 0.0f});
trans = glm::translate(trans, glm::round(glm::vec3 {x, y, 0.0f}));
mRenderer->setMatrix(trans);
font->renderTextCache(cache);
delete cache;

View file

@ -27,9 +27,9 @@ public:
void apply(float t) override
{
t -= 1;
cameraPosition[3].x = -glm::mix(-mCameraStart[3].x, mTarget.x, t * t * t + 1);
cameraPosition[3].y = -glm::mix(-mCameraStart[3].y, mTarget.y, t * t * t + 1);
cameraPosition[3].z = -glm::mix(-mCameraStart[3].z, mTarget.z, t * t * t + 1);
cameraPosition[3].x = std::round(-glm::mix(-mCameraStart[3].x, mTarget.x, t * t * t + 1));
cameraPosition[3].y = std::round(-glm::mix(-mCameraStart[3].y, mTarget.y, t * t * t + 1));
cameraPosition[3].z = std::round(-glm::mix(-mCameraStart[3].z, mTarget.z, t * t * t + 1));
}
private:

View file

@ -180,7 +180,7 @@ void DateTimeEditComponent::render(const glm::mat4& parentTrans)
if (mAlignRight)
off.x += referenceSize - mTextCache->metrics.size.x;
trans = glm::translate(trans, off);
trans = glm::translate(trans, glm::round(off));
mRenderer->setMatrix(trans);

View file

@ -295,7 +295,8 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
// Text + cursor rendering.
// Offset into our "text area" (padding).
trans = glm::translate(trans, glm::vec3 {getTextAreaPos().x, getTextAreaPos().y, 0.0f});
trans =
glm::translate(trans, glm::round(glm::vec3 {getTextAreaPos().x, getTextAreaPos().y, 0.0f}));
glm::ivec2 clipPos {static_cast<int>(trans[3].x), static_cast<int>(trans[3].y)};
// Use "text area" size for clipping.
@ -307,7 +308,7 @@ void TextEditComponent::render(const glm::mat4& parentTrans)
static_cast<int>(dimScaled.y - trans[3].y)};
mRenderer->pushClipRect(clipPos, clipDim);
trans = glm::translate(trans, glm::vec3 {-mScrollOffset.x, -mScrollOffset.y, 0.0f});
trans = glm::translate(trans, glm::round(glm::vec3 {-mScrollOffset.x, -mScrollOffset.y, 0.0f}));
mRenderer->setMatrix(trans);
if (mTextCache)