Skip to content

Commit c3daf2a

Browse files
pyrolloSmallJoker
authored andcommittedJul 26, 2019
Fix missing item images clipping in formspecs (#8652)
* Fix clipping of itemimage * Code style * More code styling
1 parent a8446d2 commit c3daf2a

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed
 

Diff for: ‎src/client/hud.cpp

+24-3
Original file line numberDiff line numberDiff line change
@@ -649,10 +649,31 @@ void drawItemStack(video::IVideoDriver *driver,
649649
core::rect<s32> oldViewPort = driver->getViewPort();
650650
core::matrix4 oldProjMat = driver->getTransform(video::ETS_PROJECTION);
651651
core::matrix4 oldViewMat = driver->getTransform(video::ETS_VIEW);
652+
core::rect<s32> viewrect = rect;
653+
if (clip)
654+
viewrect.clipAgainst(*clip);
655+
652656
core::matrix4 ProjMatrix;
653-
ProjMatrix.buildProjectionMatrixOrthoLH(2, 2, -1, 100);
657+
ProjMatrix.buildProjectionMatrixOrthoLH(2.0f, 2.0f, -1.0f, 100.0f);
658+
659+
core::matrix4 ViewMatrix;
660+
ViewMatrix.buildProjectionMatrixOrthoLH(
661+
2.0f * viewrect.getWidth() / rect.getWidth(),
662+
2.0f * viewrect.getHeight() / rect.getHeight(),
663+
-1.0f,
664+
100.0f);
665+
ViewMatrix.setTranslation(core::vector3df(
666+
1.0f * (rect.LowerRightCorner.X + rect.UpperLeftCorner.X -
667+
viewrect.LowerRightCorner.X - viewrect.UpperLeftCorner.X) /
668+
viewrect.getWidth(),
669+
1.0f * (viewrect.LowerRightCorner.Y + viewrect.UpperLeftCorner.Y -
670+
rect.LowerRightCorner.Y - rect.UpperLeftCorner.Y) /
671+
viewrect.getHeight(),
672+
0.0f));
673+
654674
driver->setTransform(video::ETS_PROJECTION, ProjMatrix);
655-
driver->setTransform(video::ETS_VIEW, ProjMatrix);
675+
driver->setTransform(video::ETS_VIEW, ViewMatrix);
676+
656677
core::matrix4 matrix;
657678
matrix.makeIdentity();
658679

@@ -662,7 +683,7 @@ void drawItemStack(video::IVideoDriver *driver,
662683
}
663684

664685
driver->setTransform(video::ETS_WORLD, matrix);
665-
driver->setViewPort(rect);
686+
driver->setViewPort(viewrect);
666687

667688
video::SColor basecolor =
668689
client->idef()->getItemstackColor(item, client);

0 commit comments

Comments
 (0)
Please sign in to comment.