@@ -649,10 +649,31 @@ void drawItemStack(video::IVideoDriver *driver,
649
649
core::rect<s32> oldViewPort = driver->getViewPort ();
650
650
core::matrix4 oldProjMat = driver->getTransform (video::ETS_PROJECTION);
651
651
core::matrix4 oldViewMat = driver->getTransform (video::ETS_VIEW);
652
+ core::rect<s32> viewrect = rect;
653
+ if (clip)
654
+ viewrect.clipAgainst (*clip);
655
+
652
656
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
+
654
674
driver->setTransform (video::ETS_PROJECTION, ProjMatrix);
655
- driver->setTransform (video::ETS_VIEW, ProjMatrix);
675
+ driver->setTransform (video::ETS_VIEW, ViewMatrix);
676
+
656
677
core::matrix4 matrix;
657
678
matrix.makeIdentity ();
658
679
@@ -662,7 +683,7 @@ void drawItemStack(video::IVideoDriver *driver,
662
683
}
663
684
664
685
driver->setTransform (video::ETS_WORLD, matrix);
665
- driver->setViewPort (rect );
686
+ driver->setViewPort (viewrect );
666
687
667
688
video::SColor basecolor =
668
689
client->idef ()->getItemstackColor (item, client);
0 commit comments