2
0
Rémi Verschelde 7 жил өмнө
parent
commit
ccf5a50250

+ 51 - 50
scene/resources/bit_mask.cpp

@@ -29,6 +29,7 @@
 /*************************************************************************/
 
 #include "bit_mask.h"
+
 #include "io/image_loader.h"
 
 void BitMap::create(const Size2 &p_size) {
@@ -189,13 +190,13 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 		{ //square value
 
 			/*
-	     checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent
-	     +---+---+
-	     | 1 | 2 |
-	     +---+---+
-	     | 4 | 8 | <- current pixel (curx,cury)
-	     +---+---+
-	     */
+			checking the 2x2 pixel grid, assigning these values to each pixel, if not transparent
+			+---+---+
+			| 1 | 2 |
+			+---+---+
+			| 4 | 8 | <- current pixel (curx,cury)
+			+---+---+
+			*/
 			//NOTE: due to the way we pick points from texture, rect needs to be smaller, otherwise it goes outside 1 pixel
 			Rect2i fixed_rect = Rect2i(rect.position, rect.size - Size2i(2, 2));
 			Point2i tl = Point2i(curx - 1, cury - 1);
@@ -215,13 +216,13 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 			case 5:
 			case 13:
 				/* going UP with these cases:
-		 1          5           13
-		 +---+---+  +---+---+  +---+---+
-		 | 1 |   |  | 1 |   |  | 1 |   |
-		 +---+---+  +---+---+  +---+---+
-		 |   |   |  | 4 |   |  | 4 | 8 |
-		 +---+---+  +---+---+  +---+---+
-		 */
+				1          5           13
+				+---+---+  +---+---+  +---+---+
+				| 1 |   |  | 1 |   |  | 1 |   |
+				+---+---+  +---+---+  +---+---+
+				|   |   |  | 4 |   |  | 4 | 8 |
+				+---+---+  +---+---+  +---+---+
+				*/
 				stepx = 0;
 				stepy = -1;
 				break;
@@ -230,13 +231,13 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 			case 10:
 			case 11:
 				/* going DOWN with these cases:
-		 8          10          11
-		 +---+---+  +---+---+   +---+---+
-		 |   |   |  |   | 2 |   | 1 | 2 |
-		 +---+---+  +---+---+   +---+---+
-		 |   | 8 |  |   | 8 |   |   | 8 |
-		 +---+---+  +---+---+  	+---+---+
-		 */
+				8          10         11
+				+---+---+  +---+---+  +---+---+
+				|   |   |  |   | 2 |  | 1 | 2 |
+				+---+---+  +---+---+  +---+---+
+				|   | 8 |  |   | 8 |  |   | 8 |
+				+---+---+  +---+---+  +---+---+
+				*/
 				stepx = 0;
 				stepy = 1;
 				break;
@@ -245,13 +246,13 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 			case 12:
 			case 14:
 				/* going LEFT with these cases:
-		 4          12          14
-		 +---+---+  +---+---+   +---+---+
-		 |   |   |  |   |   |   |   | 2 |
-		 +---+---+  +---+---+   +---+---+
-		 | 4 |   |  | 4 | 8 |   | 4 | 8 |
-		 +---+---+  +---+---+  	+---+---+
-		 */
+				4          12         14
+				+---+---+  +---+---+  +---+---+
+				|   |   |  |   |   |  |   | 2 |
+				+---+---+  +---+---+  +---+---+
+				| 4 |   |  | 4 | 8 |  | 4 | 8 |
+				+---+---+  +---+---+  +---+---+
+				*/
 				stepx = -1;
 				stepy = 0;
 				break;
@@ -260,25 +261,25 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 			case 3:
 			case 7:
 				/* going RIGHT with these cases:
-		 2          3           7
-		 +---+---+  +---+---+   +---+---+
-		 |   | 2 |  | 1 | 2 |   | 1 | 2 |
-		 +---+---+  +---+---+   +---+---+
-		 |   |   |  |   |   |   | 4 |   |
-		 +---+---+  +---+---+  	+---+---+
-		 */
+				2          3          7
+				+---+---+  +---+---+  +---+---+
+				|   | 2 |  | 1 | 2 |  | 1 | 2 |
+				+---+---+  +---+---+  +---+---+
+				|   |   |  |   |   |  | 4 |   |
+				+---+---+  +---+---+  +---+---+
+				*/
 				stepx = 1;
 				stepy = 0;
 				break;
 			case 9:
 				/*
-		 +---+---+
-		 | 1 |   |
-		 +---+---+
-		 |   | 8 |
-		 +---+---+
-		 this should normally go UP, but if we already been here, we go down
-		*/
+				+---+---+
+				| 1 |   |
+				+---+---+
+				|   | 8 |
+				+---+---+
+				this should normally go UP, but if we already been here, we go down
+				*/
 				if (case9s.has(Point2i(curx, cury))) {
 					//found, so we go down, and delete from case9s;
 					stepx = 0;
@@ -293,14 +294,14 @@ Vector<Vector2> BitMap::_march_square(const Rect2i &rect, const Point2i &start)
 				break;
 			case 6:
 				/*
-		 6
-		 +---+---+
-		 |   | 2 |
-		 +---+---+
-		 | 4 |   |
-		 +---+---+
-		 this normally go RIGHT, but if its coming from UP, it should go LEFT
-		 */
+				6
+				+---+---+
+				|   | 2 |
+				+---+---+
+				| 4 |   |
+				+---+---+
+				this normally go RIGHT, but if its coming from UP, it should go LEFT
+				*/
 				if (case6s.has(Point2i(curx, cury))) {
 					//found, so we go down, and delete from case6s;
 					stepx = -1;