361361 +SpritePatch
362362 +DecalPatch
363363 +Added the Colour "Orange" cos some internet rando made me laugh about it :D
364+ +Changed ClipLineToScreen to ClipLineToDrawTarget
364365
365366
366367 !! Apple Platforms will not see these updates immediately - Sorry, I dont have a mac to test... !!
@@ -1513,7 +1514,7 @@ namespace olc
15131514 olc::Sprite* GetFontSprite ();
15141515
15151516 // Clip a line segment to visible area
1516- bool ClipLineToScreen (olc::vi2d& in_p1, olc::vi2d& in_p2);
1517+ bool ClipLineToDrawTarget (olc::vi2d& in_p1, olc::vi2d& in_p2);
15171518
15181519
15191520 // Patches
@@ -2740,7 +2741,7 @@ namespace olc
27402741 auto rol = [&](void ) { pattern = (pattern << 1 ) | (pattern >> 31 ); return pattern & 1 ; };
27412742
27422743 olc::vi2d p1 (x1, y1), p2 (x2, y2);
2743- if (!ClipLineToScreen (p1, p2))
2744+ if (!ClipLineToDrawTarget (p1, p2))
27442745 return ;
27452746 x1 = p1.x ; y1 = p1.y ;
27462747 x2 = p2.x ; y2 = p2.y ;
@@ -2932,15 +2933,17 @@ namespace olc
29322933 return fontRenderable.Sprite ();
29332934 }
29342935
2935- bool PixelGameEngine::ClipLineToScreen (olc::vi2d& in_p1, olc::vi2d& in_p2)
2936+ bool PixelGameEngine::ClipLineToDrawTarget (olc::vi2d& in_p1, olc::vi2d& in_p2)
29362937 {
2938+ olc::vi2d vDrawTargetSize{ (int32_t )GetDrawTargetWidth (), (int32_t )GetDrawTargetHeight () };
2939+
29372940 // https://en.wikipedia.org/wiki/Cohen%E2%80%93Sutherland_algorithm
29382941 static constexpr int SEG_I = 0b0000 , SEG_L = 0b0001 , SEG_R = 0b0010 , SEG_B = 0b0100 , SEG_T = 0b1000 ;
2939- auto Segment = [&vScreenSize = vScreenSize ](const olc::vi2d& v)
2942+ auto Segment = [&vDrawTargetSize = vDrawTargetSize ](const olc::vi2d& v)
29402943 {
29412944 int i = SEG_I ;
2942- if (v.x < 0 ) i |= SEG_L ; else if (v.x > vScreenSize .x ) i |= SEG_R ;
2943- if (v.y < 0 ) i |= SEG_B ; else if (v.y > vScreenSize .y ) i |= SEG_T ;
2945+ if (v.x < 0 ) i |= SEG_L ; else if (v.x > vDrawTargetSize .x ) i |= SEG_R ;
2946+ if (v.y < 0 ) i |= SEG_B ; else if (v.y > vDrawTargetSize .y ) i |= SEG_T ;
29442947 return i;
29452948 };
29462949
@@ -2954,9 +2957,9 @@ namespace olc
29542957 {
29552958 int s3 = s2 > s1 ? s2 : s1;
29562959 olc::vi2d n;
2957- if (s3 & SEG_T ) { n.x = in_p1.x + (in_p2.x - in_p1.x ) * (vScreenSize .y - in_p1.y ) / (in_p2.y - in_p1.y ); n.y = vScreenSize .y ; }
2960+ if (s3 & SEG_T ) { n.x = in_p1.x + (in_p2.x - in_p1.x ) * (vDrawTargetSize .y - in_p1.y ) / (in_p2.y - in_p1.y ); n.y = vDrawTargetSize .y ; }
29582961 else if (s3 & SEG_B ) { n.x = in_p1.x + (in_p2.x - in_p1.x ) * (0 - in_p1.y ) / (in_p2.y - in_p1.y ); n.y = 0 ; }
2959- else if (s3 & SEG_R ) { n.x = vScreenSize .x ; n.y = in_p1.y + (in_p2.y - in_p1.y ) * (vScreenSize .x - in_p1.x ) / (in_p2.x - in_p1.x ); }
2962+ else if (s3 & SEG_R ) { n.x = vDrawTargetSize .x ; n.y = in_p1.y + (in_p2.y - in_p1.y ) * (vDrawTargetSize .x - in_p1.x ) / (in_p2.x - in_p1.x ); }
29602963 else if (s3 & SEG_L ) { n.x = 0 ; n.y = in_p1.y + (in_p2.y - in_p1.y ) * (0 - in_p1.x ) / (in_p2.x - in_p1.x ); }
29612964 if (s3 == s1) { in_p1 = n; s1 = Segment (in_p1); }
29622965 else { in_p2 = n; s2 = Segment (in_p2); }
0 commit comments