diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2019-07-26 19:44:29 +0200 |
---|---|---|
committer | SmallJoker <SmallJoker@users.noreply.github.com> | 2019-07-26 19:44:29 +0200 |
commit | c3daf2a8bed7eaa72f14d07c92b8ec61a994d6fa (patch) | |
tree | 3a072a7cb8dff6005eca8e803f37bba8ccfbfd55 /src/client | |
parent | a8446d29e8b7dd00afc542fc19a3fc3354a669b8 (diff) | |
download | minetest-c3daf2a8bed7eaa72f14d07c92b8ec61a994d6fa.tar.gz minetest-c3daf2a8bed7eaa72f14d07c92b8ec61a994d6fa.tar.bz2 minetest-c3daf2a8bed7eaa72f14d07c92b8ec61a994d6fa.zip |
Fix missing item images clipping in formspecs (#8652)
* Fix clipping of itemimage
* Code style
* More code styling
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/hud.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/client/hud.cpp b/src/client/hud.cpp index cb58fb500..51746f788 100644 --- a/src/client/hud.cpp +++ b/src/client/hud.cpp @@ -649,10 +649,31 @@ void drawItemStack(video::IVideoDriver *driver, core::rect<s32> oldViewPort = driver->getViewPort(); core::matrix4 oldProjMat = driver->getTransform(video::ETS_PROJECTION); core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW); + core::rect<s32> viewrect = rect; + if (clip) + viewrect.clipAgainst(*clip); + core::matrix4 ProjMatrix; - ProjMatrix.buildProjectionMatrixOrthoLH(2, 2, -1, 100); + ProjMatrix.buildProjectionMatrixOrthoLH(2.0f, 2.0f, -1.0f, 100.0f); + + core::matrix4 ViewMatrix; + ViewMatrix.buildProjectionMatrixOrthoLH( + 2.0f * viewrect.getWidth() / rect.getWidth(), + 2.0f * viewrect.getHeight() / rect.getHeight(), + -1.0f, + 100.0f); + ViewMatrix.setTranslation(core::vector3df( + 1.0f * (rect.LowerRightCorner.X + rect.UpperLeftCorner.X - + viewrect.LowerRightCorner.X - viewrect.UpperLeftCorner.X) / + viewrect.getWidth(), + 1.0f * (viewrect.LowerRightCorner.Y + viewrect.UpperLeftCorner.Y - + rect.LowerRightCorner.Y - rect.UpperLeftCorner.Y) / + viewrect.getHeight(), + 0.0f)); + driver->setTransform(video::ETS_PROJECTION, ProjMatrix); - driver->setTransform(video::ETS_VIEW, ProjMatrix); + driver->setTransform(video::ETS_VIEW, ViewMatrix); + core::matrix4 matrix; matrix.makeIdentity(); @@ -662,7 +683,7 @@ void drawItemStack(video::IVideoDriver *driver, } driver->setTransform(video::ETS_WORLD, matrix); - driver->setViewPort(rect); + driver->setViewPort(viewrect); video::SColor basecolor = client->idef()->getItemstackColor(item, client); |